/buy command help plz!!
#1

I made a dialog box with list to get weapons when we type /buy..... and i hv costed those weapons with dollars... and when someone buys a weapon: think that John has $10, and a Desert Eagle cost $1000, and when john buys it the money goes minus.... i want if the player doesnt have enough money to buy that weapon, then a message comes u dont have enough cash to buy this weapon.... can u plz help me in it... i want help hw to do that... heres my current script:

Код:
This is under the :
public OnPlayerCommandText(playerid, cmdtext[])

if(strcmp(cmd, "/buy", true) == 0)
	{
	ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Buy the weapons that you want from here.", "Desert Eagle = $6000 \nCombat Shotgun = $14000 \nMP5 = $10000 \nAK-47 = $14000 \nM4 = $16000", "Select", "Close");
	return 1;
	}

This is under:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])

if(dialogid == 3)
{
	if(response == 0) return SendClientMessage(playerid, COLOR_YELLOW, "You closed  the '/buy' menu.");
	switch(listitem)
	{
	case 0:{
	SendClientMessage(playerid, COLOR_YELLOW, "You have bought a Desert Eagle for $6000.");
	GivePlayerWeapon(playerid, 24, 40);
	GivePlayerMoney(playerid, -6000);
	}
	case 1:{
	SendClientMessage(playerid, COLOR_YELLOW, "You have bought a Combat Shotgun for $14000.");
	GivePlayerWeapon(playerid, 27, 107);
	GivePlayerMoney(playerid, -14000);
	}
	case 2:{
	SendClientMessage(playerid, COLOR_YELLOW, "You have bought a MP5 for $10000.");
	GivePlayerWeapon(playerid, 29, 230);
	GivePlayerMoney(playerid, -10000);
	}
	case 3:{
	SendClientMessage(playerid, COLOR_YELLOW, "You have bought a AK-47 for $14000.");
	GivePlayerWeapon(playerid, 30, 460);
	GivePlayerMoney(playerid, -14000);
	}
	case 4:{
	SendClientMessage(playerid, COLOR_YELLOW, "You have bought a M4 for $16000.");
	GivePlayerWeapon(playerid, 31, 460);
	GivePlayerMoney(playerid, -16000);
 	}
	}
}
plz help me ASAP!!
Reply
#2

pawn Код:
if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!"); // this will check the amount of money the player has, and then checks if its lower as the 'AMOUNTHERE'
Reply
#3

