SA-MP Forums Archive
Function being called over and over again - 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: Function being called over and over again (/showthread.php?tid=599509)



Function being called over and over again - Amads - 26.01.2016

Hello!
I've made a similiar topic a day ago but the problem has changed.

For some reason this function (located in OnPlayerConnect) gets called A LOT of times for no reason, when it clearly should execute only once.
Код:
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
        AktywnyDialog[playerid] = 2;
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_PASSWORD,"Logowanie","{FFA500}* * * LOGOWANIE\n\n{FFFFFF}Witamy ponownie, wpisz swoje {FF0000}hasło{FFFFFF}, aby się zalogować.\n","Zaloguj","Wyjdź");
    }
Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    printf("* test");
    return 1;
}
Logs:
Код:
[22:34:26] [join] Amads has joined the server (0:127.0.0.1)
[22:34:26] * test
[22:34:26] * test
[22:34:26] * test
[22:34:26] * test
[22:34:26] * test
[22:34:26] * test
[22:34:26] * test
And it goes on and on...



Re: Function being called over and over again - AmigaBlizzard - 26.01.2016

I'm no expert in INI-parsers, but my guess would be that function is called everytime there is a parameter-entry in the file below the [data] block.

How many times does it run, and how many lines are usually stored in your playerfile?

Wouldn't such a function determine which parameter is read (name), along with it's value (value), so you can take appropriate action?

Try to add this in that function:
PHP код:
printf("Name = %s"name);
printf("Value = %s"value); 
And see what it prints.


Re: Function being called over and over again - -CaRRoT - 26.01.2016

Ignore this comment, mistake.