[solved] if statements bringing errors
#1

Script:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if (GetPlayerVehicleID(playerid); == 417)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
    }
    if (GetPlayerVehicleID(playerid); == 512)
      {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
      }
      #end if
    return 1;
}
Errors:
pawn Код:
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(118) : error 001: expected token: ")", but found ";"
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(118) : error 036: empty statement
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(118) : error 029: invalid expression, assumed zero
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(118) : fatal error 107: too many error messages on one line
Reply
#2

if(GetPlayerVehicleID(playerid); == 417)
^
You don't see anything wrong with that?
Reply
#3

Quote:
Originally Posted by Baked-Banana
if(GetPlayerVehicleID(playerid); == 417)
^
You don't see anything wrong with that?
pawn Код:
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(129) : error 031: unknown directive
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(129 -- 130) : warning 215: expression has no effect
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(130) : error 001: expected token: ";", but found "return"
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(130) : warning 217: loose indentation
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(145) : error 029: invalid expression, assumed zero
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(145) : warning 215: expression has no effect
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(145) : error 001: expected token: ";", but found ")"
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(145) : error 029: invalid expression, assumed zero
C:\Users\Wyatt\Desktop\RANDOM\SERVER\gamemodes\Sand.pwn(145) : fatal error 107: too many error messages on one line
after i remove.
Reply
#4

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 417)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    if(GetVehicleModel(vehicleid) == 512)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    return 1;
}
That's the correct version. For one thing, you needed to use the function GetVehicleModel which would have returned the actual vehicle model not the vehicle id which is what you were doing. Secondly, you didn't need to get the vehicle id because it's already one of the callback's parameters. Try that out though and it should work.
Reply
#5

Quote:
Originally Posted by Baked-Banana
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 417)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    if(GetVehicleModel(vehicleid) == 512)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    return 1;
}
That's the correct version. For one thing, you needed to use the function GetVehicleModel which would have returned the actual vehicle model not the vehicle id which is what you were doing. Secondly, you didn't need to get the vehicle id because it's already one of the callback's parameters. Try that out though and it should work.
ty so much, learning every day ya know
Reply
#6

Quote:
Originally Posted by luigifan9
Quote:
Originally Posted by Baked-Banana
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetVehicleModel(vehicleid) == 417)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    if(GetVehicleModel(vehicleid) == 512)
    {
        SendClientMessage(playerid, c_green, "Type /rentcar to rent this or /nty to be ejected :D");
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
    return 1;
}
That's the correct version. For one thing, you needed to use the function GetVehicleModel which would have returned the actual vehicle model not the vehicle id which is what you were doing. Secondly, you didn't need to get the vehicle id because it's already one of the callback's parameters. Try that out though and it should work.
ty so much, learning every day ya know
Yeah I've been there. (and am still there)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)