Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <sINI>
- public OnGameModeInit()
- {
- file_OS();
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(GetPVarInt(playerid,"primeiro_spawn") == 0)
- {
- new ficheiroc[40];
- format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(playerid));
- if(!fexist(ficheiroc))
- {
- file_Create(ficheiroc);
- file_Open(ficheiroc);
- file_SetVal(GetPlayerNameEx(playerid),1);
- file_Save(ficheiroc);
- file_Close();
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerNPC(playerid) && !IsPlayerNPC(i) && IsPlayerConnected(i))
- {
- format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(playerid));
- file_Open(ficheiroc);
- if(file_IsKey(GetPlayerNameEx(i)))
- {
- SetPVarInt(playerid,GetPlayerNameEx(i),file_GetVal(GetPlayerNameEx(i)));
- if(GetPVarInt(playerid,GetPlayerNameEx(i)) == 1)
- {
- ShowPlayerNameTagForPlayer(i, playerid, true);
- }
- else if(GetPVarInt(playerid,GetPlayerNameEx(i)) == 0)
- {
- ShowPlayerNameTagForPlayer(i, playerid, false);
- }
- }
- else
- {
- file_SetVal(GetPlayerNameEx(i),0);
- file_Save(ficheiroc);
- }
- file_Close();
- format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(i));
- file_Open(ficheiroc);
- if(file_IsKey(GetPlayerNameEx(playerid)))
- {
- SetPVarInt(i,GetPlayerNameEx(playerid),file_GetVal(GetPlayerNameEx(playerid)));
- if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 1)
- {
- ShowPlayerNameTagForPlayer(playerid, i, true);
- }
- else if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 0)
- {
- ShowPlayerNameTagForPlayer(playerid, i, false);
- }
- }
- else
- {
- file_SetVal(GetPlayerNameEx(playerid),0);
- file_Save(ficheiroc);
- }
- file_Close();
- }
- }
- SetPVarInt(playerid,"primeiro_spawn",1);
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(strfind(text, GetPlayerNameEx(playerid), true) == 0)
- {
- new ficheiroc[40];
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(i));
- file_Open(ficheiroc);
- if(i != playerid && IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- if(ProxDetectorS(5.0, playerid, i))
- {
- if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 0)
- {
- file_SetVal(GetPlayerNameEx(playerid),1);
- SetPVarInt(playerid,GetPlayerNameEx(playerid),1);
- ShowPlayerNameTagForPlayer(i, playerid, true);
- }
- }
- }
- file_Save(ficheiroc);
- file_Close();
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid,"primeiro_spawn",0);
- return 1;
- }
- public OnPlayerRequestClass(playerid)
- {
- if(GetPVarInt(playerid,"primeiro_spawn") == 0)
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(i != playerid && IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- SetPVarInt(playerid,GetPlayerNameEx(i),0);
- SetPVarInt(i,GetPlayerNameEx(playerid),0);
- ShowPlayerNameTagForPlayer(i, playerid, false);
- ShowPlayerNameTagForPlayer(playerid, i, false);
- }
- }
- }
- return 1;
- }
- stock GetPlayerNameEx(playerid)
- {
- new NomePlayer[MAX_PLAYER_NAME];
- GetPlayerName(playerid,NomePlayer,sizeof(NomePlayer));
- return NomePlayer;
- }
- forward ProxDetectorS(Float:radi, playerid, targetid);
- public ProxDetectorS(Float:radi, playerid, targetid)
- {
- if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- //radi = 2.0; //Trigger Radius
- GetPlayerPos(targetid, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
- if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- return 1;
- }
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment