Level and Exp system
#1

Hey i have a problem with a Level and Exp when i type /buylevel it give me level up but when i disconect form de server and i go back on it i don't have the level

Код:
CMD:buylevel(playerid,params[])
{
		new string[30]; 
		if(IsPlayerConnected(playerid) == 1) 
	    {
	        new points[248]; 
            new nxtlevel = Player[playerid][pLevel]+1; 
    		new expamount = nxtlevel*levelexp; 
	        if(Player[playerid][pExp] < expamount) 
	        {
				format(points,sizeof(points)," You need [%d] Exp Points in order to level up, You currently have [%d]",expamount,Player[playerid][pExp]); // Format, This is pretty obvious.
				SendClientMessage(playerid,0xFFFFFFC8,points);
				return 1;
			}
			else
			{
				Player[playerid][pExp] = 0; 
				Player[playerid][pLevel]++; 
				format(string,sizeof(string),"~g~Your now level:[%d]",Player[playerid][pLevel]); 
				GameTextForPlayer(playerid,string,6000,1);
				SavePlayer(playerid);
				return 1;
			}
		}
		return 1;
}
Код:
forward ScoreUpdate();
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 = Player[i][pLevel];
			SetPlayerScore(i, Score);
			if (Score > ScoreOld)
			{
				ScoreOld = Score;
			}
		}
	}
}
I use MySQL!!!
Reply
#2

Its a problem with your SQL Tables
Reply
#3

I have a stock to save the player account
Код:
stock SavePlayer(playerid)
{
	new query[356], EncryptedPass[130];
	
	WP_Hash(EncryptedPass, sizeof(EncryptedPass), Player[playerid][pPassword]);

	GetPlayerPos(playerid, Player[playerid][pPosition][0], Player[playerid][pPosition][1], Player[playerid][pPosition][2]);
	
	format(query, sizeof(query), "UPDATE accounts SET pName = '%s', pPassword = '%s', pAdminLevel = %d, pPlayerPos = '%f %f %f', pSkin=%d, pMoney = %d, pVip = %d, pMuted = %d, pWarnings = %d, pWarningReasons = '%s|%s|%s', pLevel = %d, pExp = %d WHERE pid = %d", GetName(playerid), Player[playerid][pPassword], Player[playerid][pAdminLevel], Player[playerid][pPosition][0], Player[playerid][pPosition][1], 
	Player[playerid][pPosition][0], Player[playerid][pSkin], Player[playerid][pMoney], Player[playerid][pvStatus], Player[playerid][pMuted], Player[playerid][pWarnings], Player[playerid][pWarningReason1], Player[playerid][pWarningReason2], Player[playerid][pWarningReason3], Player[playerid][pLevel], Player[playerid][pExp], Player[playerid][pID]);
	mysql_query(query);
	printf(query);
	
	printf("Player ID %d (%s) has been saved", playerid, GetName(playerid));
}
Reply
#4

Show the printf
Reply
#5

Reply
#6

Quote:
Originally Posted by MrAlexisX2
Посмотреть сообщение
Show the printf
Reply
#7

I had this problem before and I fixed it extremely easily, but I'm not sure if this will work for you.
I simply changed
Код:
Player[playerid][pLevel]++;
to
Код:
Player[playerid][pLevel] += 1;
Reply
#8

Okay, change :
PHP код:
new query[356]; 
By :
PHP код:
new query[1024]; 
Reply
#9

Quote:
Originally Posted by AnoTek
Посмотреть сообщение
Код:
forward ScoreUpdate();
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 = Player[i][pLevel];
			SetPlayerScore(i, Score);
			if (Score > ScoreOld)
			{
				ScoreOld = Score;
			}
		}
	}
}
Why, why, why?

Just use a hook for SetPlayerScore and do the code there, why are using a timer which is completely useless at this case? When you can easily track changed score directly from the script?
Reply
#10

Quote:
Originally Posted by MrAlexisX2
Посмотреть сообщение
Okay, change :
PHP код:
new query[356]; 
By :
PHP код:
new query[1024]; 
Thank you so much bro repp+ it works now but can you explain me why i need to chenge that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)