SA-MP Forums Archive
A bit confused .. ( var1 < var2 && var3 >= 1 - 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: A bit confused .. ( var1 < var2 && var3 >= 1 (/showthread.php?tid=536044)



A bit confused .. ( var1 < var2 && var3 >= 1 - Kyance - 07.09.2014

le solved


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - Stinged - 07.09.2014

Not sure it it will solve the problem, but maybe it will.
pawn Код:
if((gPlayerInfo[playerid][gExperience] >= gPlayerInfo[playerid][gNeededExp]) && gPlayerInfo[playerid][gLevel] < 50)
{
    //...
}
else if((gPlayerInfo[playerid][gExperience] < gPlayerInfo[playerid][gNeededExp]) && gPlayerInfo[playerid][gLevel] >= 1)
{
    //...
}
if((var < var) && var >= var)


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - Kyance - 07.09.2014

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Not sure it it will solve the problem, but maybe it will.
pawn Код:
if((gPlayerInfo[playerid][gExperience] >= gPlayerInfo[playerid][gNeededExp]) && gPlayerInfo[playerid][gLevel] < 50)
{
    //...
}
else if((gPlayerInfo[playerid][gExperience] < gPlayerInfo[playerid][gNeededExp]) && gPlayerInfo[playerid][gLevel] >= 1)
{
    //...
}
if((var < var) && var >= var)
Nope, still the same problem, goes nicely to Level 1(200 Experience needed), but if I then use /giveexp 0 199, it will set the Level to 0 again.

Like, if the NeededExp is more than the Experience in /giveexp(well, the stock), it will level him down


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - BroZeus - 07.09.2014

pawn Код:
else if(gPlayerInfo[playerid][gExperience] < gPlayerInfo[playerid][gNeededExp] && gPlayerInfo[playerid][gLevel] >= 1)
Change this line to the following --
pawn Код:
else if(gPlayerInfo[playerid][gExperience] < 0 && gPlayerInfo[playerid][gLevel] >= 1)
When player experience fall below 0 then he will level down

But your code was if his experience is less than needed experience then he will be level downed
I hope u understand


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - Kyance - 07.09.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
pawn Код:
else if(gPlayerInfo[playerid][gExperience] < gPlayerInfo[playerid][gNeededExp] && gPlayerInfo[playerid][gLevel] >= 1)
Change this line to the following --
pawn Код:
else if(gPlayerInfo[playerid][gExperience] < 0 && gPlayerInfo[playerid][gLevel] >= 1)
When player experience fall below 0 then he will level down

But your code was if his experience is less than needed experience then he will be level downed
I hope u understand
Okay, thanks that works.
But now another problem I just saw;
When I give someone a negative number of the XP, it still counts up instead of down.


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - BroZeus - 07.09.2014

not sure
but i think there is same message when giving or taking exp so u got confused
so
pawn Код:
else
        {
            format(Text, sizeof(Text), "You've received {FC4949}%d experience!", amount), SendClientMessage(playerid, -1, Text);
            gPlayerInfo[playerid][gExperience] -= amount;
        }
change the above to following
pawn Код:
else
        {
            format(Text, sizeof(Text), "A amount of {FC4949}%d experience was taken from you..", amount), SendClientMessage(playerid, -1, Text);
            gPlayerInfo[playerid][gExperience] -= amount;
        }



Re: A bit confused .. ( var1 < var2 && var3 >= 1 - Kyance - 07.09.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
not sure
but i think there is same message when giving or taking exp so u got confused
so
pawn Код:
else
        {
            format(Text, sizeof(Text), "You've received {FC4949}%d experience!", amount), SendClientMessage(playerid, -1, Text);
            gPlayerInfo[playerid][gExperience] -= amount;
        }
change the above to following
pawn Код:
else
        {
            format(Text, sizeof(Text), "A amount of {FC4949}%d experience was taken from you..", amount), SendClientMessage(playerid, -1, Text);
            gPlayerInfo[playerid][gExperience] -= amount;
        }
I already changed the text, and yeah, it was a bit confusing too xD
Anyways, here's how I use the stock; ( just a small line )
pawn Код:
if(gPlayerInfo[playerid][gRExperience] >= 50) SendClientMessage(playerid, -1, "Nitestick bought for 50 xp!"), GiveExperience(playerid, -50), gPlayerInfo[playerid][Slot][1] = 1;
But If I use -, it counts it up.

Should I maybe create a "TakeExperience"? ;d

EDIT: Yeah, created a "TakeExperience" and it works now.


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - BroZeus - 07.09.2014

Do u receive the right message?
i mean the exp taken message?


Re: A bit confused .. ( var1 < var2 && var3 >= 1 - Kyance - 07.09.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Do u receive the right message?
i mean the exp taken message?
Yeah, but I created a "TakeExperience" and it works.
I guess the problem was the double - sign (-= -amount)