Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #define ISeeThisGuy(%0,%1) MyFriends[%0][showing][%1]
- enum friendsinfo
- {
- bool:iknow[MAX_PLAYERS],
- bool:showing[MAX_PLAYERS]
- }
- new MyFriends[MAX_PLAYERS][friendsinfo];
- /*Comentarios
- Na OnPlayerLogin:
- LoadMyFriendsInGame(playerid);
- Na pInfo (PlayerInfo
- FriendRequest,
- No /sms
- if(IsMyFriend(playerid, giveplayerid)) format(string, sizeof(string), "SMS: %s, de: %s (%d)", result,sendername,PlayerInfo[playerid][pPnumber]);
- else format(string, sizeof(string), "SMS: %s, de: Desconhecido (%d)", result,PlayerInfo[playerid][pPnumber]);
- no /aceitar (comando /recusar abaixo)
- else if(strcmp(x_job,"amizade",true) == 0)
- {
- new str[128];
- if(!IsPlayerConnected(PlayerInfo[playerid][FriendRequest])) return SendClientMessage(playerid, COLOR_YELLOW, "{FF4040}[ERRO]{FFFFFF} Você não tem um pedido de amizade válido.");
- MyNewFriend(playerid, PlayerInfo[playerid][FriendRequest]);
- MyNewFriend(PlayerInfo[playerid][FriendRequest], playerid);
- GetPlayerName(PlayerInfo[playerid][FriendRequest], str, MAX_PLAYER_NAME);
- format(str, sizeof str, "[AMIZADE] Você aceitou %s como seu amigo.", str);
- SendClientMessage(playerid, COLOR_YELLOW, str);
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- format(str, sizeof str, "[AMIZADE] %s te aceitou como amigo.", str);
- SendClientMessage(PlayerInfo[playerid][FriendRequest], COLOR_YELLOW, str);
- PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
- return 1;
- }
- No OnPlayerText, na parte de ligações
- if(IsMyFriend(playerid, Mobile[playerid]))
- {
- format(string, sizeof(string), "%s fala (ao celular): %s", sendername, text);
- ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
- }
- else
- {
- ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
- format(string, sizeof(string), "Desconhecido fala (ao celular): %s", sendername, text);
- }
- */
- //esse é o para aparecer Desconhecido no ProxDectector
- public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new str[256], pos, Float:posx, Float:posy, Float:posz, Float:oldposx,
- Float:oldposy, Float:oldposz, Float:tempposx, Float:tempposy,
- Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- pos = strfind(string, GetNick(playerid));
- strcat(str, string, 256);
- if(pos != -1)
- {
- strdel(str, pos, pos + strlen(GetNick(playerid)));
- strins(str, "Desconhecido", pos, 256);
- }
- else
- {
- pos = strfind(string, NomeEx(playerid));
- if(pos != -1)
- {
- strdel(str, pos, pos + strlen(NomeEx(playerid)));
- strins(str, "Desconhecido", pos, 256);
- }
- }
- //radi = 2.0; //Trigger Radius
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerPos(i, 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/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col1, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col1, str);
- else SendClientMessage(i, col1, string);
- }
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col2, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col2, str);
- else SendClientMessage(i, col2, string);
- }
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col3, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col3, str);
- else SendClientMessage(i, col3, string);
- }
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col4, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col4, str);
- else SendClientMessage(i, col4, string);
- }
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col5, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col5, str);
- else SendClientMessage(i, col5, string);
- }
- }
- }
- else
- {
- if(IsMyFriend(playerid, i)) SendClientMessage(i, col1, string);
- else
- {
- if(i != playerid) SendClientMessage(i, col1, str);
- else SendClientMessage(i, col1, string);
- }
- }
- }
- }//not connected
- return 1;
- }
- IsMyFriend(playerid, thisguy)
- {
- if(MyFriends[playerid][iknow][thisguy])
- {
- MyFriends[playerid][showing][thisguy] = true;
- return true;
- }
- MyFriends[playerid][showing][thisguy] = false;
- return false;
- }
- LoadMyFriendsInGame(playerid)
- {
- new str[64];
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- format(str, sizeof str, "FriendsOf/%s.ini", str);
- if(dini_Exists(str))
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
- format(str, sizeof str, "FriendsOf/%s.ini", GetNick(playerid));
- if(dini_Isset(str, GetNick(i)))
- {
- MyFriends[playerid][iknow][i] = true;
- MyFriends[playerid][showing][i] = true;
- MyFriends[i][iknow][playerid] = true;
- MyFriends[i][showing][playerid] = true;
- ShowPlayerNameTagForPlayer(playerid, i, true);
- ShowPlayerNameTagForPlayer(i, playerid, true);
- }
- }
- }
- return 1;
- }
- MyNewFriend(playerid, otherplayer)
- {
- if(!IsPlayerConnected(otherplayer) || !IsPlayerConnected(playerid)) return 1;
- new str[64];
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- format(str, sizeof str, "FriendsOf/%s.ini", str);
- if(dini_Exists(str)) dini_IntSet(str, GetNick(otherplayer), 1);
- else
- {
- dini_Create(str);
- dini_IntSet(str, GetNick(otherplayer), 1);
- return 1;
- }
- MyFriends[playerid][iknow][otherplayer] = true;
- MyFriends[playerid][showing][otherplayer] = true;
- MyFriends[otherplayer][iknow][playerid] = true;
- MyFriends[otherplayer][showing][playerid] = true;
- ShowPlayerNameTagForPlayer(playerid, otherplayer, true);
- ShowPlayerNameTagForPlayer(otherplayer, playerid, true);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- MyFriends[i][iknow][playerid] = false;
- MyFriends[i][showing][playerid] = false;
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp("/solicitaramizade", cmd, true))
- {
- new str[128];
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "{00ca3e}USE:{FFFFFF} /solicitaramizade [playerid/parte do nome]");
- new newfriend = ReturnUser(tmp);
- if(!IsPlayerConnected(newfriend)) return SendClientMessage(playerid, COLOR_GREY, "{FF4040}[ERRO]{FFFFFF} O jogador está desconectado.");
- if(IsMyFriend(playerid, newfriend)) return SendClientMessage(playerid, COLOR_GREY, "{FF4040}[ERRO]{FFFFFF} O jogador já é seu amigo.");
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- PlayerInfo[newfriend][FriendRequest] = playerid;
- format(str, sizeof str, "[AMIZADE] %s quer ser seu amigo, para aceitar o pedido use /Aceitar [Amizade].", str);
- SendClientMessage(newfriend, COLOR_YELLOW, str);
- SendClientMessage(newfriend, COLOR_YELLOW, "[AMIZADE] Para recusar o convite use /Recusar [Amizade].");
- GetPlayerName(newfriend, str, MAX_PLAYER_NAME);
- format(str, sizeof str, "[AMIZADE] Você enviou um pedido de amizade para %s.", str);
- SendClientMessage(playerid, COLOR_YELLOW, str);
- return 1;
- }
- if(strcmp(cmd,"/recusar",true)==0)
- {
- new item[256];
- item = strtok(cmdtext, idx);
- if(!strlen(item))
- {
- SendClientMessage(playerid, COLOR_BRANCO, "|__________________ Recusar __________________|");
- SendClientMessage(playerid, COLOR_BRANCO, "{00ca3e}USE:{FFFFFF} /recusar [nome]");
- SendClientMessage(playerid, COLOR_GREY, "Nomes disponiveis: amizade");
- SendClientMessage(playerid, COLOR_BRANCO, "|____________________________________________|");
- return 1;
- }
- else if(strcmp(item,"amizade",true) == 0)
- {
- new str[128];
- if(!IsPlayerConnected(PlayerInfo[playerid][FriendRequest])) return SendClientMessage(playerid, COLOR_YELLOW, "{FF4040}[ERRO]{FFFFFF} O pedido expirou.");
- GetPlayerName(PlayerInfo[playerid][FriendRequest], str, MAX_PLAYER_NAME);
- format(str, sizeof str, "[AMIZADE] Você recusou o pedido de amizade de %s.", str);
- SendClientMessage(playerid, COLOR_YELLOW, str);
- GetPlayerName(playerid, str, MAX_PLAYER_NAME);
- format(str, sizeof str, "[AMIZADE] %s recusou seu pedido de amizade.", str);
- SendClientMessage(PlayerInfo[playerid][FriendRequest], COLOR_YELLOW, str);
- PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
- return 1;
- }
- return 1;
- }
- if(!strcmp("/nametags", cmd, true))
- {
- if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "{FF4040}[ERRO]{FFFFFF} Você não pode usar este comando.");
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) return SendClientMessage(playerid, -1, "{00ca3e}USE:{FFFFFF} /nametags [on] ou [off].");
- if(strfind(cmdtext, "/nametags on") == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, true);
- SendClientMessage(playerid, -1, "{00ca3e}[INFO]{FFFFFF} Agora você pode ver todos os nomes.");
- return 1;
- }
- else if (strfind(cmdtext, "/nametags off") == 0)
- {
- for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
- LoadMyFriendsInGame(playerid);
- SendClientMessage(playerid, -1, "{00ca3e}[INFO]{FFFFFF} Modo de ver todos os nomes desativado.");
- return 1;
- }
- return SendClientMessage(playerid, -1, "{00ca3e}USE:{FFFFFF} /nametags [on] ou [off].");
- }
- return 0;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- if(IsMyFriend(forplayerid, playerid))
- {
- ShowPlayerNameTagForPlayer(forplayerid, playerid, true);
- ShowPlayerNameTagForPlayer(playerid, forplayerid, true);
- return 1;
- }
- ShowPlayerNameTagForPlayer(forplayerid, playerid, false);
- ShowPlayerNameTagForPlayer(playerid, forplayerid, false);
- return 1;
- }
Add Comment
Please, Sign In to add comment