SA-MP Forums Archive
Rank system won't work. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Rank system won't work. (/showthread.php?tid=522647)



Rank system won't work. - Jimmy0wns - 28.06.2014

So, I'm currently working on a rank/xp system but can't get it working.
Basically when someone has enough XP, he keeps getting a higher level.

Code: http://pastebin.com/X68SYeCD
If there is anything else you need, then I'll add it.


Re: Rank system won't work. - BroZeus - 28.06.2014

try these
pawn Код:
public UpdatePlayerLevel(playerid)
{
        new newlevelxp;
        newlevelxp = GetXPAmount(pInfo[playerid][pLevel]);
        if(pInfo[playerid][pExp] > newlevelxp[playerid])
        {
            SendClientMessage(playerid, -1, "this means you have leveled up");
            pInfo[playerid][pLevel]++;
            return 0;
        }
        return 1;
}

stock GetXPAmount(rankid)
{
        new xpamount;
        switch(rankid)
        {
            case 0: xpamount = 100;
                case 1: xpamount = 200;
                case 2: xpamount = 400;
                case 3: xpamount = 800;
                case 4: xpamount = 1600;
                case 5: xpamount = 3200;
                case 6: xpamount = 6400;
                case 7: xpamount = 12800;
                case 8: xpamount = 25600;
                case 9: xpamount = 51200;
                case 10: xpamount = 10240;
        }
        return xpamount;
}



Re: Rank system won't work. - Jimmy0wns - 28.06.2014

Код:
.pwn(352) : error 028: invalid subscript (not an array or too many subscripts): "newlevelxp"
.pwn(352) : warning 215: expression has no effect
.pwn(352) : error 001: expected token: ";", but found "]"
.pwn(352) : error 029: invalid expression, assumed zero
.pwn(352) : fatal error 107: too many error messages on one line



Re: Rank system won't work. - BroZeus - 28.06.2014

which is line 352


Re: Rank system won't work. - Jimmy0wns - 28.06.2014

I fixed that one already, but it still won't work after that.


Re: Rank system won't work. - BroZeus - 28.06.2014

is his level keeps on increasing in textdraw
or
"this means you have leveled up" this mesage keeps popping up>?


Re: Rank system won't work. - Jimmy0wns - 28.06.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
is his level keeps on increasing in textdraw
or
"this means you have leveled up" this mesage keeps popping up>?
Level keeps increasing on the textdraw and the message keeps popping up.


Re: Rank system won't work. - BroZeus - 28.06.2014

pawn Код:
public UpdatePlayerLevel(playerid)
{
        new newlevelxp;
        newlevelxp = GetXPAmount(pInfo[playerid][pLevel]);
printf("current exp = %i || Next level exp = %i",pInfo[playerid][pExp], newlevelxp);
        if(pInfo[playerid][pExp] > newlevelxp[playerid])
        {
            SendClientMessage(playerid, -1, "this means you have leveled up");
            pInfo[playerid][pLevel]++;
            return 0;
        }
        return 1;
}
use this and show server log


Re: Rank system won't work. - icra - 28.06.2014

This is happening because you don't reset current player exp while leveling up.
pawn Код:
if(pInfo[playerid][pExp] > newlevelxp[playerid])
        {
            SendClientMessage(playerid, -1, "this means you have leveled up");
            pInfo[playerid][pLevel]++;
            pInfo[playerid][pExp] = 0;
            newlevelxp[playerid] = newlevelxp[playerid] * pInfo[playerid][pLevel];
            return 0;
        }



Re: Rank system won't work. - BroZeus - 28.06.2014

Quote:
Originally Posted by icra
Посмотреть сообщение
This is happening because you don't reset current player exp while leveling up.
pawn Код:
if(pInfo[playerid][pExp] > newlevelxp[playerid])
        {
            SendClientMessage(playerid, -1, "this means you have leveled up");
            pInfo[playerid][pLevel]++;
            pInfo[playerid][pExp]
            newlevelxp[playerid] = newlevelxp[playerid] * pInfo[playerid][pLevel];
            return 0;
        }
thats just wrong because he is using GetXpAmount stock so he wouldnt need to do that