Someone help me fix these returns?!
#1

pawn Код:
CMD:jail(playerid,params[])
{
    new id;
    if(sscanf(params, "u", id)) SendClientMessage(playerid,COLOR_RED,"Usage: /jail <ID>");
    else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid,COLOR_RED,"Error: Player Not Connected!");
    else
    {
        if(PlayerInfo[playerid][pAdminLevel] >=10) return SendClientMessage(playerid,COLOR_RED,"You cannot use this command!");
        {
            new string[128];
            format(string, sizeof(string), "%s has been sent to jail by an Admin",GetName(playerid));
            SendClientMessageToAll(COLOR_RED, string);
            RemovePlayerFromVehicle(id);
            PlayerInfo[id][pJailed] = 1;
            ResetPlayerWeapons(playerid);
            SetPlayerInterior(id, 6);
            SetPlayerPos(id, 265.000000,78.000000,1002.00000000);
            SetPlayerVirtualWorld(id, 5);
        }
        return 1;
    }
}
Warnings:

pawn Код:
C:\Documents and Settings\Chris\Desktop\Trucking Server\filterscripts\ShockeyAdmin.pwn(672) : warning 209: function "cmd_jail" should return a value
Reply
#2

Try this;
pawn Код:
CMD:jail(playerid,params[]) {
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Usage: /jail <ID>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Error: Player Not Connected!");
    if(PlayerInfo[playerid][pAdminLevel] >= 10) return SendClientMessage(playerid,COLOR_RED,"You cannot use this command!");
    new string[128];
    format(string, sizeof(string), "%s has been sent to jail by an Admin",GetName(playerid));
    SendClientMessageToAll(COLOR_RED, string);
    RemovePlayerFromVehicle(id);
    PlayerInfo[id][pJailed] = 1;
    ResetPlayerWeapons(playerid);
    SetPlayerInterior(id, 6);
    SetPlayerPos(id, 265.000000,78.000000,1002.00000000);
    SetPlayerVirtualWorld(id, 5);
    return 1;
}
Reply
#3

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Try this;
pawn Код:
CMD:jail(playerid,params[]) {
    new id;
    if(sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_RED, "Usage: /jail <ID>");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Error: Player Not Connected!");
    if(PlayerInfo[playerid][pAdminLevel] >= 10) return SendClientMessage(playerid,COLOR_RED,"You cannot use this command!");
    new string[128];
    format(string, sizeof(string), "%s has been sent to jail by an Admin",GetName(playerid));
    SendClientMessageToAll(COLOR_RED, string);
    RemovePlayerFromVehicle(id);
    PlayerInfo[id][pJailed] = 1;
    ResetPlayerWeapons(playerid);
    SetPlayerInterior(id, 6);
    SetPlayerPos(id, 265.000000,78.000000,1002.00000000);
    SetPlayerVirtualWorld(id, 5);
    return 1;
}
What was wrong?
Reply
#4

You put the "return 1" into an IF statement, not at the end of the command.
Reply
#5

Also, next time don't use else if, else if, simply return like I did.
Better way to write and much more comfortable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)