[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
#2

Not really a tutorial, more like a filterscript release.
Reply
#3

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

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.
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)