Read Gamemode variable for filterscript
#1

can i read variable from gamemode for filterscript?
Reply
#2

Yeah, you can use "CallRemoteFunction", to call methods from gamemode that returns the variable value... It sounds like OOP...

Ex:
pawn Код:
//FS
#define PWN::%1(%2) forward %1(%2); public %1(%2)
new value_r = 10;

PWN:: get_val()
{
    return value_r;
}

//GM
public OnGameModeInit()
{
    printf("%d", CallRemoteFunction("get_val", ""));
    return 1;
}
Reply
#3

Or you could use PVars / GVars to store all your player and gamemode-related info.

Tutorial:
https://sampforum.blast.hk/showthread.php?tid=261584
Reply
#4

Quote:
Originally Posted by Willian_Luigi
Посмотреть сообщение
Yeah, you can use "CallRemoteFunction", to call methods from gamemode that returns the variable value... It sounds like OOP...
can you give me an example?
btw,i use GarHouse system.
if player use /myhouse in DM they will get an error message.

pawn Код:
CMD:myhouses(playerid, params[])
{

    #pragma unused params
    if ( PlayerInfo[playerid][inDM] == 1 ) return SendClientMessage( playerid, -1, ""RED"ERROR: "GREY"You Are in DM
    if(GetOwnedHouses(playerid) == 0) return ShowInfoBoxEx(playerid, COLOUR_SYSTEM, E_NO_HOUSES_OWNED);
    new h, _tmpstring[128], count = GetOwnedHouses(playerid);
    CMDSString = "
";
    Loop(i, (count + 1), 1)
    {
        h = ReturnPlayerHouseID(playerid, i);
        if(i == count)
        {
            format(_tmpstring, sizeof(_tmpstring), "
{00BC00}%d.\t{FFFF2A}%s in %s", i, hInfo[h][HouseName], hInfo[h][HouseLocation]);
        }
        else format(_tmpstring, sizeof(_tmpstring), "
{00BC00}%d.\t{FFFF2A}%s in %s\n", i, hInfo[h][HouseName], hInfo[h][HouseLocation]);
        strcat(CMDSString, _tmpstring);
    }
    ShowPlayerDialog(playerid, HOUSEMENU+50, DIALOG_STYLE_LIST, INFORMATION_HEADER, CMDSString, "
Select", "Cancel");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)