Guest User

Untitled

a guest
Feb 21st, 2011
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.15 KB | None | 0 0
  1. // Created by Neal Anthony.
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <a_npc>
  6. #include <zcmd>
  7. #include <sscanf2>
  8.  
  9. #define COLOR_GREY 0xAFAFAFAA
  10. #define COLOR_GREEN 0x33AA33AA
  11. #define COLOR_RED 0xAA3333AA
  12. #define COLOR_YELLOW 0xFFFF00AA
  13.  
  14.  
  15. new pAccent[MAX_PLAYERS][26];
  16.  
  17. #if defined FILTERSCRIPT
  18.  
  19. forward NearbyMessageForPlayers( playerid, stringcolour, text[]);
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print(" Accent System by Neal Anthony (Maramizo) Loaded ");
  24.     return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.     print(" Accent System by Neal Anthony (Maramizo) Unloaded ");
  30.     return 1;
  31. }
  32.  
  33. stock strtok(const string[], &index,seperator=' ')
  34. {
  35.     new length = strlen(string);
  36.     new offset = index;
  37.     new result[128];
  38.     while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
  39.     {
  40.         result[index - offset] = string[index];
  41.         index++;
  42.     }
  43.  
  44.     result[index - offset] = EOS;
  45.     if ((index < length) && (string[index] == seperator))
  46.     {
  47.         index++;
  48.     }
  49.     return result;
  50. }
  51. public OnPlayerConnect(playerid)
  52. {
  53.     SetPVarString(playerid,"Accent","Unknown"); // Sets the accent to 'unknown' untill the player chooses his players accent
  54.     SendClientMessage(playerid, 0xFFFFFFAA, "Type /accent to set your players accent"); // Idea by PlayBox... Thank you!
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerDisconnect(playerid, reason)
  59. {
  60.     new string[] = " ";
  61.     strmid(pAccent[playerid],string,0,sizeof string ,255);
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerText(playerid, text[])
  66. {
  67.     new name[MAX_PLAYER_NAME];
  68.     new string[128];
  69.     GetPlayerName(playerid,name,sizeof(name));
  70.     GetPVarString(playerid, "Accent", string, 128);
  71.     format(string, sizeof(string), "[%s accent] %s: %s", string, name, text);
  72.     NearbyMessageForPlayers(playerid, 0xFFFFFFAA, string);
  73.     return 0;
  74. }
  75.  
  76. public OnPlayerCommandText(playerid, cmdtext[])
  77. {
  78.     return 0;
  79. }
  80. CMD:accent(playerid, params[])
  81. {
  82.     new string[128];
  83.     new giveaccent;
  84.     if(!sscanf(params,"s[128]",giveaccent))
  85.     {
  86.         if (giveaccent < 9 || giveaccent > 20)
  87.         {
  88.             new string2[128];
  89.             format(string2,sizeof(string2),"Accent: You have changed your accent to %s.",string);
  90.             SetPVarString(playerid,"Accent",string);
  91.             SendClientMessage(playerid,0xFFFFFFAA,string);
  92.             strmid(pAccent[playerid],string,0,sizeof(string),255);
  93.             return 1;
  94.         }
  95.         else
  96.         {
  97.             SendClientMessage(playerid, COLOR_RED, "Accent must be between 9 and 20 Characters.");
  98.             return 1;
  99.         }
  100.     }
  101.     else
  102.     {
  103.     SendClientMessage (playerid, COLOR_RED, "USAGE:/accent [Accent Here]");
  104.     return 1;
  105.     }
  106. }
  107.  
  108. public NearbyMessageForPlayers(playerid, stringcolour, text[]) // Credits to whoever made this, it saves me alot of time.
  109. {
  110.     new Float:PosX, Float:PosY, Float:PosZ;
  111.     for(new p = 0; p < MAX_PLAYERS; p++)
  112.     {
  113.         if(IsPlayerConnected( p ))
  114.         {
  115.             GetPlayerPos( playerid, PosX, PosY, PosZ );
  116.             if(IsPlayerInRangeOfPoint(p, 12, PosX, PosY, PosZ) )
  117.             {
  118.                 if(GetPlayerInterior( playerid ) == GetPlayerInterior( p ) && GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( p ) )
  119.                 {
  120.                     SendClientMessage(p, stringcolour, text);
  121.                 }
  122.             }
  123.         }
  124.     }
  125.     return 1;
  126. }
  127. #endif
Advertisement
Add Comment
Please, Sign In to add comment