Problem with level
#1

What is wrong with this command ? When i type /levelup server give`s me 2 level`s..I want to give one level...
When i have level 1 and 4/4 exp i want server to give me level 2 not level 3...


Код:
	if(strcmp(cmd, "/levelup", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(gPlayerLogged[playerid] != 0)
			{
				if(PlayerInfo[playerid][pLevel] >= 0)
				{
					new nxtlevel = PlayerInfo[playerid][pLevel]+1;
					new costlevel = nxtlevel*levelcost;//10k for testing purposes
					new expamount = nxtlevel*levelexp;
					if(PlayerInfo[playerid][pCash] < costlevel)
					{
						format(string, sizeof(string), "   You can't afford that ($%d) !",costlevel);
						SendClientMessage(playerid, COLOR_GREY, string);
						return 1;
					}
					else if(PlayerInfo[playerid][pExp] < expamount)
					{
						format(string, sizeof(string), "   You need %d respect points, you curently have %d !",expamount,PlayerInfo[playerid][pExp]);
						SendClientMessage(playerid, COLOR_GREY, string);
						return 1;
					}
					else
					{
						format(string, sizeof(string), "~r~Level up~n~~w~level %d", nxtlevel);
						PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
						if(PlayerInfo[playerid][pLevel] >= 0)
						{
						PlayerInfo[playerid][pLevel]++;
						PlayerInfo[playerid][gPupgrade] = PlayerInfo[playerid][gPupgrade]+5;
						PlayerInfo[playerid][pLevel]++;
						format(string, sizeof(string), "((Ai facut level %d,felicitari !))", nxtlevel);
						SendClientMessage(playerid, COLOR_YELLOW, string);
						format(string, sizeof(string), "%d ..",PlayerInfo[playerid][gPupgrade]);
						SendClientMessage(playerid, COLOR_YELLOW, string);
						}
						else
						{
						PlayerInfo[playerid][pExp] -= expamount;
						new total = PlayerInfo[playerid][pExp];
						if(total > 0) { PlayerInfo[playerid][pExp] = total; }
						else { PlayerInfo[playerid][pExp] = 0; }
						PlayerInfo[playerid][gPupgrade] = PlayerInfo[playerid][gPupgrade]+1;
						GameTextForPlayer(playerid, string, 5000, 1);
						format(string, sizeof(string), "((Ai facut level %d,felicitari !))", nxtlevel);
						SendClientMessage(playerid, COLOR_YELLOW, string);
						format(string, sizeof(string), "%d ..",PlayerInfo[playerid][gPupgrade]);
						SendClientMessage(playerid, COLOR_YELLOW, string);
						}
					}
				}
				return 1;
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "   You are not Logged in !");
			}
		}
		return 1;
	}
Reply
#2

You do PlayerInfo[playerid][pLevel] ++; twice instead of just once.
Reply
#3

You have this in your code delete one of them;

Quote:

PlayerInfo[playerid][pLevel]++;
PlayerInfo[playerid][gPupgrade] = PlayerInfo[playerid][gPupgrade]+5;
PlayerInfo[playerid][pLevel]++;

Reply
#4

So i need to put :

PlayerInfo[playerid][pLevel] +; ??
Reply
#5

No,you need to put:
Quote:

PlayerInfo[playerid][pLevel] ++;

But just once,you put it twice.
As they told you above,delete one of those lines.
Reply
#6

no you write "PlayerInfo[playerid][pLevel] ++; " twice you need to delete one.

Before :
Quote:

PlayerInfo[playerid][pLevel]++;
PlayerInfo[playerid][gPupgrade] = PlayerInfo[playerid][gPupgrade]+5;
PlayerInfo[playerid][pLevel]++;

After :
Quote:

PlayerInfo[playerid][gPupgrade] = PlayerInfo[playerid][gPupgrade]+5;
PlayerInfo[playerid][pLevel]++;

Reply
#7

You have two actions cloned, u need remove one.
Reply
#8

Why are u repeating this code twice ?
Код:
PlayerInfo[playerid][pLevel]++;
Reply
#9

Resolved !

TC
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)