I need your help
#8

Alright, this is a very basic example I can provide you right now. I hope you can understand something from this

PHP код:
// Just defining the model to avoid the confusion
#define PoliceLSPD 596
#define PoliceSFPD 597
#define PoliceLVPD 598
// Boolean variable to indicate it's a police vehicle
new boolg_PoliceVehicle[MAX_VEHICLES];
// Custom function to create a vehicle
server_AddStaticVehicle(modelFloat:xFloat:yFloat:zFloat:anglecolor_1color_2delay)
{
    new 
vehicleid AddStaticVehicleEx(modelxyzanglecolor_1color_2delay);
    switch (
model)
    {
        case 
PoliceLSPDPoliceSFPDPoliceLVPD// Police vehicles, you can add more
        
{
            
g_PoliceVehicle[vehicleid] = true;
        }
    }
    return 
vehicleid;
}
// Adding the vehicle
public OnGamemodeInit()
{
    
server_AddStaticVehicle(PoliceLSPD0.00.00.00.0, -1, -1120); // With your coordinates ofc
    
return 1;
}
// Detecting if players are allowed to drive these vehicles
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
g_PoliceVehicle[vehicleid] == true)
        {
            
// if (player is not detective)
                    // Eject
        
}
    }
    return 
1;

And, you must set the g_PoliceVehicle[vehicleid]'s value to false whenever you destroy one of the created police vehicle. In the similar way you can check for other vehicles too.

Note that this method is probably not that efficient. But still works pretty good and is easier to use so.
Reply


Messages In This Thread
I need your help - by canip - 17.05.2016, 16:41
Re: I need your help - by Sjn - 17.05.2016, 17:29
Re: I need your help - by canip - 17.05.2016, 18:26
Re: I need your help - by canip - 17.05.2016, 18:57
Re: I need your help - by iKevin - 17.05.2016, 19:23
Re: I need your help - by canip - 17.05.2016, 19:26
Re: I need your help - by iKevin - 17.05.2016, 19:28
Re: I need your help - by Sjn - 17.05.2016, 19:53

Forum Jump:


Users browsing this thread: 1 Guest(s)