player in each specific vehicle
#1

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?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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?
Reply
#5

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
Reply
#6

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
Reply
#7

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.
Reply
#8

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!!?!!?!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)