SA-MP Forums Archive
Someone help me fix these returns?! - 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: Someone help me fix these returns?! (/showthread.php?tid=273903)



Someone help me fix these returns?! - Shockey HD - 03.08.2011

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



Re: Someone help me fix these returns?! - Toreno - 03.08.2011

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;
}



Re: Someone help me fix these returns?! - Shockey HD - 03.08.2011

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?


Re: Someone help me fix these returns?! - Mean - 03.08.2011

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


Re: Someone help me fix these returns?! - Toreno - 03.08.2011

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