new Name[150]; new Coords[3] = 0.0; forward ExampleFunc(playerid); public ExampleFunc(playerid) return Name[playerid]; forward ExampleFunc2(a); public ExampleFunc2(a) return Coords[a];
SendClientMessage(playerid, 0x000000AA, "The veh name: %s", CallRemoteFunction("ExampleFunc", "d", playerid)); SetPlayerPos(CallRemoteFunction("ExampleFunc2", "i", 0), CallRemoteFunction("ExampleFunc2", "i", 1), CallRemoteFunction("ExampleFunc2", "i", 2));
SetPlayerPos(CallRemoteFunction("ExampleFunc2", "f", 0), CallRemoteFunction("ExampleFunc2", "f", 1), CallRemoteFunction("ExampleFunc2", "f", 2)
printf("%f", TestOne() );
printf("%s", TestTwo() );
stock TestOne()
{
new Float:Example = 5487.1564;
return _:Example;
}
stock TestTwo()
{
new string[] = "TESTING THE STRING!";
return string;
}
// Global variables on top of your script
new Float:PlayerX, Float:PlayerY, Float:PlayerZ, PlayerName[24];
// This function stores the name and coordinates of the requested player when using the function OtherScript_GetPlayerData
forward MainScript_StorePlayerData(const pName[], Float:pX, Float:pY, Float:pZ);
public MainScript_StorePlayerData(const pName[], Float:pX, Float:pY, Float:pZ)
{
// Store the name of the player that was passed to this script
format(PlayerName, sizeof(PlayerName), pName);
// Store his coordinates
PlayerX = pX;
PlayerY = pY;
PlayerZ = pZ;
}
SomeFunction(playerid)
{
// Use this function to get data from another script
CallRemoteFunction("OtherScript_GetPlayerData", "i", playerid);
printf("PlayerName: %s", PlayerName);
printf("Coordinates: %f, %f, %f", PlayerX, PlayerY, PlayerZ);
)
// Put this in the other script
forward OtherScript_GetPlayerData(playerid);
public OtherScript_GetPlayerData(playerid)
{
// Send the playername and his coordinates back to the mainscript for further use
CallRemoteFunction("MainScript_StorePlayerData", "sfff", pData[playerid][PlayerName], pData[playerid][PlayerX], pData[playerid][PlayerY], pData[playerid][PlayerZ]);
}
CallRemoteFunction only returns integers. I've tested this too and struggled with it, until I found a work-around:
|
foo(Float: fVal); public foo(Float: fVal)
{
return _: fVal;
}
printf("%f", CallRemoteFunction("foo", "f", 12.345678));