01.04.2013, 19:25
(
Last edited by brawrr; 01/04/2013 at 08:05 PM.
)
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;
}