SA-MP Forums Archive
Help OnPlayerConnect - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help OnPlayerConnect (/showthread.php?tid=178866)



Help OnPlayerConnect - FireCat - 24.09.2010

i have this code that when they disconnect it saves theyr score in a .txt file
but when they connect it should be theyr score = txt file but it remaains 0 but in scriptfiles... they score is has the last time they disconnected help
Код:
public OnPlayerConnect(playerid)
{
    new file[1];
    new name[MAX_PLAYER_NAME];
    format(file, sizeof(file), "mygamemode/users/%s.txt", name);
    SetPlayerScore(playerid, dini_Int(file, "Score"));
    return 1;
}
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    dini_Create(file);
    format(file, sizeof(file), "mygamemode/users/%s.txt", name);
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    return 1;
}
help plz


Re: Help OnPlayerConnect - Seven. - 24.09.2010

I experienced the same problem. Try to run a timer which will set their score each second in the file.


Re: Help OnPlayerConnect - Mauzen - 24.09.2010

In OnPlayerConnect the size of 'file' is too small, it cant store the file path.
Set it to MAX_PLAYER_NAME+25 like in OnPlayerDisconnect.

Edit: +You forgot the GetPlayerName(playerid, name, sizeof(name)); in OnPlayerConnect


Re: Help OnPlayerConnect - NoobScripter1 - 24.09.2010

Well you are setting the score on player connect and i suppose you got a login register system so you need loads players data at login cmd hope it help you


Re: Help OnPlayerConnect - FireCat - 24.09.2010

mauzen i puted this
Quote:

public OnPlayerConnect(playerid)
{
new file [MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
format(file, sizeof(file), "mygamemode/users/%s.txt", name);
SetPlayerScore(playerid, dini_Int(file, "Score"));
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
new file[MAX_PLAYER_NAME+25], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
dini_Create(file);
format(file, sizeof(file), "mygamemode/users/%s.txt", name);
dini_IntSet(file, "Score", GetPlayerScore(playerid));
return 1;
}

still i get the same problem


Re: Help OnPlayerConnect - Voldemort - 24.09.2010

Oghh....
pawn Код:
new file[1];
format(file, sizeof(file), "mygamemode/users/%s.txt", name);
Are you thinking what you do?
How long is file string? I see its 1 character, but I guess "mygamemode/users/%s.txt" isnt one character long it has some 50+-5

you need
pawn Код:
new file[50]; // If I remeber right MAX_PLAYER_NAME == 24;
format(file, sizeof(file), "mygamemode/users/%s.txt", name);



Re: Help OnPlayerConnect - FireCat - 24.09.2010

voldemort do you have msn?


Re: Help OnPlayerConnect - Voldemort - 24.09.2010

Check PM