Locking veh's
#1

Hello, i have this code to lock big vehicles (rhino, hunter, hydra, seasparrow), if there are < 15 players online, i tried this:

pawn Code:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetOnlinePlayers() < 15)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 520 || 432 || 425 || 447 || 476) //Whore vehicles locking
    {
    SCM(playerid,0xAA3333AA,"You can drive this vehicle if there are more than 15 players online.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
Placed on OnPlayerStateChange, but it locks EVERY vehicle i try to enter and not just the selected vehicle models.
Reply
#2

Try this:

pawn Code:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetOnlinePlayers() < 15)
{
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 425 ||
    GetVehicleModel(vehicleid) == || GetVehicleModel(vehicleid) == 447 || GetVehicleModel(vehicleid) == 476)
    {
        SCM(playerid,0xAA3333AA,"You can drive this vehicle if there are more than 15 players online.");
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
}
Reply
#3

I get an error on this line:

pawn Code:
if(GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == || GetVehicleModel(vehicleid) == 447 || GetVehicleModel(vehicleid) == 476)
Reply
#4

Try this:

pawn Code:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetOnlinePlayers() < 15)
    {

switch( GetVehicleModel(vehicleid) )
{
    case 520, 432, 425, 447, 476:
    {
       {
    SCM(playerid,0xAA3333AA,"You can drive this vehicle if there are more than 15 players online.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
}
}
}
Reply
#5

Quote:
Originally Posted by Face9000
View Post
I get an error on this line:

pawn Code:
if(GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == || GetVehicleModel(vehicleid) == 447 || GetVehicleModel(vehicleid) == 476)
There is a missing number in there,
pawn Code:
GetVehicleModel(vehicleid) ==
Insert the number there.
Reply
#6

pawn Code:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetOnlinePlayers() < 15)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 520,432,425,447,476) //Whore vehicles locking
    {
    SCM(playerid,0xAA3333AA,"You can drive this vehicle if there are more than 15 players online.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
Simple as that.
Reply
#7

pawn Code:
if(GetVehicleModel(vehicleid) == 520/432/425/447/476)
Can also do that.



OFF TOPIC:
Quote:
Originally Posted by zxc1
View Post
pawn Code:
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && GetOnlinePlayers() < 15)
    {
    new vehicleid = GetPlayerVehicleID(playerid);
    if(GetVehicleModel(vehicleid) == 520,432,425,447,476) //Whore vehicles locking
    {
    SCM(playerid,0xAA3333AA,"You can drive this vehicle if there are more than 15 players online.");
    RemovePlayerFromVehicle(playerid);
    return 1;
    }
    }
Simple as that.
Where is your gif from!!?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)