SA-MP Forums Archive
Lights - 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)
+--- Thread: Lights (/showthread.php?tid=366484)



Lights - Taleski - 06.08.2012

How can i do the lights go ON when it's day not just in Night

I uste Gamemode: CLRP (CytiLife)


Re: Lights - ryansheilds - 06.08.2012

Assuming you mean vehicle lights...
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
}
But you need a command to turn the engine on too, as it will start off.
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx


Re: Lights - Taleski - 07.08.2012

but i don't need the engine to start on or off
i have the engine
but i need lights to go ON when it's day
The lights are going ON when it's only Night
How can i Fix that?


Re: Lights - shitbird - 07.08.2012

Read what ryansheilds posted.
Click the link. You'll find what you're looking for there.


Re: Lights - CROSS_Hunter - 07.08.2012

pawn Код:
//under on game mode init
    ManualVehicleEngineAndLights();
then under OnPlayerCommandText:

pawn Код:
//only if ur using dcmd
dcmd(lightson,8,cmdtext);
dcmd(lightsoff,9,cmdtext);
then where u start scripting ur commands [in the onplayercommandtext]

pawn Код:
//defining
dcmd_lightson(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
pawn Код:
//checking if player is the driver
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
pawn Код:
//checking if the lights are already on
if(lights == VEHICLE_PARAMS_ON)
        {
            SendClientMessage(playerid,COLOR_ERROR,"The lights are already on.");//change the color_error to the color you want make sure its defined
            return 1;
        }
pawn Код:
//then the action of the lights being on
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetDistanceBetweenPlayers(playerid,i) < 10)
            {
                format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns on the lights.",PlayerName(playerid),playerid);
                SendClientMessage(i,COLOR_LIGHTBLUE,string);
            }
        }
    }
    return 1;
}
so all of the command is :
pawn Код:
dcmd_lightson(playerid,params[])
{
    #pragma unused params
    new string[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(lights == VEHICLE_PARAMS_ON)
        {
            SendClientMessage(playerid,COLOR_ERROR,"The lights are already on.");
            return 1;
        }
        SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetDistanceBetweenPlayers(playerid,i) < 10)
            {
                format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns on the lights.",PlayerName(playerid),playerid);
                SendClientMessage(i,COLOR_LIGHTBLUE,string);
            }
        }
    }
    return 1;
}
//dont copy and paste just learn it its not the same as ur code so then you will come back crying about errors
then the lights off:

pawn Код:
//defining
dcmd_lightsoff(playerid,params[])
{
#pragma unused params
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
new vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
pawn Код:
//check if he is the driver
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
pawn Код:
//check if the lightsare already off
if(lights == VEHICLE_PARAMS_OFF)
        {
            SendClientMessage(playerid,COLOR_ERROR,"The lights are already off.");
            return 1;
        }
pawn Код:
//action of the lights being off
SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetDistanceBetweenPlayers(playerid,i) < 10)
            {
                format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns off the lights.",PlayerName(playerid),playerid);
                SendClientMessage(i,COLOR_LIGHTBLUE,string);
            }
        }
    }
    return 1;
}
pawn Код:
//so the full code
dcmd_lightsoff(playerid,params[])
{
    #pragma unused params
    new string[128];
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(lights == VEHICLE_PARAMS_OFF)
        {
            SendClientMessage(playerid,COLOR_ERROR,"The lights are already off.");
            return 1;
        }
        SetVehicleParamsEx(vid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetDistanceBetweenPlayers(playerid,i) < 10)
            {
                format(string,sizeof(string),"%s(%d) twists a lever behind the steering wheel and turns off the lights.",PlayerName(playerid),playerid);
                SendClientMessage(i,COLOR_LIGHTBLUE,string);
            }
        }
    }
    return 1;
}
dont copy and paste just learn it its not the same as ur code so then you will come back crying about errors


Re: Lights - ryansheilds - 07.08.2012

Quote:
Originally Posted by Taleski
Посмотреть сообщение
but i don't need the engine to start on or off
i have the engine
but i need lights to go ON when it's day
The lights are going ON when it's only Night
How can i Fix that?
Adding ManualVehicleEngineAndLights will make a toggle for both the engine and lights, there's no way to just toggle to lights.

If you don't want a engine command, something simple like this should work:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == 0)
        {
            SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
        }
        }
}
Since you want lights to come on during the day a simple command like this:
pawn Код:
CMD:lights(playerid, params[])
{
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(lights == 1)
    {
        lights = 0;
        SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights off.");
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    }
    else
    {
        lights = 1;
        SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights on.");
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    }
    return 1;
}
This is a simple command, which might not work - Not tested.

But you should get the point with it, if you want an engine command its just like the lights command. except change it to engine.


Re: Lights - CROSS_Hunter - 07.08.2012

Quote:
Originally Posted by ryansheilds
Посмотреть сообщение
Adding ManualVehicleEngineAndLights will make a toggle for both the engine and lights, there's no way to just toggle to lights.

If you don't want a engine command, something simple like this should work:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(engine == 0)
        {
            SetVehicleParamsEx(vid,1,lights,alarm,doors,bonnet,boot,objective);
        }
        }
}
Since you want lights to come on during the day a simple command like this:
pawn Код:
CMD:lights(playerid, params[])
{
    new engine,lights,alarm,doors,bonnet,boot,objective;
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(lights == 1)
    {
        lights = 0;
        SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights off.");
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    }
    else
    {
        lights = 1;
        SendClientMessage(playerid, COLOR_WHITE,"You have turned the vehicle lights on.");
        SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    }
    return 1;
}
This is a simple command, which might not work - Not tested.

But you should get the point with it, if you want an engine command its just like the lights command. except change it to engine.
repeating what i said?


Re: Lights - ryansheilds - 07.08.2012

Quote:
Originally Posted by CROSS_Hunter
Посмотреть сообщение
repeating what i said?
Yours looked like shit, and might of been a bit too complicated, I was showing a easy and basic explanation.


Re: Lights - Taleski - 07.08.2012

oh my god
i use this command
but the lights are turning ON when it's just NIGHT
in DAY they are not turning ON
how can i fix that??


Re: Lights - ryansheilds - 07.08.2012

You did at that?:
pawn Код:
public OnGameModeInit()
{
    ManualVehicleEngineAndLights();
}