SA-MP Forums Archive
Help with Incognito's GVar Plugin - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with Incognito's GVar Plugin (/showthread.php?tid=477540)



Help with Incognito's GVar Plugin - SlonCHL - 24.11.2013

I have a game mode that sends a RCon command to load my map fs, in my map fs, I have some coordinates that is globalise by Incognito's GVar plugin, but I cannot retrieve the variable from my game mode after sending the RCon command, do I have to wait for the map to load first?

My game mode(Related codes only)
pawn Код:
new Map[][2][150] =
{
    {
        {"  The Park Outbreak"}, //I don't know why but my script skips the first 2 characters for this var, if you can help me on this pls help
        {"  theparkoutbreak"} //if I do not put the spacing this line will be eparkoutbreak
    }
};
new Float:EscapeEntranceGateCoord[3][2][3];
new Float:HumanSpawnPoint[5][4];

main()
{
    SetTimer("LoadMap", 1, false);
}

public LoadMap()
{
    SendClientMessageToAll(GAME_MESSAGE_COLOR, "Loading map, please wait");
    GameTextForAll("Loading Map", 3000, GAME_GAMETEXT_STYLE);
    new RconCommand[150];
    new NextMapID = GetGVarInt("NextMapID"); //<< 0
    format(RconCommand, sizeof(RconCommand), "loadfs %s", Map[NextMapID][1]);
    SendRconCommand(RconCommand);

    EscapeEntranceGateCoord[0][0][0] = GetGVarFloat("EscapeEntrance1Gate1CoordX");
    EscapeEntranceGateCoord[0][0][1] = GetGVarFloat("EscapeEntrance1Gate1CoordY");
    EscapeEntranceGateCoord[0][0][2] = GetGVarFloat("EscapeEntrance1Gate1CoordZ");

    EscapeEntranceGateCoord[0][1][0] = GetGVarFloat("EscapeEntrance1Gate2CoordX");
    EscapeEntranceGateCoord[0][1][1] = GetGVarFloat("EscapeEntrance1Gate2CoordY");
    EscapeEntranceGateCoord[0][1][2] = GetGVarFloat("EscapeEntrance1Gate2CoordZ");

    EscapeEntranceGateCoord[1][0][0] = GetGVarFloat("EscapeEntrance2Gate1CoordX");
    EscapeEntranceGateCoord[1][0][1] = GetGVarFloat("EscapeEntrance2Gate1CoordY");
    EscapeEntranceGateCoord[1][0][2] = GetGVarFloat("EscapeEntrance2Gate1CoordZ");

    EscapeEntranceGateCoord[1][1][0] = GetGVarFloat("EscapeEntrance2Gate2CoordX");
    EscapeEntranceGateCoord[1][1][1] = GetGVarFloat("EscapeEntrance2Gate2CoordY");
    EscapeEntranceGateCoord[1][1][2] = GetGVarFloat("EscapeEntrance2Gate2CoordZ");

    EscapeEntranceGateCoord[2][0][0] = GetGVarFloat("EscapeEntrance3Gate1CoordX");
    EscapeEntranceGateCoord[2][0][1] = GetGVarFloat("EscapeEntrance3Gate1CoordY");
    EscapeEntranceGateCoord[2][0][2] = GetGVarFloat("EscapeEntrance3Gate1CoordZ");

    EscapeEntranceGateCoord[2][1][0] = GetGVarFloat("EscapeEntrance3Gate2CoordX");
    EscapeEntranceGateCoord[2][1][1] = GetGVarFloat("EscapeEntrance3Gate2CoordY");
    EscapeEntranceGateCoord[2][1][2] = GetGVarFloat("EscapeEntrance3Gate2CoordZ");
    printf("Test: %f, %f, %f", EscapeEntranceGateCoord[2][1][0], EscapeEntranceGateCoord[2][1][1], EscapeEntranceGateCoord[2][1][2]);


    HumanSpawnPoint[0][0] = GetGVarFloat("HumanSpawnPoint1X");
    HumanSpawnPoint[0][1] = GetGVarFloat("HumanSpawnPoint1Y");
    HumanSpawnPoint[0][2] = GetGVarFloat("HumanSpawnPoint1Z");
    HumanSpawnPoint[0][3] = GetGVarFloat("HumanSpawnPoint1A");
   
    HumanSpawnPoint[1][0] = GetGVarFloat("HumanSpawnPoint2X");
    HumanSpawnPoint[1][1] = GetGVarFloat("HumanSpawnPoint2Y");
    HumanSpawnPoint[1][2] = GetGVarFloat("HumanSpawnPoint2Z");
    HumanSpawnPoint[1][3] = GetGVarFloat("HumanSpawnPoint2A");
   
    HumanSpawnPoint[2][0] = GetGVarFloat("HumanSpawnPoint3X");
    HumanSpawnPoint[2][1] = GetGVarFloat("HumanSpawnPoint3Y");
    HumanSpawnPoint[2][2] = GetGVarFloat("HumanSpawnPoint3Z");
    HumanSpawnPoint[2][3] = GetGVarFloat("HumanSpawnPoint3A");
    printf("Test2: %f, %f, %f, %f", HumanSpawnPoint[2][0], HumanSpawnPoint[2][1], HumanSpawnPoint[2][2], HumanSpawnPoint[2][3]);
   
    HumanSpawnPoint[3][0] = GetGVarFloat("HumanSpawnPoint4X");
    HumanSpawnPoint[3][1] = GetGVarFloat("HumanSpawnPoint4Y");
    HumanSpawnPoint[3][2] = GetGVarFloat("HumanSpawnPoint4Z");
    HumanSpawnPoint[3][3] = GetGVarFloat("HumanSpawnPoint4A");
   
    HumanSpawnPoint[4][0] = GetGVarFloat("HumanSpawnPoint5X");
    HumanSpawnPoint[4][1] = GetGVarFloat("HumanSpawnPoint5Y");
    HumanSpawnPoint[4][2] = GetGVarFloat("HumanSpawnPoint5Z");
    HumanSpawnPoint[4][3] = GetGVarFloat("HumanSpawnPoint5A");
}
Map map FS(Related codes to debug only)
pawn Код:
new Float:EscapeEntranceGateCoord[3][2][3] =
{
    {
        {1810.935791, -1424.656738, 16.111074},
        {1812.689208, -1424.660278, 16.111612}
    },
    {
        {1986.290649, -1525.501098, 24.934429},
        {1986.214477, -1527.268920, 24.932504}
    },
    {
        {1973.812011, -1241.875122, 24.465534},
        {1975.552001, -1241.647094, 24.465539}
    }
};

