this always returns 1? :S - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: this always returns 1? :S (
/showthread.php?tid=110190)
this always returns 1? :S -
cdcyborg - 25.11.2009
i think the stock script returns 1 all the time, but:
format(string, sizeof(string), "Name Is: %d", i);
SendClientMessageToAll(COLOR_YELLOW,string);
shows the correct name/id.
and when i enable the sendclientmessage on this:
if (closestplayer(playerid) && cuffed[giveplayerid] == 0) {
format(string, sizeof(string), "/cuff %d", closestplayer(playerid));
playercommandtext(playerid, string);
SendClientMessageToAll(COLOR_YELLOW, string);
}
the Wrong id whows up on the SendClientMessage on this script :S
Код:
stock closestplayer(playerid) {
for(new i=0; i<MAX_PLAYERS; i++) {
if(GetDistanceBetweenPlayers(playerid, i) < 6 && i != playerid && IsPlayerConnected(i) && !IsPlayerNPC(i)) { //Distance of 5 in-game meters
//new oname[MAX_PLAYER_NAME];
new string[256];
//GetPlayerName(i, oname, sizeof(oname));
format(string, sizeof(string), "Name Is: %d", i);
SendClientMessageToAll(COLOR_YELLOW,string);
return format(string, sizeof(string), "%d", i);
}
}
return 0;
}
new giveplayerid = closestplayer(playerid);
if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_ARMY && GetDistanceBetweenPlayers(playerid, giveplayerid) < 7) {
if (closestplayer(playerid) == playerid) return 0;
if (closestplayer(playerid) && cuffed[giveplayerid] == 0) {
format(string, sizeof(string), "/cuff %d", closestplayer(playerid));
playercommandtext(playerid, string);
//SendClientMessageToAll(COLOR_YELLOW, string);
}
else if (closestplayer(playerid) && cuffed[giveplayerid] == 1 && GetPlayerWantedLevel(giveplayerid) >= 1 ) {
if (GetPlayerWantedLevel(giveplayerid) < 4) {
format(string, sizeof(string), "/fine %d", closestplayer(playerid));
playercommandtext(playerid, string);
//SendClientMessageToAll(COLOR_YELLOW, string);
}
else if (GetPlayerWantedLevel(giveplayerid) >= 4) {
format(string, sizeof(string), "/ar %d", closestplayer(playerid));
playercommandtext(playerid, string);
//SendClientMessageToAll(COLOR_YELLOW, string);
}
}
else if (GetPlayerWantedLevel(giveplayerid) < 1 && justsearched[giveplayerid] == 0 && cuffed[giveplayerid] == 1) {
format(string, sizeof(string), "/search %d", closestplayer(playerid));
playercommandtext(playerid, string);
//SendClientMessageToAll(COLOR_YELLOW, string);
justsearched[giveplayerid] = 1;
}
else {
format(string, sizeof(string), "/uc %d", closestplayer(playerid));
justsearched[giveplayerid] = 0;
playercommandtext(playerid, string);
//SendClientMessageToAll(COLOR_YELLOW, string);
}
}
Thanks in advance. cdcyborg.
Re: this always returns 1? :S -
woot - 25.11.2009
pawn Код:
stock closestplayer(playerid)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(GetDistanceBetweenPlayers(playerid, i) < 6 && i != playerid && !IsPlayerNPC(i))
{
new string[ 128 ];
format(string, sizeof(string), "Closest player ID: %d", i);
SendClientMessageToAll(COLOR_YELLOW,string);
return i;
}
}
}