level help
#1

when you have 10/10 EP (experince point)
you can buy a level ( /buylevel ).

But if you have 11/10 I mean higher than 10/10
you cant it just send the message.

Код:
You don't have enough Experience Points to buy the next level. (%d/%d)
I want so you can, can anybody help me with that?

pawn Код:
command(buylevel, playerid, params[])
{
    #pragma unused params
    new string[128];
    if(Player[playerid][Level] == 25) return SendClientMessage(playerid, WHITE, "You cannot buy a level higher than 25!");
    if(Player[playerid][EXP] == ((Player[playerid][Level]+1) * 10))
    {
        Player[playerid][EXP] = 0;
        Player[playerid][Level]++;
        format(string, sizeof(string), "You have just bought level %d!", Player[playerid][Level]);
        SendClientMessage(playerid, WHITE, string);
    }
    else
    {
        format(string, sizeof(string), "You don't have enough Experience Points to buy the next level. (%d/%d)", Player[playerid][EXP], ((Player[playerid][Level]+1) * 10));
        SendClientMessage(playerid, WHITE, string);
    }
    return 1;
}
Reply
#2

I don't get what you mean do you want it to make so you can only get a max amount of EXP per level then you must /buylevel?
Reply
#3

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
I don't get what you mean do you want it to make so you can only get a max amount of EXP per level then you must /buylevel?
No i mean...

You need 10/10 EXP to buylevel

And if you have over the first 10/ ( Example: 13/10 ) you cant buy a level
because you dont have 10/10 i want so you can.

so if i have 13/10 EXP and i /buylevel i want so after that i have 3/20. ( btw its going +10 more for every level you have ).

EDIT: But yea.. your idea is pretty cool to :P is that easier to make?
Reply
#4

I don't see anything wrong in your script, I don't get you lol. You want it so if a player has level 1 and he does /buylevel he gets 10 EXP still but now he needs 20 EXP to buy another level?
Reply
#5

like this?
Код:
command(buylevel, playerid, params[])
{
	#pragma unused params
	new string[128];
	if(Player[playerid][Level] == 25) return SendClientMessage(playerid, WHITE, "You cannot buy a level higher than 25!");
	if(Player[playerid][EXP] >= (Player[playerid][Level]+1)*10)
	{
		Player[playerid][EXP] -= (Player[playerid][Level]+1)*10;
		Player[playerid][Level]++;
		format(string, sizeof(string), "You have just bought level %d!", Player[playerid][Level]);
		SendClientMessage(playerid, WHITE, string);
	}
	else
	{
		format(string, sizeof(string), "You don't have enough Experience Points to buy the next level. (%d/%d), Get %d more EXP.", Player[playerid][EXP], (Player[playerid][Level]+1)*10, (Player[playerid][Level]+1)*10-Player[playerid][EXP]);
		SendClientMessage(playerid, WHITE, string);
	}
	return 1;
}
Reply
#6

Quote:
Originally Posted by Retardedwolf
Посмотреть сообщение
I don't see anything wrong in your script, I don't get you lol. You want it so if a player has level 1 and he does /buylevel he gets 10 EXP still but now he needs 20 EXP to buy another level?
Okay hmm let me try to explain it..

My level system works like this

Level 1 : You need 10 EXP to next level 0/10
Level 2 : You need 20 EXP to next level 0/20
Level 3 : You need 30 EXP to next level 0/30
And so on..

Lets say i have 9/10 EXP now.. and its payday
so i get another EXP now i have 10/10 EXP now
i can /buylevel and get level 1 but lets say i wanna save up and
dont use my EXP .. now its payday again and i get 1 more EXP
now i have 11/10 and now i wanna buy a level so i do /buylevel
but i cant because it says i dont have 10/10 i want so you can
so if i can it would go like this :
i have 11/10 EXP i buy a level and is now level 1
and have 1/20 EXP because i only needed 10 for level 1.


Quote:
Originally Posted by Babul
Посмотреть сообщение
like this?
Код:
command(buylevel, playerid, params[])
{
	#pragma unused params
	new string[128];
	if(Player[playerid][Level] == 25) return SendClientMessage(playerid, WHITE, "You cannot buy a level higher than 25!");
	if(Player[playerid][EXP] >= (Player[playerid][Level]+1)*10)
	{
		Player[playerid][EXP] -= (Player[playerid][Level]+1)*10;
		Player[playerid][Level]++;
		format(string, sizeof(string), "You have just bought level %d!", Player[playerid][Level]);
		SendClientMessage(playerid, WHITE, string);
	}
	else
	{
		format(string, sizeof(string), "You don't have enough Experience Points to buy the next level. (%d/%d), Get %d more EXP.", Player[playerid][EXP], (Player[playerid][Level]+1)*10, (Player[playerid][Level]+1)*10-Player[playerid][EXP]);
		SendClientMessage(playerid, WHITE, string);
	}
	return 1;
}
No not like that :/
Reply
#7

hm. i think i got it already ^^
pay attention to this line:
Код:
if(Player[playerid][EXP] >= (Player[playerid][Level]+1)*10)
i changed the == to >=, that was your problem, maybe you didnt see the change...
btw iam using a similar system for cops ranking up. this makes it very hard to claim max. level.
edit: in your case: 10+20+30+...+240+250, thats (10+250)*(25/2), thats 3250 ^^
Reply
#8

Quote:
Originally Posted by Babul
Посмотреть сообщение
hm. i think i got it already ^^
pay attention to this line:
Код:
if(Player[playerid][EXP] >= (Player[playerid][Level]+1)*10)
i changed the == to >=, that was your problem, maybe you didnt see the change...
btw iam using a similar system for cops ranking up. this makes it very hard to claim max. level
Oh let me test it

and i has a max level of 25 i can send the code if you wanna take a look ?

EDIT: Working, but when i have 11/10 EXP i can buy a level now but it resets my
EXP, so if i have 11/10 EXP and buy level 1 i get level 1 but after that i have 0/20 is it possible to make so it saves
the EXP so if i have 11/10 and buy a level i now have 1/20 ?
Reply
#9

indeed i would like to have a look. from what i see here, you are coding smart and efficient.

edit:
this line decrements (Level+1)*10 EXP points @ buying a new level. so lets assume you are level 0, and got 23/10 exp:
Код:
Player[playerid][EXP] -= (Player[playerid][Level]+1)*10;
level 0, exp 23
you buy a level, then this line will do this: subtract (level+1)*10=10 from exp=23, thats 23-(0+1)*10 = 13.
it already should work. i dont see why it shouldnt work?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)