[Tutorial] ADD Police light to vehicle
#1

PHP Code:
new PoliceLightObj[MAX_PLAYERS]; // under the script
public OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
IsValidObject(PoliceLightObj[playerid]) == 0)//add vehicle light after player sit in vehicle
        
{
            
PoliceLightObj[playerid] = CreateObject(18646,0.0,0.0,0.0,0.0000000,0.0000000,0.0000000);
            
AttachObjectToVehicle(PoliceLightObj[playerid], GetPlayerVehicleID(playerid), 0.00.00.80.00.00.0);
        }
        
//if you wont add police light only for cops, you can create player team check like this
        /*
        
        if(IsValidObject(PoliceLightObj[playerid]) == 0)//add vehicle light after player sit in vehicle
        {
            if(PLAYERTEAM == COP)
            {
                PoliceLightObj[playerid] = CreateObject(18646,0.0,0.0,0.0,0.0000000,0.0000000,0.0000000);
                AttachObjectToVehicle(PoliceLightObj[playerid], GetPlayerVehicleID(playerid), 0.0, 0.0, 0.8, 0.0, 0.0, 0.0);
            }
        }
        
        // PLAYER TEAM can be fucn SetPlayerTeam if you use this func you should add this... if(GetPlayerTeam(playerid) == 1) ( 1 its for example number of cop team)
        
        */
    
}
    if(
oldstate == PLAYER_STATE_DRIVER)
    {
        if(
IsValidObject(PoliceLightObj[playerid]) == 1DestroyObject(PoliceLightObj[playerid]);//delete police light when player exit from vehicle
    
}
    return 
1;

Reply


Messages In This Thread
Create Police light for vehicle - by brawrr - 01.04.2013, 19:25
Re: ADD Police light to vehicle - by Kestro - 01.04.2013, 19:26
Re: ADD Police light to vehicle - by Joron - 10.12.2015, 22:53
Re: ADD Police light to vehicle - by Riddick94 - 10.12.2015, 23:09
Re: ADD Police light to vehicle - by saffierr - 15.12.2015, 21:39

Forum Jump:


Users browsing this thread: 1 Guest(s)