new Float:HumanSpawnPoint[5][4] =
{
    {1907.5391, -1570.3154, 22.2424, 182.7103},
    {2044.2927, -1400.1689, 84.3743, 84.3338},
    {1976.0824, -1282.5011, 38.5050, 17.3310},
    {1909.7496, -1301.6178, 69.2367, 130.3235},
    {1819.6625, -1413.5164, 29.8772, 180.4687}
};

public Map()
{
//This functionis called at OnFilterScriptInit
//This function contains the createobject function
    SetTimer("GlobaliseVariable", 1, false);
}

public GlobaliseVariable()
{
    SetGVarFloat("EscapeEntrance1Gate1CoordX", EscapeEntranceGateCoord[0][0][0]);
    SetGVarFloat("EscapeEntrance1Gate1CoordY", EscapeEntranceGateCoord[0][0][1]);
    SetGVarFloat("EscapeEntrance1Gate1CoordZ", EscapeEntranceGateCoord[0][0][2]);

    SetGVarFloat("EscapeEntrance1Gate2CoordX", EscapeEntranceGateCoord[0][1][0]);
    SetGVarFloat("EscapeEntrance1Gate2CoordY", EscapeEntranceGateCoord[0][1][1]);
    SetGVarFloat("EscapeEntrance1Gate2CoordZ", EscapeEntranceGateCoord[0][1][2]);

    SetGVarFloat("EscapeEntrance2Gate1CoordX", EscapeEntranceGateCoord[1][0][0]);
    SetGVarFloat("EscapeEntrance2Gate1CoordY", EscapeEntranceGateCoord[1][0][1]);
    SetGVarFloat("EscapeEntrance2Gate1CoordZ", EscapeEntranceGateCoord[1][0][2]);

    SetGVarFloat("EscapeEntrance2Gate2CoordX", EscapeEntranceGateCoord[1][1][0]);
    SetGVarFloat("EscapeEntrance2Gate2CoordY", EscapeEntranceGateCoord[1][1][1]);
    SetGVarFloat("EscapeEntrance2Gate2CoordZ", EscapeEntranceGateCoord[1][1][2]);

    SetGVarFloat("EscapeEntrance3Gate1CoordX", EscapeEntranceGateCoord[2][0][0]);
    SetGVarFloat("EscapeEntrance3Gate1CoordY", EscapeEntranceGateCoord[2][0][1]);
    SetGVarFloat("EscapeEntrance3Gate1CoordZ", EscapeEntranceGateCoord[2][0][2]);

    SetGVarFloat("EscapeEntrance3Gate2CoordX", EscapeEntranceGateCoord[2][1][0]);
    SetGVarFloat("EscapeEntrance3Gate2CoordY", EscapeEntranceGateCoord[2][1][1]);
    SetGVarFloat("EscapeEntrance3Gate2CoordZ", EscapeEntranceGateCoord[2][1][2]);


    SetGVarFloat("HumanSpawnPoint1X", HumanSpawnPoint[0][0]);
    SetGVarFloat("HumanSpawnPoint1Y", HumanSpawnPoint[0][1]);
    SetGVarFloat("HumanSpawnPoint1Z", HumanSpawnPoint[0][2]);
    SetGVarFloat("HumanSpawnPoint1A", HumanSpawnPoint[0][3]);

    SetGVarFloat("HumanSpawnPoint2X", HumanSpawnPoint[1][0]);
    SetGVarFloat("HumanSpawnPoint2Y", HumanSpawnPoint[1][1]);
    SetGVarFloat("HumanSpawnPoint2Z", HumanSpawnPoint[1][2]);
    SetGVarFloat("HumanSpawnPoint2A", HumanSpawnPoint[1][3]);

    SetGVarFloat("HumanSpawnPoint3X", HumanSpawnPoint[2][0]);
    SetGVarFloat("HumanSpawnPoint3Y", HumanSpawnPoint[2][1]);
    SetGVarFloat("HumanSpawnPoint3Z", HumanSpawnPoint[2][2]);
    SetGVarFloat("HumanSpawnPoint3A", HumanSpawnPoint[2][3]);

    SetGVarFloat("HumanSpawnPoint4X", HumanSpawnPoint[3][0]);
    SetGVarFloat("HumanSpawnPoint4Y", HumanSpawnPoint[3][1]);
    SetGVarFloat("HumanSpawnPoint4Z", HumanSpawnPoint[3][2]);
    SetGVarFloat("HumanSpawnPoint4A", HumanSpawnPoint[3][3]);

    SetGVarFloat("HumanSpawnPoint5X", HumanSpawnPoint[4][0]);
    SetGVarFloat("HumanSpawnPoint5Y", HumanSpawnPoint[4][1]);
    SetGVarFloat("HumanSpawnPoint5Z", HumanSpawnPoint[4][2]);
    SetGVarFloat("HumanSpawnPoint5A", HumanSpawnPoint[4][3]);
}
Server Log
Код:
[01:49:58]   Filterscript 'theparkoutbreak.amx' loaded.
[01:49:58] Test: 0.000000, 0.000000, 0.000000
[01:49:58] Test2: 0.000000, 0.000000, 0.000000, 0.000000
[01:49:58]
The map was loaded but the global vars don't work
What did I do wrong? I think it's the code sequence


