Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.59 KB | None | 0 0
  1. // Created by Neal Anthony.
  2. #define FILTERSCRIPT
  3.  
  4. #include <a_samp>
  5. #include <a_npc>
  6.  
  7. new pAccent[MAX_PLAYERS][26];
  8.  
  9. #if defined FILTERSCRIPT
  10.  
  11. forward NearbyMessageForPlayers( playerid, stringcolour, text[]);
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print(" Accent System by Neal Anthony (Maramizo) Loaded ");
  16.     return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21.     print(" Accent System by Neal Anthony (Maramizo) Unloaded ");
  22.     return 1;
  23. }
  24.  
  25. stock strtok(const string[], &index,seperator=' ')
  26. {
  27.     new length = strlen(string);
  28.     new offset = index;
  29.     new result[128];
  30.     while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
  31.     {
  32.         result[index - offset] = string[index];
  33.         index++;
  34.     }
  35.  
  36.     result[index - offset] = EOS;
  37.     if ((index < length) && (string[index] == seperator))
  38.     {
  39.         index++;
  40.     }
  41.     return result;
  42. }
  43. public OnPlayerConnect(playerid)
  44. {
  45.     new string[] = " ";
  46.     strmid(pAccent[playerid],string,0,sizeof string ,255);
  47.     return 1;
  48. }
  49.  
  50. public OnPlayerDisconnect(playerid, reason)
  51. {
  52.     new string[] = " ";
  53.     strmid(pAccent[playerid],string,0,sizeof string ,255);
  54.     return 1;
  55. }
  56.  
  57. public OnPlayerText(playerid, text[])
  58. {
  59.     new name[MAX_PLAYER_NAME];
  60.     new string[128];
  61.     GetPlayerName(playerid,name,sizeof(name));
  62.     GetPVarString(playerid, "Accent", string, 128);
  63.     format(string, sizeof(string), "[%s accent] %s: %s", string, name, text);
  64.     NearbyMessageForPlayers(playerid, 0xFFFFFFAA, string);
  65.     return 0;
  66. }
  67.  
  68. public OnPlayerCommandText(playerid, cmdtext[])
  69. {
  70.     new cmd[256];
  71.     new tmp[256];
  72.     new string[128];
  73.     new idx;
  74.     cmd = strtok(cmdtext, idx);
  75.     if(!strcmp(cmd,"/accent", true))
  76.     {
  77.         if(IsPlayerConnected(playerid))
  78.         {
  79.            
  80.             tmp = strtok(cmdtext, idx);
  81.             format(string,sizeof(string),"Accent: You have changed your accent to %s.",tmp);
  82.             SetPVarString(playerid,"Accent",tmp);
  83.             SendClientMessage(playerid,0xFFFFFFAA,string);
  84.             strmid(pAccent[playerid],tmp,0,sizeof(tmp),255);
  85.         }
  86.         return 0;
  87.     }
  88.     return 0;
  89. }
  90.  
  91. public NearbyMessageForPlayers(playerid, stringcolour, text[]) // Credits to whoever made this, it saves me alot of time.
  92. {
  93.     new Float:PosX, Float:PosY, Float:PosZ;
  94.     for(new p = 0; p < MAX_PLAYERS; p++)
  95.     {
  96.         if(IsPlayerConnected( p ))
  97.         {
  98.             GetPlayerPos( playerid, PosX, PosY, PosZ );
  99.             if(IsPlayerInRangeOfPoint(p, 12, PosX, PosY, PosZ) )
  100.             {
  101.                 if(GetPlayerInterior( playerid ) == GetPlayerInterior( p ) && GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( p ) )
  102.                 {
  103.                     SendClientMessage(p, stringcolour, text);
  104.                 }
  105.             }
  106.         }
  107.     }
  108.     return 1;
  109. }
  110. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement