28.02.2009, 16:21
Hi
I have this piece of code:
GetClosestPlayer always seems to return 0 (when I tested I was playerid 0), even when I stand right next to another person.
Does anyone have a working GetClosestPlayer?
I copied my GetClosestPlayer function and the other functions it calls from the uf.inc into a new inc, because I can't include the whole uf.inc without getting a bunch of errors.
I have this piece of code:
pawn Код:
dcmd_rob(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][pTeam] == TEAM_COP) return SendClientMessage(playerid, COLOR_RED, "** Police officers cannot rob other people!");
new otherplayer = GetClosestPlayer(playerid);
if(otherplayer == playerid) return SendClientMessage(playerid, COLOR_RED, "** No one close enough to rob!");
SetPlayerCriminal(playerid, 2);
new attempt = random(2);
if(attempt == 1)
{
// If success, give money etc.
}
else
{
format(string, sizeof(string), "You attempted to rob some money from %s, but failed!", PlayerName(otherplayer));
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}
Does anyone have a working GetClosestPlayer?
I copied my GetClosestPlayer function and the other functions it calls from the uf.inc into a new inc, because I can't include the whole uf.inc without getting a bunch of errors.