Re: Help with Incognito's GVar Plugin - ikkentim - 24.11.2013

Why are you calling public GlobaliseVariable() on a timer? (Thats the reason of the issue)

Replace SetTimer("GlobaliseVariable", 1, false); with GlobalVariable
There is pretty much useless calling it on a 1ms timer here.

Please show us the code where you read the name of the map if you want the first-2-chars problem to be fixed.

If you remove the first to spaces in front of the FS im pretty sure it will just work.


Re: Help with Incognito's GVar Plugin - SlonCHL - 24.11.2013

Quote:
Originally Posted by ikkentim
Посмотреть сообщение
Why are you calling public GlobaliseVariable() on a timer? (Thats the reason of the issue)

Replace SetTimer("GlobaliseVariable", 1, false); with GlobalVariable
There is pretty much useless calling it on a 1ms timer here.

Please show us the code where you read the name of the map if you want the first-2-chars problem to be fixed.

If you remove the first to spaces in front of the FS im pretty sure it will just work.
You sure thats the issue?? Thought theres no differences, I didnt want to mix the map and global vars so I did it in a new function

Right there at public LoadMap(), first few lines and err no, if I remove the spaces, I cant even load the map cause the command is load an invalidfs


Re: Help with Incognito's GVar Plugin - SlonCHL - 25.11.2013

Bump, didn't solve the issue

