Invalid function or declaration
#1

Hello, I'm trying to add this function to my gamemode:
Код:
SetVehicleEngineState(vehicleid, state)
{
	new engine, lights, alarm, doors, bonnet, boot, objective;
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	SetVehicleParamsEx(vehicleid, state, lights, alarm, doors, bonnet, boot, objective);
}
But every time I compile it it gives me invalid function or declaration error. There's nothing wrong with it, is there?
Reply
#2

I changed state to vstate, because state interferes with something else.

Код:
SetVehicleEngineState(vehicleid, vstate)
{
	new engine, lights, alarm, doors, bonnet, boot, objective;
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	SetVehicleParamsEx(vehicleid, vstate, lights, alarm, doors, bonnet, boot, objective);
}
Reply
#3

Quote:
Originally Posted by PeanutButter
Посмотреть сообщение
I changed state to vstate, because state interferes with something else.

Код:
SetVehicleEngineState(vehicleid, vstate)
{
	new engine, lights, alarm, doors, bonnet, boot, objective;
	GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
	SetVehicleParamsEx(vehicleid, vstate, lights, alarm, doors, bonnet, boot, objective);
}
Thank you, I didn't think about it.
Reply
#4

On functions that have a similar name to natives and when those natives have specific return values, I recommend returning the natives in the functions:
PHP код:
SetVehicleEngineState(vehicleidvstate)
{
    new 
enginelightsalarmdoorsbonnetbootobjective;
    
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
    return 
SetVehicleParamsEx(vehicleidvstatelightsalarmdoorsbonnetbootobjective);

Return Values:
  • 1: The function executed successfully.
  • 0: The function failed to execute. This means the vehicle does not exist. - May come in handy
In any other means, it's advised to return a 0 or a 1 when functions don't return any specific values.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)