OnPlayerDisconnect
#1

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;
}
Reply
#2

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.
Reply
#3

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

*bump
Reply
#5

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

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


Forum Jump:


Users browsing this thread: