/Buylevel command problem.
#1

Hi

So i have my level system ready and i wans that so people could export cars and buy levels.

I have my /buylevel command ready but each time i write /buylevel it buys all 3 levels. How could i make it buy one level at a time?

Код:
	if(strcmp(cmdtext,"/buylevel",true)==0)
       {
 	if(GetPlayerMoney(playerid) >= 100000 && GetPlayerScore(playerid) == 0)
       {
       SetPlayerRank(playerid, 1);
       SetPlayerScore(playerid, 1);
       GivePlayerMoney(playerid, -100000);
       SendClientMessage(playerid, COLOR_GREEN,"Apsveicam! Tu iegādājies 1. līmeni.");
	   }
    else {
	   if(GetPlayerMoney(playerid) < 100000 && GetPlayerScore(playerid) == 0)
       {
	   SendClientMessage(playerid, COLOR_BRIGHTRED, "Tev nav pietiekami daudz naudas.");
       }
       return 1;
    }
   	if(GetPlayerMoney(playerid) >= 200000 && GetPlayerScore(playerid) == 1)
       {
       SetPlayerRank(playerid, 2);
       SetPlayerScore(playerid, 2);
       GivePlayerMoney(playerid, -200000);
       SendClientMessage(playerid, COLOR_GREEN,"Apsveicam! Tu iegādājies 2. līmeni.");
	   }
    else {
	   if(GetPlayerMoney(playerid) < 200000 && GetPlayerScore(playerid) == 1)
       {
	   SendClientMessage(playerid, COLOR_BRIGHTRED, "Tev nav pietiekami daudz naudas.");
       }
       return 1;
    }
   	if(GetPlayerMoney(playerid) >= 300000 && GetPlayerScore(playerid) == 2)
       {
       SetPlayerRank(playerid, 3);
       SetPlayerScore(playerid, 3);
       GivePlayerMoney(playerid, -300000);
       SendClientMessage(playerid, COLOR_GREEN,"Apsveicam! Tu iegādājies 3. līmeni.");
	   }
    else {
	   if(GetPlayerMoney(playerid) < 300000 && GetPlayerScore(playerid) == 2)
       {
	   SendClientMessage(playerid, COLOR_BRIGHTRED, "Tev nav pietiekami daudz naudas.");
       }
       return 1;
    }
    return 1;
    }
Reply
#2

put a return 1; after each sendclientmessage saying that they bought it
Reply
#3

No it doeasnt work. It still buys all 3 of them.

Translation:

Код:
if(strcmp(cmdtext,"/buylevel",true)==0)
       {
 	if(GetPlayerMoney(playerid) >= 100000 && GetPlayerScore(playerid) == 0)
       {
       SetPlayerRank(playerid, 1);
       SetPlayerScore(playerid, 1);
       GivePlayerMoney(playerid, -100000);
       SendClientMessage(playerid, COLOR_GREEN,"Gratz! You bought level 1.");
	   }
    else {
	   if(GetPlayerMoney(playerid) < 100000 && GetPlayerScore(playerid) == 0)
       {
	   SendClientMessage(playerid, COLOR_BRIGHTRED, "You don't have enough money.");
       }
       return 1;
    }
Please, please help.
Reply
#4

not sure but I think it should be
'else if'
{

not

else
{
if
{
Reply
#5

pawn Код:
if(strcmp(cmdtext,"/buylevel",true)==0)
{
    if(GetPlayerMoney(playerid) < 100000 && GetPlayerScore(playerid) != 0)
        return SendClientMessage(playerid, COLOR_BRIGHTRED, "You don't have enough money.");
    SetPlayerRank(playerid, 1);
    SetPlayerScore(playerid, 1);
    GivePlayerMoney(playerid, -100000);
    SendClientMessage(playerid, COLOR_GREEN,"Gratz! You bought level 1.");
    return 1;
}
Reply
#6

Try this:

pawn Код:
if(strcmp(cmdtext,"/buylevel",true)==0)
    {
        new Score = GetPlayerScore(playerid);
        if(GetPlayerMoney(playerid) < 100000 && Score == 0)
        {
            SendClientMessage(playerid, COLOR_BRIGHTRED, "You don't have enough money.");
            return 1;
        }
        else
        {
            SetPlayerRank(playerid, 1);
            SetPlayerScore(playerid, 1);
            GivePlayerMoney(playerid, -100000);
            SendClientMessage(playerid, COLOR_GREEN,"Gratz! You bought level 1.");
            return 1;
        }
    }
EDIT: 2 L8
Reply
#7

Thank you guys very very much! Youre the best! Everything works.
Reply
#8

Quote:
Originally Posted by Memoryz
Посмотреть сообщение
put a return 1; after each sendclientmessage saying that they bought it
You're lucky bayler came to your community. You don't even understand anything.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)