pawn Код:
public Map()
{
//This functionis called at OnFilterScriptInit
//This function contains the createobject function
    SetGVarFloat("EscapeEntrance1Gate1CoordX", EscapeEntranceGateCoord[0][0][0]);
    SetGVarFloat("EscapeEntrance1Gate1CoordY", EscapeEntranceGateCoord[0][0][1]);
    SetGVarFloat("EscapeEntrance1Gate1CoordZ", EscapeEntranceGateCoord[0][0][2]);

    SetGVarFloat("EscapeEntrance1Gate2CoordX", EscapeEntranceGateCoord[0][1][0]);
    SetGVarFloat("EscapeEntrance1Gate2CoordY", EscapeEntranceGateCoord[0][1][1]);
    SetGVarFloat("EscapeEntrance1Gate2CoordZ", EscapeEntranceGateCoord[0][1][2]);

    SetGVarFloat("EscapeEntrance2Gate1CoordX", EscapeEntranceGateCoord[1][0][0]);
    SetGVarFloat("EscapeEntrance2Gate1CoordY", EscapeEntranceGateCoord[1][0][1]);
    SetGVarFloat("EscapeEntrance2Gate1CoordZ", EscapeEntranceGateCoord[1][0][2]);

    SetGVarFloat("EscapeEntrance2Gate2CoordX", EscapeEntranceGateCoord[1][1][0]);
    SetGVarFloat("EscapeEntrance2Gate2CoordY", EscapeEntranceGateCoord[1][1][1]);
    SetGVarFloat("EscapeEntrance2Gate2CoordZ", EscapeEntranceGateCoord[1][1][2]);

    SetGVarFloat("EscapeEntrance3Gate1CoordX", EscapeEntranceGateCoord[2][0][0]);
    SetGVarFloat("EscapeEntrance3Gate1CoordY", EscapeEntranceGateCoord[2][0][1]);
    SetGVarFloat("EscapeEntrance3Gate1CoordZ", EscapeEntranceGateCoord[2][0][2]);

    SetGVarFloat("EscapeEntrance3Gate2CoordX", EscapeEntranceGateCoord[2][1][0]);
    SetGVarFloat("EscapeEntrance3Gate2CoordY", EscapeEntranceGateCoord[2][1][1]);
    SetGVarFloat("EscapeEntrance3Gate2CoordZ", EscapeEntranceGateCoord[2][1][2]);


    SetGVarFloat("HumanSpawnPoint1X", HumanSpawnPoint[0][0]);
    SetGVarFloat("HumanSpawnPoint1Y", HumanSpawnPoint[0][1]);
    SetGVarFloat("HumanSpawnPoint1Z", HumanSpawnPoint[0][2]);
    SetGVarFloat("HumanSpawnPoint1A", HumanSpawnPoint[0][3]);

    SetGVarFloat("HumanSpawnPoint2X", HumanSpawnPoint[1][0]);
    SetGVarFloat("HumanSpawnPoint2Y", HumanSpawnPoint[1][1]);
    SetGVarFloat("HumanSpawnPoint2Z", HumanSpawnPoint[1][2]);
    SetGVarFloat("HumanSpawnPoint2A", HumanSpawnPoint[1][3]);

    SetGVarFloat("HumanSpawnPoint3X", HumanSpawnPoint[2][0]);
    SetGVarFloat("HumanSpawnPoint3Y", HumanSpawnPoint[2][1]);
    SetGVarFloat("HumanSpawnPoint3Z", HumanSpawnPoint[2][2]);
    SetGVarFloat("HumanSpawnPoint3A", HumanSpawnPoint[2][3]);

    SetGVarFloat("HumanSpawnPoint4X", HumanSpawnPoint[3][0]);
    SetGVarFloat("HumanSpawnPoint4Y", HumanSpawnPoint[3][1]);
    SetGVarFloat("HumanSpawnPoint4Z", HumanSpawnPoint[3][2]);
    SetGVarFloat("HumanSpawnPoint4A", HumanSpawnPoint[3][3]);

    SetGVarFloat("HumanSpawnPoint5X", HumanSpawnPoint[4][0]);
    SetGVarFloat("HumanSpawnPoint5Y", HumanSpawnPoint[4][1]);
    SetGVarFloat("HumanSpawnPoint5Z", HumanSpawnPoint[4][2]);
    SetGVarFloat("HumanSpawnPoint5A", HumanSpawnPoint[4][3]);
}
EDIT
Nevermind, solved it, I was right is was the timing problem. Should wait for the whole filterscript to load first before doing anything with it