PHP код:
if(dialogid == 3)
{
    if(
response == 0) return SendClientMessage(playeridCOLOR_YELLOW"You closed  the '/buy' menu.");
    switch(
listitem)
    {
        case 
0:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Desert Eagle for $6000.");
            
GivePlayerWeapon(playerid2440);
            
GivePlayerMoney(playerid, -6000);
            if(
GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
1:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Combat Shotgun for $14000.");
            
GivePlayerWeapon(playerid27107);
            
GivePlayerMoney(playerid, -14000);
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
2:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a MP5 for $10000.");
            
GivePlayerWeapon(playerid29230);
            
GivePlayerMoney(playerid, -10000);
            if(
GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
3:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a AK-47 for $14000.");
            
GivePlayerWeapon(playerid30460);
            
GivePlayerMoney(playerid, -14000);
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
4:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a M4 for $16000.");
            
GivePlayerWeapon(playerid31460);
            
GivePlayerMoney(playerid, -16000);
            if(
GetPlayerMoney(playerid) < 16000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
    }

Reply
#4

Quote:
Originally Posted by Jafet_Macario
Посмотреть сообщение
PHP код:
if(dialogid == 3)
{
    if(
response == 0) return SendClientMessage(playeridCOLOR_YELLOW"You closed  the '/buy' menu.");
    switch(
listitem)
    {
        case 
0:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Desert Eagle for $6000.");
            
GivePlayerWeapon(playerid2440);
            
GivePlayerMoney(playerid, -6000);
            if(
GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
1:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Combat Shotgun for $14000.");
            
GivePlayerWeapon(playerid27107);
            
GivePlayerMoney(playerid, -14000);
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
2:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a MP5 for $10000.");
            
GivePlayerWeapon(playerid29230);
            
GivePlayerMoney(playerid, -10000);
            if(
GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
3:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a AK-47 for $14000.");
            
GivePlayerWeapon(playerid30460);
            
GivePlayerMoney(playerid, -14000);
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
        case 
4:
        {
            
SendClientMessage(playeridCOLOR_YELLOW"You have bought a M4 for $16000.");
            
GivePlayerWeapon(playerid31460);
            
GivePlayerMoney(playerid, -16000);
            if(
GetPlayerMoney(playerid) < 16000) return SendClientMessage(playerid, -1,"You don't have that much");
        }
    }

This still wotn work.
Now it removes the money from the player first, and after that it checks the amount of money. So you will buy the weapon, money gets removed, and you get a message 'You dont have that much'.
Reply
#5

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!"); // this will check the amount of money the player has, and then checks if its lower as the 'AMOUNTHERE'
where do i type this??
Reply
#6

Sorry my bad.
PHP код:
if(dialogid == 3)
{
    if(
response == 0) return SendClientMessage(playeridCOLOR_YELLOW"You closed  the '/buy' menu.");
    switch(
listitem)
    {
        case 
0:
        {
            if(
GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Desert Eagle for $6000.");
                
GivePlayerWeapon(playerid2440);
                
GivePlayerMoney(playerid, -6000);
            }
        }
        case 
1:
        {
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Combat Shotgun for $14000.");
                
GivePlayerWeapon(playerid27107);
                
GivePlayerMoney(playerid, -14000);
            }
        }
        case 
2:
        {          
            if(
GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a MP5 for $10000.");
                
GivePlayerWeapon(playerid29230);
                
GivePlayerMoney(playerid, -10000);
            }
        }
        case 
3:
        {
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a AK-47 for $14000.");
                
GivePlayerWeapon(playerid30460);
                
GivePlayerMoney(playerid, -14000);
            }
        }
        case 
4:
        {
            if(
GetPlayerMoney(playerid) < 16000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a M4 for $16000.");
                
GivePlayerWeapon(playerid31460);
                
GivePlayerMoney(playerid, -16000);
            }
        }
    }

This should work.
Reply
#7

pawn Код:
if(dialogid == 3)
{
    if(response == 0) return SendClientMessage(playerid, COLOR_YELLOW, "You closed  the '/buy' menu.");
    switch(listitem) {
        case 0:
        {
            if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!"); // now itll check his money the first thing when he clicks on the first list item
            SendClientMessage(playerid, COLOR_YELLOW, "You have bought a Desert Eagle for $6000.");
            GivePlayerWeapon(playerid, 24, 40);
            GivePlayerMoney(playerid, -6000);
        }
        case 1:
        {
            if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!"); // etc etc
            SendClientMessage(playerid, COLOR_YELLOW, "You have bought a Combat Shotgun for $14000.");
            GivePlayerWeapon(playerid, 27, 107);
            GivePlayerMoney(playerid, -14000);
        }
        case 2:
        {
            if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!");
            SendClientMessage(playerid, COLOR_YELLOW, "You have bought a MP5 for $10000.");
            GivePlayerWeapon(playerid, 29, 230);
            GivePlayerMoney(playerid, -10000);
        }
        case 3:
        {
            if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!");
            SendClientMessage(playerid, COLOR_YELLOW, "You have bought a AK-47 for $14000.");
            GivePlayerWeapon(playerid, 30, 460);
            GivePlayerMoney(playerid, -14000);
        }
        case 4:
        {
            if( GetPlayerMoney(playerid) < AMOUNTHERE ) return SendClientMessage(playerid, Color, "You dont have enough money to buy this weapon!");
            SendClientMessage(playerid, COLOR_YELLOW, "You have bought a M4 for $16000.");
            GivePlayerWeapon(playerid, 31, 460);
            GivePlayerMoney(playerid, -16000);
        }
    }
}
Reply
#8

Quote:
Originally Posted by Jafet_Macario
Посмотреть сообщение
Sorry my bad.
PHP код:
if(dialogid == 3)
{
    if(
response == 0) return SendClientMessage(playeridCOLOR_YELLOW"You closed  the '/buy' menu.");
    switch(
listitem)
    {
        case 
0:
        {
            if(
GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Desert Eagle for $6000.");
                
GivePlayerWeapon(playerid2440);
                
GivePlayerMoney(playerid, -6000);
            }
        }
        case 
1:
        {
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a Combat Shotgun for $14000.");
                
GivePlayerWeapon(playerid27107);
                
GivePlayerMoney(playerid, -14000);
            }
        }
        case 
2:
        {          
            if(
GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a MP5 for $10000.");
                
GivePlayerWeapon(playerid29230);
                
GivePlayerMoney(playerid, -10000);
            }
        }
        case 
3:
        {
            if(
GetPlayerMoney(playerid) < 14000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a AK-47 for $14000.");
                
GivePlayerWeapon(playerid30460);
                
GivePlayerMoney(playerid, -14000);
            }
        }
        case 
4:
        {
            if(
GetPlayerMoney(playerid) < 16000) return SendClientMessage(playerid, -1,"You don't have that much");
            else
            {
                
SendClientMessage(playeridCOLOR_YELLOW"You have bought a M4 for $16000.");
                
GivePlayerWeapon(playerid31460);
                
GivePlayerMoney(playerid, -16000);
            }
        }
    }

This should work.
thanks bro this worked!!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)