PDA

View Full Version : Problem with level


OnY
08/12/2013, 02:50 PM
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;
}

Stevo127
08/12/2013, 02:55 PM
You do PlayerInfo[playerid][pLevel] ++; twice instead of just once.

FilesMAker
08/12/2013, 02:57 PM
You have this in your code delete one of them;

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

OnY
08/12/2013, 02:57 PM
So i need to put :

PlayerInfo[playerid][pLevel] +; ??

Tagathron
08/12/2013, 02:59 PM
No,you need to put:
PlayerInfo[playerid][pLevel] ++;
But just once,you put it twice.
As they told you above,delete one of those lines.

FilesMAker
08/12/2013, 03:01 PM
no you write "PlayerInfo[playerid][pLevel] ++; " twice you need to delete one.

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

After :

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

0x41726d79
08/12/2013, 03:11 PM
You have two actions cloned, u need remove one.

FahadKing07
08/12/2013, 03:30 PM
Why are u repeating this code twice ? PlayerInfo[playerid][pLevel]++;

OnY
08/12/2013, 06:42 PM
Resolved !

TC