Help with FilterScript !
#2

This is how you do it using Remote Function calling

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
• Getting a player's admin level.
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.
pawn Код:
forward GetPlayerAdminLevel(playerid);

public GetPlayerAdminLevel(playerid) return PlayerAdminLevel[playerid]; //Directly returns the admin level of the player.
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 Код:
#include <a_samp>
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 Код:
#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;
}
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.
for the full tutorial https://sampforum.blast.hk/showthread.php?tid=516617
Reply


Messages In This Thread
Help with FilterScript ! - by Pajkovic003 - 13.11.2017, 12:26
Re: Help with FilterScript ! - by TrueThing - 13.11.2017, 13:06
Re: Help with FilterScript ! - by Pajkovic003 - 13.11.2017, 13:29

Forum Jump:


Users browsing this thread: 1 Guest(s)