Saving a players score and money. -
Odyssey - 02.07.2011
Ok, so I am using a script called SAdmin, yeh yeh, look at all my other scripts I have been requesting help for gAdmin, LuxAdmin, LAdmin etc.....
But I need this to save score and money, and it dose to, when I dissconect, and go into the scriptfiles, the score is saved, but when I log on, it sets it to 0. And when I also get some cash, asoon as I get it, the cash goes up to the ammount I recieved then sets back to 0.
Here is my script.
http://pastebin.com/GniVi2Nh
The only command I added is /setscore.
Re: Saving a players score and money. -
Odyssey - 02.07.2011
Anyone?
Re: Saving a players score and money. -
iPLEOMAX - 02.07.2011
Read UserFiles OnPlayerConnect to load the stats.
If you managed to save it, hopefully you can 'read' and 'set' it...
Stats don't load automatically.
Re: Saving a players score and money. -
Odyssey - 02.07.2011
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFF00}Virtual Pilots register.", "Please register a account to play!", "Register", "Quit");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 5000);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
dini_IntSet(file, "Warns",PlayerInfo[playerid][pWarns] = 1);
dini_IntSet(file, "Banned",PlayerInfo[playerid][pBanned] = 0);
dini_IntSet(file, "Muted",PlayerInfo[playerid][pMuted] = 0);
dini_IntSet(file, "Jailed",PlayerInfo[playerid][pJailed] = 0);
dini_IntSet(file, "MuteWarns",PlayerInfo[playerid][pMuteWarns] = 1);
dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin]);
dini_IntSet(file, "Kills",PlayerInfo[playerid][pKills]);
dini_IntSet(file, "Deaths",PlayerInfo[playerid][pDeaths]);
dini_IntSet(file, "Spam",PlayerInfo[playerid][pSpam] = 0);
SetPVarString(playerid,"Tags","<none>");
SetPVarInt(playerid,"Register",1);
new none[30] = "<none>";
dini_Set(file, "Tags", none);
format(string, 128, "Welcome to the server! You have registered the account {80FF00}%s", name);
SendClientMessage(playerid, COLOR_YELLOW, string);
gPlayerLogged[playerid] = 1;
welcomehide(playerid);
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFF00}Virtual Pilots login.", "Welcome back! Please login to continue!", "Login", "Quit");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
if(Logins[playerid] == 3) {
new tt[128];
format(tt,sizeof(tt),"{80FF00}%s {FFFFFF}was kicked for to many wrong passwords.",name);
SendClientMessageToAll(red,tt);
return Kick(playerid);
}
new textah[256];
format(textah,sizeof(textah),"Incorrect password. Please try again. %i/3",Logins[playerid]);
SendClientMessage(playerid, COLOR_RED, textah);
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{FFFF00}Virtual Pilots login.", "Wrong Password! Please try again!", "Login", "Quit");
Logins[playerid]++;
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
GetPlayerName(playerid,OrName[playerid],20);
SetPlayerScore(playerid, PlayerInfo[playerid][pScore]);
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid,medblue, "You have successfully logged in!");
if(PlayerInfo[playerid][pAdminLevel] >= 1) {
new atext[128];
format(atext,sizeof(atext),"Level: %i",PlayerInfo[playerid][pAdminLevel]);
SendClientMessage(playerid,lime,atext);
}
welcomehide(playerid);
}
}
if(dialogid == 5) {
new dtext[128];
#pragma unused dtext
if(listitem == 1) {
if(PlayerInfo[playerid][pAdminLevel] >= 2) {
ShowPlayerDialog(playerid,6,DIALOG_STYLE_INPUT,"Reason","Type the reason here:","Go","Cancel");
} else {
return SendClientMessage(playerid,red,"This command only for lvl2 or higher.");
}
}
}
return 1;
}
I got this
Re: Saving a players score and money. -
Shadoww5 - 02.07.2011
Post
OnPlayerConnect.
Re: Saving a players score and money. -
Odyssey - 02.07.2011
Its all there in the pastebin
Re: Saving a players score and money. -
Seven_of_Nine - 02.07.2011
Fixed, I'll probably do a lil' update on the SAdmin topic.
Re: Saving a players score and money. -
Gazmull - 02.07.2011
You must load the account stats at OnPlayerSpawn or in Login == 1 or something depends on your script.