PHP Code:
new PoliceLightObj[MAX_PLAYERS]; // under the script

public OnPlayerStateChange(playerid, newstate, oldstate)
{
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.0, 0.0, 0.8, 0.0, 0.0, 0.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]) == 1) DestroyObject(PoliceLightObj[playerid]);//delete police light when player exit from vehicle
}
return 1;
}
__________________

WWW.SAMP-GAMING.COM
**** [COD] Call Of Duty - Ghosts **** - 91.121.97.26:7820
[FS] Info about opponent! Help to kill!
[FS] Improved Damage (WITH SPECIAL EFFECTS)
[FS] FireNitro
[FS] Question Calculator Game