Lights command
#1

PHP код:
CMD:lights(playeridparams[])
{
    new 
vehicleidengine,lights,alarm,doors,bonnet,boot,objective;
    
vehicleid GetPlayerVehicleID(playerid);
    
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(!
IsPlayerInAnyVehicle(playerid))
        return 
SendClientMessage(playeridCOLOR_RED"Error: You are not in a vehicle.");
    if(
GetPlayerVehicleSeat(playerid) != 0)
        return 
SendClientMessage(playeridCOLOR_RED"Error: You are not in the drivers seat.");
    if(
lights == 0)
    {
        
SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
    }
    else
    {
        
SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
    }
    return 
1;

errm well i created a /lights command it worked 100% when i tested it but after i went to sleep got up restarted the server.. if u do /lights the lights only come on when the player exits the vehicle O.o
whats up with that?
i also have a /engine command that works 100% so whats wrong
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=456791
Reply
#3

Quote:
Originally Posted by Vanter
Посмотреть сообщение
Can't you actually post something to help him?

pawn Код:
ManualVehicleEngineAndLights();
Put that under OnGameModeInit. Your situation seems to be that they're controlled by your player's status, like how it is in single player.
Reply
#4

Quote:
Originally Posted by nmader
Посмотреть сообщение
Can't you actually post something to help him?

pawn Код:
ManualVehicleEngineAndLights();
Put that under OnGameModeInit. Your situation seems to be that they're controlled by your player's status, like how it is in single player.
@vanter isn't that some form of advertising? lool and i looked at your code and it isn't different from mine
@nmader errm is there a way to turn on your lights and engine free at will? but still keep the engine automatically on so when a player enters it he doesn't have to type /engine to turn it on
Reply
#5

then freaking when player enters vehicle, get vehicle Id and set vehicle params ex
Reply
#6

Quote:
Originally Posted by nmader
Посмотреть сообщение
Can't you actually post something to help him?

pawn Код:
ManualVehicleEngineAndLights();
Put that under OnGameModeInit. Your situation seems to be that they're controlled by your player's status, like how it is in single player.
Quote:
Originally Posted by Vanter
Посмотреть сообщение
then freaking when player enters vehicle, get vehicle Id and set vehicle params ex
Wow and your attitude is gonna help me how? nice example.Thanks for your "help"
Reply
#7

Vehicles are on by default. As long as you aren't using SetVehicleParamsEx under OnPlayerStateChange or OnPlayerEnterVehicle, you shouldn't have a problem with the engine being disabled.

pawn Код:
CMD:lights(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "Error: You are not in the drivers seat of any vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, engine, (lights) ? (0) : (1), alarm, doors, bonnet, boot, objective);
    return 1;
}
Reply
#8

my internet chipped sorry for that double post
Reply
#9

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Vehicles are on by default. As long as you aren't using SetVehicleParamsEx under OnPlayerStateChange or OnPlayerEnterVehicle, you shouldn't have a problem with the engine being disabled.

pawn Код:
CMD:lights(playerid, params[])
{
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_RED, "Error: You are not in the drivers seat of any vehicle.");
    new vehicleid = GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, engine, (lights) ? (0) : (1), alarm, doors, bonnet, boot, objective);
    return 1;
}
thanks for your effort in helping me thres but with your code the lights come on for about 2 seconds then comes back off and when i'm on foot :S
i checked back the two callbacks u mentioned and i don't have SetVehicleParamsEx or anything of that sort under them /:
and i find it weird cause the /engine command works and its formatted the same as the lights command ._.
Reply
#10

Are you sure you don't have SetVehicleParamsEx anywhere else in your code that might be affecting this?
(CTRL + F, "SetVehicleParams")
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)