native CallRemoteFunction(const function[], const format[], {Float,_}:...);
I'm adding a public function to my gamemode which would return the admin level variable since the gamemode got all the source of administration system.• Linking up a function on Anti-Cheats
Now I'm creating a new filterscript with a command which would print the player's admin level. I'm opening a new script and I'm including a_samp first.pawn Code:forward GetPlayerAdminLevel(playerid);
public GetPlayerAdminLevel(playerid) return PlayerAdminLevel[playerid]; //Directly returns the admin level of the player.
Now to do the remote call. We can create a "stock" function which returns the remote function's return. CallRemoteFunction returns what the "public" function specified on that function returns. So here, on CallRemoteFunction we can use "GetPlayerAdminLevel" public function to return it's value and that value would be the admin level of the player.pawn Code:#include <a_samp>
This can be useful on cases where you've to get the admin level for any sort of commands or stuff. The same idea can also be used to check if player is on any event, DM or stuffs.pawn Code:#define FILTERSCRIPT //Supposing that this is a FS.
#include <a_samp>
stock GetPlayerAdminLevel(playerid) //There's no problem if this is a "stock" and having the same name of that "public" function.
{
return CallRemoteFunction("GetPlayerAdminLevel", "i", playerid); //Directly calls out the "public" function named GetPlayerAdminLevel from other script.
//It will be returning the admin level of the player.
}
//The function has been created, how about a command to test it?
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/testadmlevel", true)) {
printf("Your admin level is : %d", GetPlayerAdminLevel(playerid)); //Calls out the stock function.
return 1;
}
return 0;
}
You can also use the same idea on Anti-Cheats. Like if player's pos is being set, rather than including the functions everywhere and getting it included on every scripts, create remote functions and use the AntiCheat as a filterscript. It would link things up together. I haven't tried that on any Anti-Cheat but I'm quite sure that it would work.You can also call up the SA-MP callbacks or any "public" functions using CallRemoteFunction. On cases where you call local OnPlayerConnect, if it's necessary to load something else from the OnPlayerConnect of other script, you can use CallRemoteFunction.
Suppose, this is my supercoolanticheat.PWN which is a filterscript. It got:
Now, I've got an include which got many remote functions. Rather than that include having all these arrays, I'm going to use remote calls.pawn Code:forward LAnti_SetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
public LAnti_SetPlayerPos(playerid, Float:X, Float:Y, Float:Z)
{
LAnti_pX[playerid] = X;
LAnti_pY[playerid] = Y;
LAnti_pZ[playerid] = Z;
return SetPlayerPos(playerid, X, Y, Z);
}
Now this would automatically set the array's values according to the call which has been done. I just have to include my "include" on every scripts. CallRemoteFunction fetches the function from every script which got that function.pawn Code:stock LAnti_SetPlayerPos(playerid, Float:X, Float:Y, Float:Z)
{
return CallRemoteFunction("LAnti_SetPlayerPos", "ifff", playerid, X, Y, Z);
}
CallRemoteFunction("OnPlayerConnect", "i", playerid); //This will call OnPlayerConnect on every script which uses OnPlayerConnect
So is it possible to get a variable's address if I add a parameter to it's forwarded function and then return it accordingly?
|
new
myVars[5];
forward GetVariableValue(var_id);
public GetVariableValue(var_id)
{
if(var_id < 0 || var_id > 4) return 0;
return myVars[var_id];
}
stock GetVariableValue(var_id)
{
return CallRemoteFunction("GetVariableValue", "i", var_id);
}