Advertisement
Guest User

Colour text v1.0[FS]

a guest
Dec 9th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.63 KB | None | 0 0
  1. #include                    <a_samp>
  2. #include                    <YSI\y_ini>
  3. #include                    <zcmd>
  4.  
  5.  
  6.  
  7. #define COLOR_ERROR         0xFFFF0000
  8. #define DIALOG_COLOUR_TEXT  233
  9. //isnull
  10. #if !defined isnull
  11.    #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  12. #endif
  13.  
  14. new textcolour[MAX_PLAYERS];
  15.  
  16. public OnFilterScriptInit()
  17. {
  18.     print("\n--------------------------------------");
  19.     print(" ColourText by Turbo Loaded");
  20.     print("--------------------------------------\n");
  21.     return 1;
  22. }
  23.  
  24. public OnFilterScriptExit()
  25. {
  26.     return 1;
  27. }
  28. enum PlayerInfo
  29. {
  30.     ColourText
  31. }
  32. new pInfo[MAX_PLAYERS][PlayerInfo];
  33. stock Path(playerid)
  34. {
  35.     new string[128],name[MAX_PLAYER_NAME];
  36.     GetPlayerName(playerid,name,sizeof(name));
  37.     format(string,sizeof(string),"Users/Coloured Text/%s.ini",name);
  38.     return string;
  39. }
  40. forward loadaccount_user(playerid, name[], value[]);
  41. public loadaccount_user(playerid, name[], value[])
  42. {
  43.     INI_Int("ColourText",pInfo[playerid][ColourText]);
  44.     return 1;
  45. }
  46. public OnPlayerConnect(playerid)
  47. {
  48.     textcolour[playerid] = 0;
  49.     new name[MAX_PLAYER_NAME];
  50.     GetPlayerName(playerid,name,sizeof(name));
  51.     if(fexist(Path(playerid)))
  52.     {
  53.         INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
  54.     }
  55.     else
  56.     {
  57.             new INI:file = INI_Open(Path(playerid));
  58.             INI_SetTag(file,"Data");
  59.             INI_WriteInt(file,"ColourText",0);
  60.             INI_Close(file);
  61.     }
  62.     return 1;
  63.  }
  64. public OnPlayerDisconnect(playerid, reason)
  65. {
  66.         new INI:file = INI_Open(Path(playerid));
  67.         INI_SetTag(file,"Data");
  68.         INI_WriteInt(file,"ColourText",pInfo[playerid][ColourText]);
  69.         INI_Close(file);
  70.         textcolour[playerid] = 0;
  71.         return 1;
  72. }
  73. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  74. {
  75.     if(dialogid == DIALOG_COLOUR_TEXT)
  76.     {
  77.         if(response)
  78.         {
  79.             switch(listitem)
  80.             {
  81.                 case 0: textcolour[playerid] = 1;
  82.                 case 1: textcolour[playerid] = 2;
  83.                 case 2: textcolour[playerid] = 3;
  84.                 case 3: textcolour[playerid] = 4;
  85.                 case 4: textcolour[playerid] = 5;
  86.                 case 5: textcolour[playerid] = 6;
  87.                 case 6: textcolour[playerid] = 7;
  88.                 case 7: textcolour[playerid] = 0;
  89.             }
  90.         }
  91.         return 1;
  92.     }
  93.     return 0;
  94. }
  95. public OnPlayerText(playerid, text[])
  96. {
  97.     new str[128];
  98.     if(textcolour[playerid] == 1)
  99.     {
  100.         format(str, sizeof(str), "{0000FF}%s",text[0]);
  101.         SendPlayerMessageToAll(playerid, str);
  102.         return 0;
  103.     }
  104.     if(textcolour[playerid] == 2)
  105.     {
  106.         format(str, sizeof(str), "{FFFF00}%s",text[0]);
  107.         SendPlayerMessageToAll(playerid, str);
  108.         return 0;
  109.     }
  110.     if(textcolour[playerid] == 3)
  111.     {
  112.         format(str, sizeof(str), "{FF0000}%s",text[0]);
  113.         SendPlayerMessageToAll(playerid, str);
  114.         return 0;
  115.     }
  116.     if(textcolour[playerid] == 4)
  117.     {
  118.         format(str, sizeof(str), "{000000}%s",text[0]);
  119.         SendPlayerMessageToAll(playerid, str);
  120.         return 0;
  121.     }
  122.     if(textcolour[playerid] == 5)
  123.     {
  124.         format(str, sizeof(str), "{00FF00}%s",text[0]);
  125.         SendPlayerMessageToAll(playerid, str);
  126.         return 0;
  127.     }
  128.     if(textcolour[playerid] == 6)
  129.     {
  130.         format(str, sizeof(str), "{00FFFF}%s",text[0]);
  131.         SendPlayerMessageToAll(playerid, str);
  132.         return 0;
  133.     }
  134.     if(textcolour[playerid] == 7)
  135.     {
  136.         format(str, sizeof(str), "{FF8000}%s",text[0]);
  137.         SendPlayerMessageToAll(playerid, str);
  138.         return 0;
  139.     }
  140.     return 1;
  141. }
  142. CMD:colourtext(playerid,params[])
  143. {
  144.     if(pInfo[playerid][ColourText] == 0)
  145.     {
  146.         SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: You are not authorised to use Colour Text!");
  147.         return 1;
  148.     }
  149.     if(pInfo[playerid][ColourText] == 1)
  150.     {
  151.         ShowPlayerDialog(playerid,DIALOG_COLOUR_TEXT,DIALOG_STYLE_LIST,"Colour Text", "Blue\nYellow\nRed\nBlack\nGreen\nLight Blue\nOrange\nTurn off colour text","Choose", "Cancel");
  152.     }
  153.     return 1;
  154. }
  155. CMD:givecolourtext(playerid,params[])
  156. {
  157.     new id,idname[MAX_PLAYER_NAME],string[128];
  158.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]{FFFFFF}: You are not authorised to use this command");
  159.     if(isnull(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: {FFFFFF}/givecolourtext (id)");
  160.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: Specified player not connected");
  161.     if(pInfo[id][ColourText] == 1) return SendClientMessage(playerid,COLOR_ERROR, "[ERROR]{FFFFFF}: That player already have colourtext, How can you give it twice?");
  162.     GetPlayerName(playerid, idname, sizeof(idname));
  163.     format(string, sizeof(string), "You have given %s(%d) colour text.",idname,id);
  164.     SendClientMessage(playerid, -1, string);
  165.     SendClientMessage(id, -1, "An administrator has given you ColourText. You can now use /colourtext");
  166.     pInfo[id][ColourText] = 1;
  167.     return 1;
  168. }
  169. CMD:takecolourtext(playerid,params[])
  170. {
  171.     new id,idname[MAX_PLAYER_NAME],string[128];
  172.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR]{FFFFFF}: You are not authorised to use this command");
  173.     if(isnull(params)) return SendClientMessage(playerid,COLOR_ERROR,"Usage: {FFFFFF}/takecolourtext (id)");
  174.     if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]{FFFFFF}: Specified player not connected");
  175.     if(pInfo[id][ColourText] == 0) return SendClientMessage(playerid,COLOR_ERROR, "[ERROR]{FFFFFF}: That player doesnot have colourtext, How can you take it?");
  176.     GetPlayerName(playerid, idname, sizeof(idname));
  177.     format(string, sizeof(string), "You have taken %s(%d)'s' colour text.",idname,id);
  178.     SendClientMessage(playerid, -1, string);
  179.     SendClientMessage(id, -1, "An administrator has taken your ColourText. You cannot use /colourtext anymore");
  180.     pInfo[id][ColourText] = 0;
  181.     return 1;
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement