Help me with this!!! - 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: Help me with this!!! (
/showthread.php?tid=255814)
Help me with this!!! -
Cjgogo - 17.05.2011
LOOOOOOL!!!I went to server and tested my arrest command for key and the only thing I managed to do is arresting myself,AND I CANNOT SPOT THE ERROR:
pawn Код:
if(newkeys == KEY_LOOK_BEHIND)
{
if(gTeam[playerid] == TEAM_COPS)
{
new p1;
new p2;
GetDistanceBetweenPlayers(p1,p2);
if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_WHITE,"Nobody is close enough");
if(GetDistanceBetweenPlayers(p1,p2) < 5)
{
GetPlayerWantedLevel(p2);
if(GetPlayerWantedLevel(p2) < 1) return SendClientMessage(p1,COLOR_WHITE,"The player is not wanted");
if(GetPlayerWantedLevel(p2) > 0)
{
TogglePlayerControllable(p2,0);
new copname[24];
new wantedname[24];
GetPlayerName(p1,copname,sizeof(copname));
GetPlayerName(p2,wantedname,sizeof(wantedname));
new string[128];
format(string,sizeof(string),"Officer %s has arrested %s",copname,wantedname);
SendClientMessageToAll(COLOR_GREEN,string);
GivePlayerMoney(p1,1000);
}
}
}
if(gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_MEDICS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for a cop");
}
So do you see the error?
Re: Help me with this!!! -
Sasino97 - 17.05.2011
Quote:
Originally Posted by Cjgogo
LOOOOOOL!!!I went to server and tested my arrest command for key and the only thing I managed to do is arresting myself,AND I CANNOT SPOT THE ERROR:
pawn Код:
if(newkeys == KEY_LOOK_BEHIND) { if(gTeam[playerid] == TEAM_COPS) { new p1; new p2; GetDistanceBetweenPlayers(p1,p2); if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_WHITE,"Nobody is close enough"); if(GetDistanceBetweenPlayers(p1,p2) < 5) { GetPlayerWantedLevel(p2); if(GetPlayerWantedLevel(p2) < 1) return SendClientMessage(p1,COLOR_WHITE,"The player is not wanted"); if(GetPlayerWantedLevel(p2) > 0) { TogglePlayerControllable(p2,0); new copname[24]; new wantedname[24]; GetPlayerName(p1,copname,sizeof(copname)); GetPlayerName(p2,wantedname,sizeof(wantedname)); new string[128]; format(string,sizeof(string),"Officer %s has arrested %s",copname,wantedname); SendClientMessageToAll(COLOR_GREEN,string); GivePlayerMoney(p1,1000); } } } if(gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_MEDICS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for a cop"); }
So do you see the error?
|
Yes, I see it, and it's a
HUGE error...
new p1;
and
new p2;
declare new variables equal to 0 ...... So if you entered the server with ID 0 you arrest yourself...
pawn Код:
new p1 = playerid;
for(new i=0;i<MAX_PLAYERS;i++)
{
if( .... YOur distance check .... < 5)
{
new p2 = i;
//all your code ... here
}
}