Levels
#1

How would I go about making a level&experience system using dini?

I'm thinking of something along the lines of;
Level 1 = 100 points
Level 2 = 200 points
Level 3 = 400 points
Level 4 = 800 points

Basically, *2 every time.

I know I need to set it under OnPlayerDeath.. The killer get +1 points and then it checks if he reached one of the points needed to level up, then it sets his new level to what it's supposed to be.. But the thing is, I have no idea how I would do that
Reply
#2

OnPlayerDeath

Example

PHP код:
if(GetPlayerScore(killerid) == 100//100 points
{
//your code here

Not sure if it work in that callback, but never had the level system before.
Reply
#3

Well, if you're working on the basis that 'points' are score, then this should work.

OnPlayerDeath:

PHP код:
SetPlayerScorekilleridGetPlayerScorekillerid) + );
switch( 
GetPlayerScorekillerid) )
{
case 
100
{
// Level them up to level 1.
}
case 
200
{
// Level them up to level 2.
}

Reply
#4

2KY's way should work also.

switch is faster than if.
Reply
#5

Ok, I got what you guys were going by so I did this,

On top:
Quote:

new Level[MAX_PLAYERS];
new Points[MAX_PLAYERS];

Then went down to OnPlayerDeath:
Quote:

Points[killerid] ++;
SetPlayerScore(killerid, Points[killerid]);
switch(GetPlayerScore(killerid))
{

case 100:
{
Level[killerid] ++;
}
case 200:
{
Level[killerid] ++;
}
case 400:
{
Level[killerid] ++;
}
case 800:
{
Level[killerid] ++;
}
case 1600:
{
Level[killerid] ++;
}
case 3200:
{
Level[killerid] ++;
}
case 6400:
{
Level[killerid] ++;
}
case 12800:
{
Level[killerid] ++;
}
}

And then went to OnPlayerDisconnet:
Quote:

dini_IntSet(file, "Level", Level[playerid]);
dini_IntSet(file, "Points", GetPlayerScore(playerid));

For now, this looks good? I currently have no way to test it so ya.. Compiler brought up no errors.
Reply
#6

Change the switch statement to go through Points[killerid], and yes, it will work just fine.
Reply
#7

Well,

1 kill = +1 Points (which is score in my case)
So, the following gets the score and if one of the case things = to the score, it levels the player up
Quote:

switch(GetPlayerScore(killerid))
case 50:
{
Level[playerid] ++;
}

I'm positive what I did at first was right, but I'm only a beginner so I could be wrong.
Reply
#8

That would level the player up that died.

OnPlayerDeath -

playerid: The person who died.
killerid: The person who killed playerid.
reason: The way they died, weapon ID, explosion, et cetera.
Reply
#9

Quote:
Originally Posted by 2KY
Посмотреть сообщение
That would level the player up that died.

OnPlayerDeath -

playerid: The person who died.
killerid: The person who killed playerid.
reason: The way they died, weapon ID, explosion, et cetera.
If you're referring to

Quote:

switch(GetPlayerScore(killerid))
case 50:
{
Level[playerid] ++;
}

^^ Supposed to be [killerid] ++;

then I didn't mean that.. I was actually not paying attention and just wrote that to quickly get the post out, but anyways HUGE thanks for the help!

PS: If I have another question, should I just post it in this topic of make another one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)