Checking if the player passed the specific EXP?(EDITED)!!!! still need help
#1

pawn Код:
if(killerid == playerid)
    {
        if(playerDB[killerid][EXP] >= .....???? // <<<<< Wut to write here<<<???
        {
            SendClientMessage(killerid,COLOR_WHITE,"[INFO] New level biatch!.");
            playerDB[killerid][Level] ++;
            PlayerPlaySound(killerid,1057,0.0,0.0,0.0);
        }
    }

Okay i got the levels defined like: #define LEVEL1 5000
the 5000 is the experience which is needed to be earn, i got 30levels and my question is how do i check if the player has passed the experience so he would recieve a new level? checking every level exp would take some time and some more data, i know theres an easier way but can't figure it out, i tried to search didn't result in my problem, anyone knows?? cmoon..

edit: or if anyone knows an easier way to make this without defines , waiting for all replies.


EDIt 2: Found a way but get an error:

Код:
playerDB[playerid][PatirtisLeft] = LevelExp[playerDB[playerid][Lygis]]) - playerDB[playerid][Patirtis];
Oh and um
Код:
new LevelExp[30]
levelexp goes like that and then new LevelExp[30] = {1,2,3,4,5,6} and so on to 30...

Код:
E:\Games Setup\Gta san andreas server\Install\samp02Xserver.win32\gamemodes\FreeRoam.pwn(9115) : error 001: expected token: ";", but found ")"
E:\Games Setup\Gta san andreas server\Install\samp02Xserver.win32\gamemodes\FreeRoam.pwn(9115) : error 029: invalid expression, assumed zero
E:\Games Setup\Gta san andreas server\Install\samp02Xserver.win32\gamemodes\FreeRoam.pwn(9115) : warning 215: expression has no effect
Reply
#2

-------------
Reply
#3

pawn Код:
if(playerDB[killerid][EXP] >= .....???? // <<<<< Wut to write here<<<???
There you put in the exp required for his next level.

I'm unsure about your levels, but maybe:

pawn Код:
if(killerid == playerid)
{
if(playerDB[killerid][EXP] >= (playerDB[killerid][Level]+1 * 5000))
{
SendClientMessage(killerid,COLOR_WHITE,"[INFO] New level biatch!.");
playerDB[killerid][Level] ++;
PlayerPlaySound(killerid,1057,0.0,0.0,0.0);
}
}
Reply
#4

pawn Код:
new LevelExp[30] = {5000,}; // add other levels exp here
pawn Код:
if(playerDB[killerid][EXP] >= LevelExp[playerDB[killerid][Level]])
Reply
#5

Quote:
Originally Posted by MadeMan
pawn Код:
new LevelExp[30] = {5000,}; // add other levels exp here
pawn Код:
if(playerDB[killerid][EXP] >= LevelExp[playerDB[killerid][Level]])
Level+1, remember it advances him to the next level.

Also, you're comparing his EXP with his level
Reply
#6

Quote:
Originally Posted by Hiddos
Quote:
Originally Posted by MadeMan
pawn Код:
new LevelExp[30] = {5000,}; // add other levels exp here
pawn Код:
if(playerDB[killerid][EXP] >= LevelExp[playerDB[killerid][Level]])
Level+1, remember it advances him to the next level.

Also, you're comparing his EXP with his level
new LevelExp[30]; array starts from 0, so if his level is 0 then to get level 1 he must have 5000 EXP.

And I'm comparing EXP with EXP if you can read right.
Reply
#7

pawn Код:
#define MAX_EXPERIENCE 10 //When a player reaches MAX_EXPERIENCE, they go up a level
#define MAX_LEVELS 10
pawn Код:
new PlayerExperience[MAX_PLAYERS]; //Can be changed if you are saving the stats to external files
new PlayerLevel[MAX_PLAYERS]; //^^
pawn Код:
stock GivePlayerExperience(id, experience)
{
new message[128];
PlayerExperience[id] += experience;
format(message, sizeof(message), "You have gained %i experience point(s)!", experience);
if((PlayerExperience[id] - MAX_EXPERIENCE) >= 0) {
PlayerExperience[id] = PlayerExperience[id] - MAX_EXPERIENCE;
PlayerLevel[id]++;
format(message, sizeof(message), "You have gained %i experience point(s), meaning you advance to level %i, well done!", experience, PlayerLevel[id]);
}
if(PlayerLevel[id] >= MAX_LEVELS) PlayerLevel[id] = MAX_LEVELS;
SendClientMessage(id, COLOR_GREEN, message);
return 1;
}
pawn Код:
//Example - OnPlayerDeath
if(killerid != playerid) GivePlayerExperience(killerid, 1); //Will give the killerid +1 experience
Not tested, just scripted on the spot.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)