SA-MP Forums Archive
[Tutorial] ADD Police light to vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] ADD Police light to vehicle (/showthread.php?tid=427449)



Create Police light for vehicle - brawrr - 01.04.2013

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;




Re: ADD Police light to vehicle - Kestro - 01.04.2013

Not really a tutorial, more like a filterscript release.


Re: ADD Police light to vehicle - Joron - 10.12.2015

Quote:
Originally Posted by Kestro
View Post
Not really a tutorial, more like a filterscript release.
Yeah..


Re: ADD Police light to vehicle - Riddick94 - 10.12.2015

L'viv (Lwуw) back right now! And smells like a snippet/filterscript. Tutorial my friend is more descriptive where you say everything about your code and explain it. You have to say what is each line of code doing and why it's done that way and no other.

Please update your post.


Re: ADD Police light to vehicle - saffierr - 15.12.2015

As Kestro said, but beside that, I like it.