If in range of a cop - 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)
+--- Thread: If in range of a cop (
/showthread.php?tid=454341)
If in range of a cop -
wumpyc - 28.07.2013
Here's what i'm trying to do:
Код:
stock NearPolice(playerid)
{
foreach(new i : Player)
{
if(IsPlayerConnected(i)){
if(i != playerid){
if(PlayerInfo[i][pClass] == TEAM_POLICE){
new Float:datx,Float:daty,Float:datz;
GetPlayerPos(i,datx,daty,datz);
if(IsPlayerInRangeOfPoint(playerid,100.0,datx,daty,datz)) return _:1;
else return _:0;
}
}
}
}
return 1;
}
CMD:reclass(playerid,params[])
{
if(PlayerInfo[playerid][pSpawned] == 0) return SendClientMessage(playerid,COLOR_RED,"Only spawned players can use this command.");
if(/*PlayerInfo[playerid][pFines] > 0 && */NearPolice(playerid) == 1) return SendClientMessage(playerid,COLOR_RED,"You cannot use this command while you have fines near a cop.");
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid,true);
TogglePlayerSpectating(playerid,false);
return 1;
}
However it always says that I cannot use that command near a cop, even tho there is no cop online.
Re: If in range of a cop -
Darnell - 28.07.2013
Why return _:1 and return _:0? new scripting way?
Re: If in range of a cop -
Aliassassin123456 - 28.07.2013
pawn Код:
stock NearPolice(playerid)
{
foreach(new i : Player)
{
if(IsPlayerConnected(i)){
if(i != playerid){
if(PlayerInfo[i][pClass] == TEAM_POLICE){
new Float:datx,Float:daty,Float:datz;
GetPlayerPos(i,datx,daty,datz);
if(IsPlayerInRangeOfPoint(playerid,100.0,datx,daty,datz)) return 1;
}
}
}
}
return 0;
}
CMD:reclass(playerid,params[])
{
if(PlayerInfo[playerid][pSpawned] == 0) return SendClientMessage(playerid,COLOR_RED,"Only spawned players can use this command.");
if(/*PlayerInfo[playerid][pFines] > 0 && */NearPolice(playerid) == 1) return SendClientMessage(playerid,COLOR_RED,"You cannot use this command while you have fines near a cop.");
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid,true);
TogglePlayerSpectating(playerid,false);
return 1;
}
AW: If in range of a cop -
Harry :) - 28.07.2013
still wrong, remove the return 1/0 at the bottom at NearPolice, that either returns permanently true (is in range) on your idea or permanently false (is not in range) at that suggestion above me everytime NearPolice is called
Re: If in range of a cop -
wumpyc - 28.07.2013
Ops lol.. but that doesn't fix it.. going to test ali's fix now
Re: If in range of a cop -
wumpyc - 28.07.2013
Thanks ali. Works now
Re: If in range of a cop -
Aliassassin123456 - 28.07.2013
No problem man
Re: If in range of a cop -
Darnell - 28.07.2013
Assasin, it's wrong.
The indention is wrong.
Re: If in range of a cop -
wumpyc - 28.07.2013
Quote:
Originally Posted by Darnell
Assasin, it's wrong.
The indention is wrong.
|
I can fix that myself hehe