[Help]/engine
#1

Hello,

I'm trying to script an /engine command that checks if your engine is on or off then if the engine is on it turns it off or if its off it turns it on

This is what I got so far but it doesn't work, can't figure out what's the problem, I hope someone knows what the problem is

pawn Код:
CMD:engine(playerid,o[])
{
static
vid,
vid1,
str[80],
str1[80],
pname[MAX_PLAYER_NAME],
engine,
lights,
alarm,
doors,
bonnet,
boot,
objective
;
vid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
if(engine==0)
{
SetVehicleParamsEx(vid,1,0,0,0,0,0,0);
GetPlayerName(playerid,pname,sizeof(pname));
format(str,sizeof(str),"%s has turned his vehicle's engine on.",pname);
ProxDetector(25.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
if(engine==1)
{
vid1 = GetPlayerVehicleID(playerid);
SetVehicleParamsEx(vid1,0,0,0,0,0,0,0);
GetPlayerName(playerid,pname,sizeof(pname));
format(str1,sizeof(str1),"%s has turned his vehicle's engine off.",pname);
ProxDetector(25.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}

return 1;
}
Thanks.
Reply
#2

ther ya go
nice and easy using GetPVarInt
pawn Код:
CMD:engine(playerid,o[])
{
new veh = GetPlayerVehicleID(playerid);
new engine,lights,alarm,doors,bonnet,boot,objective;
new pname[MAX_PLAYER_NAME];GetPlayerName(playerid,pname,sizeof(pname));
if(GetPVarInt(playerid, "Lights") == 0)
    {
        GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
        SetPVarInt(playerid, "Lights", 1);
        format(str,sizeof(str),"%s has turned his vehicle's engine on.",pname);
        ProxDetector(25.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    }else if(GetPVarInt(playerid, "Lights") == 1)
    {
        GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
        SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
        SetPVarInt(playerid, "Lights", 0);
        format(str1,sizeof(str1),"%s has turned his vehicle's engine off.",pname);
        ProxDetector(25.0, playerid, str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
    }
return 1;
}
Reply
#3

Oh thank you
+1 rep!

But if some other player gets in that vehicle which it's engine is off will he be able to drive or he has to turn it on?
Reply
#4

Quote:
Originally Posted by moadi
Посмотреть сообщение
Oh thank you
+1 rep!

But if some other player gets in that vehicle which it's engine is off will he be able to drive or he has to turn it on?
Thanks

if one player get's in a new vehicle which's engine is off and then that player turns it on
and he leaves the vehicle, the vehicles engine will stay turned on (if you have no fucntion to turn it off when player exits vehicle) and then after that player left and if some other player enters that vehicle he will not need to tunr it on
hope thats what you asked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)