02.11.2013, 07:19
hi guys, I've made a exp/level system
You get one exp each hour, once you hit 6/6 you can level up.
There are the following codes I added on my server
In-game It works fine like you can level up each hour/with command /buylevel you can level up.
but when i relog they're all gone so i want them to be saved.
Yes, these are it, Just the player data isn't saving on my ini file it shows me level,exp but the value is always 0 doesn't update at all.
Can someone tell me what I did wrong or fix it for me?
http://pastebin.com/kFj8J9FF -> The place where I've got this system, can someone convert it to my function.
Once again screw if you find syntax errors, I get only warnings, in game the level system works fine, just the thing is it doesn't save at all!
You get one exp each hour, once you hit 6/6 you can level up.
There are the following codes I added on my server
In-game It works fine like you can level up each hour/with command /buylevel you can level up.
but when i relog they're all gone so i want them to be saved.
Код:
enum Info { pLevel, pExp, };
Код:
new ScoreOld; new levelexp = 1;
Код:
forward ScoreUpdate(); forward PayDay(playerid);
Код:
public ScoreUpdate() { new Score; new name[MAX_PLAYER_NAME]; //new string[256]; for(new i=0; i<MAX_PLAYERS; i++) { if (IsPlayerConnected(i)) { GetPlayerName(i, name, sizeof(name)); Score = PlayerInfo[i][pLevel]; SetPlayerScore(i, Score); if (Score > ScoreOld) { ScoreOld = Score; } } } }
Код:
public OnPlayerConnect(playerid) { PlayerInfo[playerid][pLevel] = 1; PlayerInfo[playerid][pExp] = 0; return 1; }
Код:
COMMAND:buylevel(playerid,params[]) { new nxtlevel = PlayerInfo[playerid][pLevel]+5; new expamount = nxtlevel*levelexp; new string[30]; // String. if(IsPlayerConnected(playerid) == 1) // Checks if player is connected. { new points[248]; // Points. if(PlayerInfo[playerid][pExp] < expamount) // Checks if player's exp amount is above the required one or not. { format(points,sizeof(points)," You need [%d] Exp Points in order to level up, You currently have [%d]",expamount,PlayerInfo[playerid][pExp]); // Format, This is pretty obvious. SendClientMessage(playerid,COLOR_GREEN,points); // Sends the message. return 1; } else { PlayerInfo[playerid][pExp] = 0; // Sets the EXP amount to 0 as you level'd up. PlayerInfo[playerid][pLevel]++; // Adds a level. format(string,sizeof(string),"~g~Your now level:[%d]",PlayerInfo[playerid][pLevel]); // Format. GameTextForPlayer(playerid,string,6000,1); // Sends gametext about his new level'ing up. return 1; } } return 1; }
Код:
forward OnPlayerLogin(playerid,password[]);
Код:
public OnPlayerLogin(playerid,password[]) { if(GetPVarInt(playerid, "PlayerLogged") != 0) return true; new string[128]; format(string, sizeof(string), "users/%s.ini", PlayerName(playerid)); Hash(password); if(strcmp(DOF2_GetString(string, "Key"), password, true) == 0) { if(DOF2_GetInt(string, "Convert") != 5) return Kick(playerid); // Load Ints // SetPVarInt(playerid, "pLevel", DOF2_GetInt(string, "level")); SetPVarInt(playerid, "pExp", DOF2_GetInt(string, "Exp")); new score = PlayerInfo[playerid][pLevel]; SetPlayerScore(playerid, score); // END brackets are all fine no syntax errors.
Код:
forward OnPlayerDataSave(playerid);
Код:
public OnPlayerDataSave(playerid) { if(IsPlayerConnected(playerid) && GetPVarInt(playerid, "PlayerLogged") == 1) { new string[128]; format(string, sizeof(string), "users/%s.ini", PlayerName(playerid)); if(DOF2_FileExists(string)) { DOF2_SetInt(string, "level", GetPVarInt(playerid, "level")); DOF2_SetInt(string, "Exp", GetPVarInt(playerid, "Exp")); } return 0 } }
Can someone tell me what I did wrong or fix it for me?
http://pastebin.com/kFj8J9FF -> The place where I've got this system, can someone convert it to my function.
Once again screw if you find syntax errors, I get only warnings, in game the level system works fine, just the thing is it doesn't save at all!