Help with a /engine command. -
GrimR - 20.09.2011
Hello,
Currently I have a simple toggle variable (0-Off, 1-On) for engine which is toggled when /engine is written by a player.
In this same toggle portion, I use GetVehicleParamsEx and SetVehicleParamsEx with the only difference being the engine portion is either 0 off or 1 on (to actually start and stop it).
However there are issues such as the character automatically trying to turn the engine on when entering the vehicle (but not actually doing it) and if I turn the vehicle off, exit the vehicle, enter it again and /engine, it will freeze the player and not allow keyboard input (like what that TogglePlayerControllable does).
Is there anyway to stop these little bugs, and/or is there callbacks etc where I should be re-calling Get/Set to ensure it doesn't try to change them?
Re: Help with a /engine command. -
Wesley221 - 20.09.2011
Can you show the code pieces, so we can try to 'fix' the problems?
Re: Help with a /engine command. -
GrimR - 20.09.2011
It wouldn't be relevant.
if you type /engine and engine is on then SetVehicleParamsEx(blah blah toggle engine off)
else SetVehicleParamsEx(blah blah toggle engine on)
That's all I do aside from messing with a crap load of internal variables (no relevant and won't effect).
Re: Help with a /engine command. -
Wesley221 - 20.09.2011
Can u explain it once again, i dont really get the problem now.
Re: Help with a /engine command. -
Basicz - 20.09.2011
pawn Код:
static
bool: engine[ MAX_VEHICLES ] // i wouldnt use char arrays here, vehicle are about 2000++
;
public OnVehicleSpawn( vehicleid )
return engine[ vehicleid ] = false;
COMMAND:engine( playerid, params[ ] )
{
engine[ GetPlayerVehicleID( playerid ) ] = ! engine[ GetPlayerVehicleID( playerid ) ];
SetVehicleParamsEx( GetPlayerVehicleID( playerid ), engine[ GetPlayerVehicleID( playerid ) ], -1, -1, -1, -1, -1 ); // Dunno arguments >.>
return 1;
}
Re: Help with a /engine command. -
GrimR - 20.09.2011
Hmmm I managed to fix the random bug but I do not know how
![undecided](images/smilies/neutral.gif)
, must be just one of those things.
Thanks for the info Basicz.
Re: Help with a /engine command. -
DRIFT_HUNTER - 20.09.2011
pawn Код:
CMD:engine(playerid, params[])
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
new variables[7], vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid, variables[0], variables[1], variables[2], variables[3], variables[4], variables[5], variables[6]);
if(variables[0] != VEHICLE_PARAMS_ON)
{
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_ON, variables[1], variables[2], variables[3], variables[4], variables[5], variables[6]);
}
else
{
SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, variables[1], variables[2], variables[3], variables[4], variables[5], variables[6]);
}
return 1;
}
Next time use WIKI to read all about function
Vehicle parameters have 3 states
#define VEHICLE_PARAMS_UNSET -1
#define VEHICLE_PARAMS_OFF 0
#define VEHICLE_PARAMS_ON 1
Re: Help with a /engine command. -
GrimR - 20.09.2011
If you mean me, I know all the states without the wiki, being a programmer the states are obvious assuming good practice was followed, SA:MP being as good as it is, I was right about that.
It wasn't the function causing an issue, it was simply a minor mistake that took some time away from the problem
to realize (don't you just love those problems!). So in short it was an error on my part that slipped through.