08.03.2016, 16:48
You just need to add a Float: tag in front of CallRemoteFunction
That would solve your problem but calling it like that looks kind of ugly and you are wasting memory because each constant string you use in a function call gets allocated into the data section (many "GetSpawn" and "i" instead of just one)
Therefor you should redefine the function or create a new function
After that it would look like that
To convert your code just use the search and replace tool
The reason is simple, printf doesn't care which type of data you pass to it
But if you pass an int to a Float parameter like in CreateVehicle the compiler will do that
It tries to convert the returned value of CallRemoteFunction to a float although it is already a float resulting in something undefined
PHP код:
Float:x = Float:CallRemoteFunction("GetSpawn","i",0),
Float:y = Float:CallRemoteFunction("GetSpawn","i",1),
Float:z = Float:CallRemoteFunction("GetSpawn","i",2) + 5.0,
Float:a = Float:CallRemoteFunction("GetSpawn","i",3);
Therefor you should redefine the function or create a new function
PHP код:
// 1. Redefinition of CallRemoteFunction with default parameters
native Float: _GetSpawn(func[] = "GetSpawn", form[] = "i", {Float, _}: ...) = CallRemoteFunction;
// Macro to use the default parameter for func[] and form[]
#define GetSpawn( _GetSpawn(_,_,
// If you use this you need to put it somewhere at the top / include
// 2. Or you create a function - although with that method you lose some speed
Float: GetSpawn(coord) return Float: CallRemoteFunction("GetSpawn", "i", coord);
// That could be put anywhere but you would get a forcing reparse warning if you put if after the first usage
// => Should also be somewhere at the top / include to avoid the warning
PHP код:
Float:x = GetSpawn(0),
Float:y = GetSpawn(1),
Float:z = GetSpawn(2) + 5.0,
Float:a = GetSpawn(3);
Quote:
I tried this code and the results in print were perfect but the spawning of vehicle was out of map(bonds) which causes a screen freeze..
|
But if you pass an int to a Float parameter like in CreateVehicle the compiler will do that
PHP код:
CreateVehicle(CallRemoteFunction("MapInfoCheck","ii",CurrentGameMode,4),float(CallRemoteFunction("GetSpawn","i",0)),float(CallRemoteFunction("GetSpawn","i",1)),...);