SA-MP Forums Archive
OnPlayerDisconnect - 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: OnPlayerDisconnect (/showthread.php?tid=459301)



OnPlayerDisconnect - detter - 22.08.2013

How can i save variables using for loop when player disconnects ?

Код:
// this doesn't work ;not one piece of data gets saved

#define ABC    10

enum Player
{
     something,
     data[ABC],
};
new pInfo[MAX_PLAYERS][Player];

OnPlayerDisconnect(playerid, reason)
{
    new str[20];
    new INI:File = .....

    INI_WriteInt(File ,"BlaBla" ,pInfo[playerid][something]);    

    for(new i = 0; i < ABC ; i++)
    {
        format(str ,sizeof(str) ,"test_%i" ,i);
        INI_WriteInt(File ,str ,pInfo[playerid][data][i]);
    }
    return 1;
}



Re: OnPlayerDisconnect - Lordzy - 22.08.2013

Quote:
Originally Posted by detter
Посмотреть сообщение
How can i save variables using for loop when player disconnects ?
As per the code you've used, it'd be kinda like this:
pawn Код:
new something[128];
new somestuff[MAX_PLAYERS];

public OnPlayerDisconnect(playerid, reason)
{
 new str[50];
 if(!fexist("Test.ini")) return 0;
 new INI:file = INI_Open("Test.ini");
 INI_SetTag(file, "Test");
 for(new i; i< 10; i++)
 {
  format(str, sizeof(str),   "Test_%d", i);
  INI_WriteInt(file, str, somestuff[playerid]);
  format(str, sizeof(str), "str_%d", i);
  INI_WriteString(file, str, something, 128);
 }
 INI_Close(file);
 return 1;
}
I haven't tested, but this is how it goes.


Re: OnPlayerDisconnect - detter - 22.08.2013

still the same ... i think that problem is in using for loop in onplayerdisconnect ... is there any alternative ?


Re: OnPlayerDisconnect - detter - 22.08.2013

*bump


Re: OnPlayerDisconnect - Edix - 22.08.2013

Problem might be that you're trying to loop the enum so I dont think its possiable.


Re: OnPlayerDisconnect - detter - 22.08.2013

i have commands that loop trough em and they work fine...