Command question.
#1

Getting used to pawno everyday, but as every new starter we have to comit mistakes.


So here's the command

pawn Код:
CMD:ee(playerid, params[])
{
            if(!IsPlayerInAnyVehicle(playerid))
            if(gClass[playerid] != CLASS_PILOT) return SP COLOR_RED, "[ERROR]: You need to be a Pilot (Rank "#PILOT_RANK"); to use this command");
            {
            GetPlayerPos(playerid, EX,EY,EZ);
            SetPlayerPos(playerid, EX,EY,EZ+5);
            GivePlayerWeapon(playerid, 46, 1);
            }
        }else return SP COLOR_RED, "[ERROR]: You are not in any vehicle");
}
Error in line
pawn Код:
}else return
Error name: Invalid function or declaration.
Reply
#2

pawn Код:
CMD:ee(playerid, params[])
{
    new Float:EX,Float:EY,Float:EZ;
    if(!IsPlayerInAnyVehicle(playerid))
    if(gClass[playerid] != CLASS_PILOT) return SP COLOR_RED, "[ERROR]: You need to be a Pilot (Rank "#PILOT_RANK"); to use this command");
    {
        GetPlayerPos(playerid, EX,EY,EZ);
        SetPlayerPos(playerid, EX,EY,EZ+5);
        GivePlayerWeapon(playerid, 46, 1);
    }
        else
    {
        SP COLOR_RED, "[ERROR]: You are not in any vehicle");  
    }
    return 1;
}
Reply
#3

This will totally work:
pawn Код:
CMD:ee(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SP COLOR_RED, "[ERROR]: You are not in any vehicle");
    if(gClass[playerid] != CLASS_PILOT) return SP COLOR_RED, "[ERROR]: You need to be a Pilot (Rank "#PILOT_RANK"); to use this command");

    GetPlayerPos(playerid, EX,EY,EZ);
    SetPlayerPos(playerid, EX,EY,EZ+5);
    GivePlayerWeapon(playerid, 46, 1);
}
Reply
#4

Quote:
Originally Posted by Roach_
Посмотреть сообщение
This will totally work:
pawn Код:
CMD:ee(playerid)
{
    if(!IsPlayerInAnyVehicle(playerid)) return SP COLOR_RED, "[ERROR]: You are not in any vehicle");
    if(gClass[playerid] != CLASS_PILOT) return SP COLOR_RED, "[ERROR]: You need to be a Pilot (Rank "#PILOT_RANK"); to use this command");

    GetPlayerPos(playerid, EX,EY,EZ);
    SetPlayerPos(playerid, EX,EY,EZ+5);
    GivePlayerWeapon(playerid, 46, 1);
}
Agree!
Reply
#5

Worked thanks
Reply
#6

To give you the explanation on why your first code did not work: you were missing an opening bracket on your if(isPlayerInAnyVehicle) statement.

pawn Код:
if(!IsPlayerInAnyVehicle(playerid)) {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)