Vehicle Permission
#1

Heya, so probably I'd like to add some vehicles to my roleplay script, although. I want to set permissions to them that only the player that has the job will have a permission to enter the vehicle and to work.

There is a special stock that will help me do so? I mean by vehicle ids?
Reply
#2

Above's code would work however IT WILL RESTRICT THE MODEL ID from that player if he isn't on the job. Vehicle ID should be checked not the vehicle model id. VehicleID and Vehicle Model ID is different, remember that!

I did say you can do this (scratch made not tested)

PHP код:
new test_vehicle;
// OnGameModeInit
test_vehicle AddStaticVehicle(blah..);
// OnPlayerEnterVehicle version
public OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(!
ispassenger)
    {
        if(
GetPlayerVehicleID(playerid) == test_vehicle && job_var[playerid] != 1)
        {
            
SendClientMessage(playerid, -1"You are not a whore to ride this shitty vehicle!");
            
RemovePlayerFromVehicle(playerid);
        }
    }
    return 
1;
}
// OnPlayerStateChange version
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
GetPlayerVehicleID(playerid) == test_vehicle && job_var[playerid] != 1)
        {
            
SendClientMessage(playerid, -1"You are not a whore to ride this shitty vehicle!");
            
RemovePlayerFromVehicle(playerid);
        }
    }
    return 
1;
}
/*
Replace job_var with any variables you are using to determine the player's current job.
Replace the test_vehicle with any variables that you used to store in the VehicleID for the job. 
*/ 
Reply
#3

You cannot use RemovePlayerFromVehicle in OnPlayerEnterVehicle because the time this callback is called is when your player starts moving towards the car or opening it's door, so he is not technically in the vehicle so he cannot be removed, it should be used under OnPlayerStateChage.
Reply
#4

This guy has a point ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)