Fiz de outra forma:
pawn Код:
if(strcmp(cmd,"/checarcinto",true)==0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_GRAD1,"USO: /checarcinto [playerid/Parte-do-Nick]");
giveplayerid = ReturnUser(tmp);
if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14)
{
if(ProxDetectorS(10.0,playerid,giveplayerid))
{
new policial[MAX_PLAYER_NAME];
new motorista[MAX_PLAYER_NAME];
GetPlayerName(playerid,policial,sizeof(policial));
GetPlayerName(giveplayerid,motorista,sizeof(motorista));
if(GetPlayerState(giveplayerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_GRAD1," O jogador nгo estб dirigindo nenhum veiculo !");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GRAD1, " ID INVБLIDO");
new str[75];
format(str,sizeof(str), "%s checou se %s estб usando o cinto de seguranзa.", policial,motorista);
ProxDetector(15.0,playerid,str,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
if(CintoPlayer[giveplayerid] == 0)
{
SendClientMessage(playerid,LARANJA1," O jogador NГO estб usando o cinto de seguranзa.");
return 1;
}
else return SendClientMessage(playerid,LARANJA1," O jogador estб usando o cinto de seguranзa.");
}
else
{
SendClientMessage(playerid,COLOR_GRAD1," O jogador estб longe de vocк.");
}
}
else return SendClientMessage(playerid, COLOR_GREY, " Vocк nгo й um Policial Rodoviбrio");
}
}
Funзгo ProxDetector:
pawn Код:
//NO TOPO DO GAMEMODE, PONHA ISTO
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
//NO FINAL DO GM, PONHA ISTO
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
if(IsPlayerConnected(playerid))
{
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);
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);
if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
{
SendClientMessage(i, col1, string);
}
else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
{
SendClientMessage(i, col2, string);
}
else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
{
SendClientMessage(i, col3, string);
}
else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
{
SendClientMessage(i, col4, string);
}
else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
SendClientMessage(i, col5, string);
}
else
{
SendClientMessage(i, col1, string);
}
}
}
}
return 1;
}
Explicando:
- O "Float:radi" й o raio de alcance da mensgem, entгo se vocк colocar 10, todos que estiverem a 10 m (metro й uma suposiзгo, pois o GTA SA:MP nгo usa o sistema mйtrico, isto serve sу como exemplo) receberгo a mensagem.
- O "playerid" й para quem a mensagem serб enviada, caso queria que ela seja para todos que estiverem no raio deixe como "playerid" mesmo.
- O "string" й a mensagem a ser enviada.
- Quanto aos "col1,col2 ..." sгo as cores que a mensagem terб. "col1" = cor da mensagem que serб enviada ao player mais proximo; "col5" = cor da mensagem que serб enviada ao player mais distante; o resto vocкs jб podem perceber como funciona
Funзгo ProxDetectorS:
pawn Код:
//NO TOPO DO GAMEMODE, PONHA ISTO:
forward ProxDetectorS(Float:radi, playerid, targetid);
//NO FINAL DO GM, PONHA ISTO:
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);
GetPlayerPos(targetid, posx, posy, posz);
tempposx = (oldposx -posx);
tempposy = (oldposy -posy);
tempposz = (oldposz -posz);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
Explicando:
- O "Float:radi" jб estб explicado acima.
- "playerid" e "targetid" deve ser substituнdo pelos jogadores que vocк quer comparar a distancia (Float:radi).
Postei isto aqui para ajudar outros scripter, principalmente os novatos, visto que, tambйm estou eu fase de aprendizado e disposto a ajudar qualquer pessoa.
OBS: Caso esteja algo errado, peзo que digam para eu corrigir.
Obrigado pela ajuda, pessoal.