Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.92 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.     SetPVarString(playerid,"Accent","Unknown"); // Sets the accent to 'unknown' untill the player chooses his players accent
  46.     SendClientMessage(playerid, 0xFFFFFFAA, "Type /accent to set your players accent"); // Idea by PlayBox... Thank you!
  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[]) // By Krx17, thank you!
  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.                 tmp = strtok(cmdtext, idx);
  80.                 if(strlen(tmp) < 5 || strlen(tmp) > 26)
  81.                     return SendClientMessage(playerid, 0xFFFF00AA, "Syntax: /accent [accent]");
  82.                 format(string,sizeof(string),"Accent: You have changed your accent to %s.",tmp);
  83.                 SetPVarString(playerid,"Accent",tmp);
  84.                 SendClientMessage(playerid,0xFFFFFFAA,string);
  85.                 strmid(pAccent[playerid],tmp,0,sizeof(tmp),255);
  86.             }
  87.             return 0;
  88.         }
  89.     return 1;
  90. }
  91.  
  92. public NearbyMessageForPlayers(playerid, stringcolour, text[]) // Credits to whoever made this, it saves me alot of time.
  93. {
  94.     new Float:PosX, Float:PosY, Float:PosZ;
  95.     for(new p = 0; p < MAX_PLAYERS; p++)
  96.     {
  97.         if(IsPlayerConnected( p ))
  98.         {
  99.             GetPlayerPos( playerid, PosX, PosY, PosZ );
  100.             if(IsPlayerInRangeOfPoint(p, 12, PosX, PosY, PosZ) )
  101.             {
  102.                 if(GetPlayerInterior( playerid ) == GetPlayerInterior( p ) && GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( p ) )
  103.                 {
  104.                     SendClientMessage(p, stringcolour, text);
  105.                 }
  106.             }
  107.         }
  108.     }
  109.     return 1;
  110. }
  111. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement