Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Created by Neal Anthony.
- #define FILTERSCRIPT
- #include <a_samp>
- #include <a_npc>
- new pAccent[MAX_PLAYERS][26];
- #if defined FILTERSCRIPT
- forward NearbyMessageForPlayers( playerid, stringcolour, text[]);
- public OnFilterScriptInit()
- {
- print(" Accent System by Neal Anthony (Maramizo) Loaded ");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print(" Accent System by Neal Anthony (Maramizo) Unloaded ");
- return 1;
- }
- stock strtok(const string[], &index,seperator=' ')
- {
- new length = strlen(string);
- new offset = index;
- new result[128];
- while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- if ((index < length) && (string[index] == seperator))
- {
- index++;
- }
- return result;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarString(playerid,"Accent","Unknown"); // Sets the accent to 'unknown' untill the player chooses his players accent
- SendClientMessage(playerid, 0xFFFFFFAA, "Type /accent to set your players accent"); // Idea by PlayBox... Thank you!
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new string[] = " ";
- strmid(pAccent[playerid],string,0,sizeof string ,255);
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new name[MAX_PLAYER_NAME];
- new string[128];
- GetPlayerName(playerid,name,sizeof(name));
- GetPVarString(playerid, "Accent", string, 128);
- format(string, sizeof(string), "[%s accent] %s: %s", string, name, text);
- NearbyMessageForPlayers(playerid, 0xFFFFFFAA, string);
- return 0;
- }
- public OnPlayerCommandText(playerid, cmdtext[]) // By Krx17, thank you!
- {
- new cmd[256];
- new tmp[256];
- new string[128];
- new idx;
- cmd = strtok(cmdtext, idx);
- if(!strcmp(cmd,"/accent", true))
- {
- if(IsPlayerConnected(playerid))
- {
- tmp = strtok(cmdtext, idx);
- if(strlen(tmp) < 5 || strlen(tmp) > 26)
- return SendClientMessage(playerid, 0xFFFF00AA, "Syntax: /accent [accent]");
- format(string,sizeof(string),"Accent: You have changed your accent to %s.",tmp);
- SetPVarString(playerid,"Accent",tmp);
- SendClientMessage(playerid,0xFFFFFFAA,string);
- strmid(pAccent[playerid],tmp,0,sizeof(tmp),255);
- }
- return 0;
- }
- return 1;
- }
- public NearbyMessageForPlayers(playerid, stringcolour, text[]) // Credits to whoever made this, it saves me alot of time.
- {
- new Float:PosX, Float:PosY, Float:PosZ;
- for(new p = 0; p < MAX_PLAYERS; p++)
- {
- if(IsPlayerConnected( p ))
- {
- GetPlayerPos( playerid, PosX, PosY, PosZ );
- if(IsPlayerInRangeOfPoint(p, 12, PosX, PosY, PosZ) )
- {
- if(GetPlayerInterior( playerid ) == GetPlayerInterior( p ) && GetPlayerVirtualWorld( playerid ) == GetPlayerVirtualWorld( p ) )
- {
- SendClientMessage(p, stringcolour, text);
- }
- }
- }
- }
- return 1;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement