/ar command error: -
Face9000 - 14.02.2012
warning 213: tag mismatch
warning 209: function "cmd_ar" should return a value
error 010: invalid function or declaration
pawn Код:
CMD:ar(playerid,params[])
{
new id,n[MAX_PLAYER_NAME], on[MAX_PLAYER_NAME];
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_CIV)
{
SendClientMessage(playerid,red,"Only law enforcement can arrest wanted suspects.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
new string2[128];
format(string2,sizeof(string2),"%s(%d) is too far away. You cannot reach him to arrest him.",on,id);
SendClientMessage(playerid,red,string2);
return 1;
}
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,red,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(GetPlayerWantedLevel(ID) < 3)
{
new string4[128];
format(string4,sizeof(string4),"%s(%d)'s wanted level is too low. You cannot jail them. Use /ticket (Player ID).",n,playerid);
SendClientMessage(playerid,red,string4);
return 1;
}
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't arrest a suspect if you are in a vehicle.");
if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid Player ID.");
if(playerid == id) return SendClientMessage(playerid,red, "You cannot arrest yourself.");
if(sscanf(params,"uz",id)) return SendClientMessage(playerid,red,"Usage:/ar [ID]");
else
{
GetPlayerName(playerid,n,sizeof(n));
GetPlayerName(id,on,sizeof(on));
new string[100];
format(string,sizeof(string),"You've arrested %s(%d).",n,id);
SendClientMessage(playerid,blue,string);
new string2[128];
format(string2, sizeof(string), "%s has been arrested by %s",n,playerid,on,id);
SendClientMessageToAll(red,string2);
}
}
return true;
}
What's wrong?
Re: /ar command error: -
ArmyOps - 14.02.2012
For start show us errors and warning lines. it makes everything faster.
But noticed already one...
At the end before return true u have 1 extra bracket. U might wanna remove 1
Re: /ar command error: -
Face9000 - 14.02.2012
Ok,then:
Line 1541 -
pawn Код:
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
Line 1548 -
pawn Код:
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
Line 1553 -
pawn Код:
if(GetPlayerWantedLevel(ID) < 3)
Line 1576 -
Re: /ar command error: -
Face9000 - 15.02.2012
Bump.
Re: /ar command error: -
Twisted_Insane - 15.02.2012
Replace "return true" with "return 1;"!
Then, show me the whole code again
with the errors commented!
Re: /ar command error: -
Konstantinos - 15.02.2012
pawn Код:
#include < a_samp >
#include < zcmd >
#include < sscanf2 >
#define red -1
#define blue -1
#define TEAM_COP 1
#define TEAM_CIV 2
new gTeam[MAX_PLAYERS], IsSpawned[MAX_PLAYERS];
CMD:ar(playerid,params[])
{
new ID, id,n[MAX_PLAYER_NAME], on[MAX_PLAYER_NAME];
if(gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_CIV)
{
SendClientMessage(playerid,red,"Only law enforcement can arrest wanted suspects.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
new string2[128];
format(string2,sizeof(string2),"%s(%d) is too far away. You cannot reach him to arrest him.",on,id);
SendClientMessage(playerid,red,string2);
return 1;
}
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,red,"You cannot arrest a suspect they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(GetPlayerWantedLevel(ID) < 3)
{
new string4[128];
format(string4,sizeof(string4),"%s(%d)'s wanted level is too low. You cannot jail them. Use /ticket (Player ID).",n,playerid);
SendClientMessage(playerid,red,string4);
return 1;
}
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You can't arrest a suspect if you are in a vehicle.");
if(IsSpawned[playerid] == 0) return SendClientMessage(playerid,0xFF0000FF,"You can't use this command when you are dead or spawning.");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Invalid Player ID.");
if(playerid == id) return SendClientMessage(playerid,red, "You cannot arrest yourself.");
if(sscanf(params,"uz",id)) return SendClientMessage(playerid,red,"Usage:/ar [ID]");
else {
GetPlayerName(playerid,n,sizeof(n));
GetPlayerName(id,on,sizeof(on));
new string[100];
format(string,sizeof(string),"You've arrested %s(%d).",n,id);
SendClientMessage(playerid,blue,string);
new string2[128];
format(string2, sizeof(string), "%s has been arrested by %s",n,playerid,on,id);
SendClientMessageToAll(red,string2);
}
return true;
}
stock GetDistanceBetweenPlayers(playerid, playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
pawn Код:
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
However at the sscanf "z" was removed use S() instead.
Re: /ar command error: -
Face9000 - 15.02.2012
Thanks,but now i got :
pawn Код:
warning 219: local variable "ID" shadows a variable at a preceding level
warning 213: tag mismatch
warning 213: tag mismatch
warning 213: tag mismatch
warning 213: tag mismatch
warning 203: symbol is never used: "ID"
AW: /ar command error: -
Tigerkiller - 15.02.2012
you have id global defined
put #undef ID for your cmd
Re: /ar command error: -
Twisted_Insane - 15.02.2012
pawn Код:
CMD:ar(playerid,params[])
{
#undef ID
//rest of your code
}
Re: /ar command error: -
Face9000 - 15.02.2012
Same