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



Login system - NviDa - 21.12.2014

Hi I have a login system in my server.It works I can register and login etc
I have a stats command but it doesn't show me the stats.It just shows 0 in score,money,kills etc.

What to do?


Re: Login system - UltraScripter - 21.12.2014

look in scriptfiles folder


Re: Login system - NviDa - 21.12.2014

K thanks! Didn't see that :/
What about the /stats command problem?Can you help?


Re: Login system - LivingLikeYouDo - 21.12.2014

Show your /stats command.


Re: Login system - NviDa - 21.12.2014

Код:
CMD:stats(playerid,params[])
{
	new Score = PlayerInfo[playerid][pScore];
    new Cash = PlayerInfo[playerid][pCash];
    new Deaths = PlayerInfo[playerid][pDeaths];
    new Kills = PlayerInfo[playerid][pKills];
    new string[500];
    format(string,sizeof(string),"Score: %i | Cash: %d | Deaths: %d | Kills: %d |",Score,Cash,Deaths,Kills,GetPlayerScore(playerid));
    SendClientMessage(playerid,-1,string);
    return 1;
}



Re: Login system - UltraScripter - 21.12.2014

show the code you saving the cash deaths...
cuz it fine


Re: Login system - NviDa - 21.12.2014

Код:
enum pInfo
{
	pName2,
	pScore,
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Name",PlayerInfo[playerid][pName2]);
	INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    return 1;
}
stock UserPath(playerid)
{
    new string[500],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}
stock udb_hash(buf[]) {
    new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
Note:-I didn't make this login system,took it from a tutorial,I am not at all familiar with enums etc.
And stats cmd was made for me by a friend.


Re: Login system - UltraScripter - 21.12.2014

did u add OnPlayerDisconnect This:
pawn Код:
new INI:YourFile = Open(yourstock(playerid));
dini_WriteInt(yourfile, "cash", GetPlayerMoney(playerid));
//and more stuff like that???
did u add this


Re: Login system - UltraScripter - 21.12.2014

wow sorry my bad
pawn Код:
INI_WriteInt(YourFile, "Cash", GetPlayerMoney(playerid));
Fixed!


Re: Login system - NviDa - 21.12.2014

Yea some what
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteInt(File,"Name",PlayerInfo[playerid][pName2]);
    INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
    INI_Close(File);
	return 1;
}