SA-MP Forums Archive
Invalid function or declaration - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Invalid function or declaration (/showthread.php?tid=621092)



Invalid function or declaration - GoldenLion - 06.11.2016

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?


Re: Invalid function or declaration - PeanutButter - 06.11.2016

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);
}



Re: Invalid function or declaration - GoldenLion - 06.11.2016

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.


Re: Invalid function or declaration - SickAttack - 06.11.2016

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: In any other means, it's advised to return a 0 or a 1 when functions don't return any specific values.