Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <YSI\y_ini>
- #include <zcmd>
- #define COLOR_ERROR 0xFFFF0000
- #define DIALOG_COLOUR_TEXT 233
- //isnull
- #if !defined isnull
- #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
- #endif
- new textcolour[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" ColourText by Turbo Loaded");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- enum PlayerInfo
- {
- ColourText
- }
- new pInfo[MAX_PLAYERS][PlayerInfo];
- stock Path(playerid)
- {
- new string[128],name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- format(string,sizeof(string),"Users/Coloured Text/%s.ini",name);
- return string;
- }
- forward loadaccount_user(playerid, name[], value[]);
- public loadaccount_user(playerid, name[], value[])
- {
- INI_Int("ColourText",pInfo[playerid][ColourText]);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- textcolour[playerid] = 0;
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- if(fexist(Path(playerid)))
- {
- INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
- }
- else
- {
- new INI:file = INI_Open(Path(playerid));
- INI_SetTag(file,"Data");
- INI_WriteInt(file,"ColourText",0);
- INI_Close(file);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:file = INI_Open(Path(playerid));
- INI_SetTag(file,"Data");
- INI_WriteInt(file,"ColourText",pInfo[playerid][ColourText]);
- INI_Close(file);
- textcolour[playerid] = 0;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(dialogid == DIALOG_COLOUR_TEXT)
- {
- if(response)
- {
- switch(listitem)
- {
- case 0: textcolour[playerid] = 1;
- case 1: textcolour[playerid] = 2;
- case 2: textcolour[playerid] = 3;
- case 3: textcolour[playerid] = 4;
- case 4: textcolour[playerid] = 5;
- case 5: textcolour[playerid] = 6;
- case 6: textcolour[playerid] = 7;
- case 7: textcolour[playerid] = 0;
- }
- }
- return 1;
- }
- return 0;
- }
- public OnPlayerText(playerid, text[])
- {
- new str[128];
- if(textcolour[playerid] == 1)
- {
- format(str, sizeof(str), "{0000FF}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 2)
- {
- format(str, sizeof(str), "{FFFF00}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 3)
- {
- format(str, sizeof(str), "{FF0000}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 4)
- {
- format(str, sizeof(str), "{000000}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 5)
- {
- format(str, sizeof(str), "{00FF00}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 6)
- {
- format(str, sizeof(str), "{00FFFF}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- if(textcolour[playerid] == 7)
- {
- format(str, sizeof(str), "{FF8000}%s",text[0]);
- SendPlayerMessageToAll(playerid, str);
- return 0;
- }
- return 1;
- }
- CMD:colourtext(playerid,params[])
- {
- if(pInfo[playerid][ColourText] == 0)
- {
- SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: You are not authorised to use Colour Text!");
- return 1;
- }
- if(pInfo[playerid][ColourText] == 1)
- {
- ShowPlayerDialog(playerid,DIALOG_COLOUR_TEXT,DIALOG_STYLE_LIST,"Colour Text", "Blue\nYellow\nRed\nBlack\nGreen\nLight Blue\nOrange\nTurn off colour text","Choose", "Cancel");
- }
- return 1;
- }
- CMD:givecolourtext(playerid,params[])
- {
- new id,idname[MAX_PLAYER_NAME],string[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]{FFFFFF}: You are not authorised to use this command");
- if(isnull(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: {FFFFFF}/givecolourtext (id)");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: Specified player not connected");
- if(pInfo[id][ColourText] == 1) return SendClientMessage(playerid,COLOR_ERROR, "[ERROR]{FFFFFF}: That player already have colourtext, How can you give it twice?");
- GetPlayerName(playerid, idname, sizeof(idname));
- format(string, sizeof(string), "You have given %s(%d) colour text.",idname,id);
- SendClientMessage(playerid, -1, string);
- SendClientMessage(id, -1, "An administrator has given you ColourText. You can now use /colourtext");
- pInfo[id][ColourText] = 1;
- return 1;
- }
- CMD:takecolourtext(playerid,params[])
- {
- new id,idname[MAX_PLAYER_NAME],string[128];
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]{FFFFFF}: You are not authorised to use this command");
- if(isnull(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: {FFFFFF}/takecolourtext (id)");
- if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: Specified player not connected");
- if(pInfo[id][ColourText] == 0) return SendClientMessage(playerid,COLOR_ERROR, "[ERROR]{FFFFFF}: That player doesnot have colourtext, How can you take it?");
- GetPlayerName(playerid, idname, sizeof(idname));
- format(string, sizeof(string), "You have taken %s(%d)'s' colour text.",idname,id);
- SendClientMessage(playerid, -1, string);
- SendClientMessage(id, -1, "An administrator has taken your ColourText. You cannot use /colourtext anymore");
- pInfo[id][ColourText] = 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement