player in each specific vehicle -
Mobtiesgangsa - 20.10.2018
Is there any alternative way to do this for accessable vehicles
when enter on any 4 wheeled car engine and lights off
when enter on bicycle engine on others off?
for some type of vehicles if they dont have trunk and\or hood to be unset
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid,
engine_state[vehicleid],
lights_state[vehicleid],
alarm_state[vehicleid],
doors_state[vehicleid],
bonnet_state[vehicleid],
boot_state[vehicleid],
objective_state[vehicleid]
);
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
switch(IsPlayerInVehicle(playerid, vehicleid))
{
case 400: SetVehicleParamsEx(vehicleid, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_OFF);
..
}
}
return 1;
}
any idea or the code in not optimized?
Re: player in each specific vehicle -
GTLS - 21.10.2018
Setting the parameter values for it doesnt actually exist, will not return any error. So if you turn Engine "ON" on a bicycle, it does nothing.
Re: player in each specific vehicle -
KinderClans - 21.10.2018
I suggest you to use a stock to directly set engine status, instead of writing that much code everytime.
pawn Код:
stock SetEngineStatus(vehicleid, status)
{
static engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
return SetVehicleParamsEx(vehicleid, status, lights, alarm, doors, bonnet, boot, objective);
}
pawn Код:
SetEngineStatus(vehicleid, true/false);
And you need also a stock if a vehicle has engine or not.
Re: player in each specific vehicle -
kristo - 21.10.2018
Quote:
Originally Posted by KinderClans
I suggest you to use a stock to directly set engine status, instead of writing that much code everytime.
And you need also a stock if a vehicle has engine or not.
|
Why a stock, sir, why not a regular function?
Re: player in each specific vehicle -
GTLS - 23.10.2018
Stock is used to declare a function you may or may not use in your code. To just prevent warning while compiling. Theres no point of using stock if you are actually going to call the function. So just declare a normal function
Re: player in each specific vehicle -
Mobtiesgangsa - 23.10.2018
my code compiled without an error but when i try'd it out it simple didnt work
i added first ManualVehicleEngineAndLights();
and try'd when player state is driver the engine to go off for some type of vehicles and for bicycles to be on
expect for some cars that doesnt have a bonnet or a boot to stay off or unusable saying this car doesnt have a trunk\hood
Re: player in each specific vehicle -
kristo - 23.10.2018
Quote:
Originally Posted by GTLS
Stock is used to declare a function you may or may not use in your code. To just prevent warning while compiling. Theres no point of using stock if you are actually going to call the function. So just declare a normal function
|
My issue wasn't him using a stock function. Having the stock keyword in front of every function is completely okay, especially if you're writing a library or just want your script to have a futureproof API. My issue was that he was referring to a function as a stock like they were synonyms.
Re: player in each specific vehicle -
sammp - 24.10.2018
Quote:
Originally Posted by GTLS
Stock is used to declare a function you may or may not use in your code. To just prevent warning while compiling. Theres no point of using stock if you are actually going to call the function. So just declare a normal function
|
If you're writing methods that aren't being used, why in gods name are you writing them!!?!!?!