/ar command error:
#1

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?
Reply
#2

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
Reply
#3

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 -
pawn Код:
return true;
Reply
#4

Bump.
Reply
#5

Replace "return true" with "return 1;"!

Then, show me the whole code again with the errors commented!
Reply
#6

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.
Reply
#7

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"
Reply
#8

you have id global defined
put #undef ID for your cmd
Reply
#9

pawn Код:
CMD:ar(playerid,params[])
{
      #undef ID
      //rest of your code
}
Reply
#10

Same
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)