new engine, lights, alarm, doors, bonnet, boot, objective; -
HondaCBR - 30.11.2011
I got a question about
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(GetPlayerVehicleID(vehicleid),engine,lights,alarm,doors,bonnet,boot,objective);
My question is If it would be possible to add a new variable, If i added owner in there, I dont want the car to do anything, I just want it to check for that variable, can someone tell me if this would work:
pawn Код:
new engine, lights, alarm, doors, bonnet, boot, objective, owner;
GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective,owner);
if(owner==0)
{
//code
}
if(owner==1)
{
//code
}
SetVehicleParamsEx(GetPlayerVehicleID(vehicleid),engine,lights,alarm,doors,bonnet,boot,objective,1);
SetVehicleParamsEx(GetPlayerVehicleID(vehicleid),engine,lights,alarm,doors,bonnet,boot,objective,0);
Re: new engine, lights, alarm, doors, bonnet, boot, objective; -
antonio112 - 30.11.2011
No, it wouldn't work.
GetVehicleParamsEx is a already made function, with its exact params.
Re: new engine, lights, alarm, doors, bonnet, boot, objective; -
blewert - 30.11.2011
You can do this by either using a separate function that isn't named the same:
pawn Код:
stock __GetVehicleParamsEx( _:vehicleid, &engine, &lights, &alarm, &doors, &bonnet, &boot, &objective, bool:owner )
{
if( owner == true )
{
//If owner is true.. execute the following code:
GetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
else
{
//If owner is false.. execute the following code:
GetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
}
stock __SetVehicleParamsEx( _:vehicleid, _:engine, _:lights, _:alarm, _:doors, _:bonnet, _:boot, _:objective, bool:owner = false )
{
if( owner == true )
{
//If owner is true.. execute the following code:
SetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
else
{
//If owner is false.. execute the following code:
SetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
}
or implementing a hook via the pre-compiler, so we can use that native function with the extra argument:
pawn Код:
//Tell pre compiler that GetVehicleParamsEx is a call to our function instead
#define GetVehicleParamsEx __GetVehicleParamsEx
stock __GetVehicleParamsEx( _:vehicleid, &engine, &lights, &alarm, &doors, &bonnet, &boot, &objective, bool:owner )
{
//Undefine GetVehicleParamsEx, because this would call our function - making it recursive.
#undef GetVehicleParamsEx
if( owner == true )
{
//If owner is true.. execute the following code:
GetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
else
{
//If owner is false.. execute the following code:
GetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
//Redefine GetVehicleParamsEx, for use outside of function.
#define GetVehicleParamsEx __GetVehicleParamsEx
}
//Tell pre compiler that SetVehicleParamsEx is a call to our function instead
#define SetVehicleParamsEx __SetVehicleParamsEx
stock __SetVehicleParamsEx( _:vehicleid, _:engine, _:lights, _:alarm, _:doors, _:bonnet, _:boot, _:objective, bool:owner = false )
{
//Undefine SetVehicleParamsEx, because this would call our function - making it recursive.
#undef SetVehicleParamsEx
if( owner == true )
{
//If owner is true.. execute the following code:
SetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
else
{
//If owner is false.. execute the following code:
SetVehicleParamsEx( vehicleid, engine, lights, alarm, doors, bonnet, boot, objective );
}
//Redefine SetVehicleParamsEx, for use outside of function.
#define SetVehicleParamsEx __SetVehicleParamsEx
}
Tested both functions, they work fine. You just need to change the code within the functions to whatever you would like.
If you're interested in pre-compiler hooks, I suggest you see ******' topic & include on it:
http://forum.sa-mp.com/showthread.ph...t=******+hooks