Leveling system not saving the playing minutes. -
Hello again.. Asking many help today i know. xD
Been making the leveling system, i want it to each 60 seconds add 1 playing minute, than if it is 60 minutes, 1 playing hour and 1 respect point and reset minutes to 0.
Actualy, it is not saving in the file, either showing in /stats. I guess it's maybe something on the timer.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{F81414}Register", "{FFFFFF}Your account doesn't exist in our database, please insert a password below, to start the registration.", "Register", "Quit");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel", PlayerInfo[playerid][AdminLevel] = 0);
dini_IntSet(file, "VipLevel", PlayerInfo[playerid][VipLevel] = 0);
dini_IntSet(file, "Money", GivePlayerMoney(playerid, 500));
dini_IntSet(file, "Score", SetPlayerScore(playerid, 1));
dini_IntSet(file, "Warns", PlayerInfo[playerid][Warns] = 0);
dini_IntSet(file, "Job", PlayerInfo[playerid][Job] = 0);
dini_IntSet(file, "CarRent", PlayerInfo[playerid][CarRent] = 0);
dini_IntSet(file, "Faction", PlayerInfo[playerid][Faction] = 0);
dini_IntSet(file, "FactionRank", PlayerInfo[playerid][FactionRank] = 0);
dini_IntSet(file, "BankAccounts", PlayerInfo[playerid][BankAccounts] = 0);
dini_IntSet(file, "HouseKey", PlayerInfo[playerid][HouseKey] = 9999);
dini_IntSet(file, "BusinessKey", PlayerInfo[playerid][BusinessKey] = 9999);
dini_IntSet(file, "Car1Key", PlayerInfo[playerid][Car1Key] = 9999);
dini_IntSet(file, "Car2Key", PlayerInfo[playerid][Car2Key] = 9999);
dini_IntSet(file, "Car3Key", PlayerInfo[playerid][Car3Key] = 9999);
dini_IntSet(file, "Car4Key", PlayerInfo[playerid][Car4Key] = 9999);
dini_IntSet(file, "Car5Key", PlayerInfo[playerid][Car5Key] = 9999);
dini_IntSet(file, "Car6Key", PlayerInfo[playerid][Car6Key] = 9999);
dini_IntSet(file, "Jailed", PlayerInfo[playerid][Jailed] = 0);
dini_IntSet(file, "Jail", PlayerInfo[playerid][Jail] = 0);
dini_IntSet(file, "Phone", PlayerInfo[playerid][Phone] = 0);
dini_IntSet(file, "PhoneNumber", PlayerInfo[playerid][PhoneNumber] = 00000000);
dini_IntSet(file, "GPS", PlayerInfo[playerid][GPS] = 1);
dini_IntSet(file, "Duty", PlayerInfo[playerid][Duty] = 0);
dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
dini_IntSet(file, "PlayingHours", PlayerInfo[playerid][PlayingHours] = 0);
dini_IntSet(file, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes] = 0);
dini_IntSet(file, "RespectPoints", PlayerInfo[playerid][RespectPoints] = 0);
SendClientMessage(playerid, COLOR_INDIGO, "Your account is now registred in our database. Welcome to Ricardo's Role-Play.");
IsLogged[playerid] = 1;
SpawnPlayer(playerid);
new string[64];
format(string, sizeof(string), "%s has logged in.", Name);
SendClientMessageToAll(COLOR_GREEN, string);
SetTimer("PlayingTime", 60000, true);
}
if (dialogid == 2)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{F81414}Login", "{FFFFFF}Your account has been found in our database. Please insert your password below to login.", "Login", "Quit");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_INDIGO, "Wrong PW sir.");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "{F81414}Login", "{FFFFFF}Your account has been found in our database. Please insert your password below to login.", "Login", "Quit");
}
else
{
IsLogged[playerid] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
PlayerInfo[playerid][VipLevel] = dini_Int(file, "VipLevel");
SetPlayerMoney(playerid, dini_Int(file, "Money"));
SetPlayerScore(playerid, dini_Int(file, "Score"));
PlayerInfo[playerid][Warns] = dini_Int(file, "Warns");
PlayerInfo[playerid][Job] = dini_Int(file, "Job");
PlayerInfo[playerid][CarRent] = dini_Int(file, "CarRent");
PlayerInfo[playerid][Faction] = dini_Int(file, "Faction");
PlayerInfo[playerid][FactionRank] = dini_Int(file, "FactionRank");
PlayerInfo[playerid][BankAccounts] = dini_Int(file, "BankAccounts");
PlayerInfo[playerid][HouseKey] = dini_Int(file, "HouseKey");
PlayerInfo[playerid][BusinessKey] = dini_Int(file, "BusinessKey");
PlayerInfo[playerid][Car1Key] = dini_Int(file, "Car1Key");
PlayerInfo[playerid][Car2Key] = dini_Int(file, "Car2Key");
PlayerInfo[playerid][Car3Key] = dini_Int(file, "Car3Key");
PlayerInfo[playerid][Car4Key] = dini_Int(file, "Car4Key");
PlayerInfo[playerid][Car5Key] = dini_Int(file, "Car5Key");
PlayerInfo[playerid][Car6Key] = dini_Int(file, "Car6Key");
PlayerInfo[playerid][Jailed] = dini_Int(file, "Jailed");
PlayerInfo[playerid][Jail] = dini_Int(file, "Jail");
PlayerInfo[playerid][Phone] = dini_Int(file, "Phone");
PlayerInfo[playerid][PhoneNumber] = dini_Int(file, "PhoneNumber");
PlayerInfo[playerid][GPS] = dini_Int(file, "GPS");
PlayerInfo[playerid][Duty] = dini_Int(file, "Duty");
SetPlayerSkin(playerid, dini_Int(file, "Skin"));
PlayerInfo[playerid][Skin] = dini_Int(file, "Skin");
PlayerInfo[playerid][PlayingHours] = dini_Int(file, "PlayingHours");
PlayerInfo[playerid][PlayingMinutes] = dini_Int(file, "PlayingMinutes");
PlayerInfo[playerid][RespectPoints] = dini_Int(file, "RespectPoints");
SendClientMessage(playerid, COLOR_INDIGO, "You have sucefull logged in. Welcome back to Ricardo's Role-Play.");
SpawnPlayer(playerid);
new string[64];
format(string, sizeof(string), "%s has logged in.", Name);
SendClientMessageToAll(COLOR_GREEN, string);
SetTimer("PlayingTime", 60000, true);
}
}
return 1;
}
forward PlayingTime(playerid);
public PlayingTime(playerid)
{
PlayerInfo[playerid][PlayingMinutes] = PlayerInfo[playerid][PlayingMinutes]+1;
if(PlayerInfo[playerid][PlayingMinutes] >= 60)
{
PlayerInfo[playerid][PlayingHours] = PlayerInfo[playerid][PlayingHours]+1;
PlayerInfo[playerid][RespectPoints] = PlayerInfo[playerid][RespectPoints]+1;
PlayerInfo[playerid][PlayingMinutes] = 0;
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "PlayingHours", PlayerInfo[playerid][PlayingHours]);
dini_IntSet(file, "RespectPoints", PlayerInfo[playerid][RespectPoints]);
dini_IntSet(file, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes]);
}
return 1;
}
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "PlayingMinutes", PlayerInfo[playerid][PlayingMinutes]);
}
return 0;
}
CMD:levelup(playerid, params[])
{
if(PlayerInfo[playerid][RespectPoints] >= 10)
{
SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
PlayerInfo[playerid][RespectPoints] = PlayerInfo[playerid][RespectPoints]-10;
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
format(file, sizeof(file), "RRP/users/%s.ini", Name);
if(fexist(file))
{
dini_IntSet(file, "RespectPoints", PlayerInfo[playerid][RespectPoints]);
}
SendClientMessage(playerid, COLOR_LIGHTRED, "You've just level up.");
return 1;
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have enough Respect Points.");
}
AW: Leveling system not saving the playing minutes. -
Your code is confusing me. Try this.
Re: Leveling system not saving the playing minutes. -
I added the SetTimer after the player login.. It's on the code i gave.
AW: Leveling system not saving the playing minutes. -
EDIT: You made a global timer, repeating for Everyone. This is a timer only for "playerid", repeating set to "true", and every 60 seconds.
Re: Leveling system not saving the playing minutes. -
Every 6 minutes??, why dont you use a time system for this so you can work out down to the second how long they have played for.
Re: Leveling system not saving the playing minutes. -
60000 is actualy 60 seconds, that is 1 minute.
The problem is finaly solved. Thanks to everyone.