You just need to add a Float: tag in front of CallRemoteFunction
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);
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
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
After that it would look like that
PHP код:
Float:x = GetSpawn(0),
Float:y = GetSpawn(1),
Float:z = GetSpawn(2) + 5.0,
Float:a = GetSpawn(3);
To convert your code just use the search and replace tool
Quote:
Originally Posted by AroseKhanNiazi
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..
|
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
PHP код:
CreateVehicle(CallRemoteFunction("MapInfoCheck","ii",CurrentGameMode,4),float(CallRemoteFunction("GetSpawn","i",0)),float(CallRemoteFunction("GetSpawn","i",1)),...);
It tries to convert the returned value of CallRemoteFunction to a float although it is already a float resulting in something undefined