Can someone help me with this
#1

Can someone help me with making this command into a menu....Right now it shows up as a client message


Код:
  	if(strcmp(cmd,"/buy",true)==0)
	{
  if(IsSpawned[playerid] == 0) {
	SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
  return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[15])){
  SendClientMessage(playerid,COLOR_ERROR,"You have to be in the checkpoint inside a 24/7 store to use this command");
  return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[15])){
  SendClientMessage(playerid,COLOR_ERROR,"You have to be in the checkpoint inside a 24/7 store to use this command");
  return 1;
  }
  TogglePlayerDynamicCP(playerid, 15, true);
  {
  new buyername[24];
  GetPlayerName(playerid,buyername, 24);
	new x_nr[256];
			x_nr = strtok(cmdtext, idx);
			if(!strlen(x_nr)) {
				SendClientMessage(playerid, COLOR_ERROR, "USAGE: /buy 1-6");
   			return 1;
			}
		  if(strcmp(x_nr,"1",true) == 0)
			{
			  if(GetPlayerMoney(playerid) <= 1499) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Chainsaw ($2000)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-1500);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Chainsaw. You were charged $1500");
			  GivePlayerWeapon(playerid,9,1);

			}
			else if(strcmp(x_nr,"2",true) == 0)
			{
        if(GetPlayerMoney(playerid) <= 4) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy flowers ($5)");

			  return 1;
			}


			  GivePlayerMoney(playerid,-5);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought flowers. You were charged $5");
			  GivePlayerWeapon(playerid,14,1);
			}
			else if(strcmp(x_nr,"3",true) == 0)
	 		{

        if(GetPlayerMoney(playerid) <= 99) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Baseball Bat ($100)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-100);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Baseball Bat. You were charged $100");
			  GivePlayerWeapon(playerid,5,1);

			}
			else if(strcmp(x_nr,"4",true) == 0)
			{
        if(GetPlayerMoney(playerid) <= 19) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy Beer ($20)");
			  return 1;
			}


			  GivePlayerMoney(playerid,-20);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought Beer. You were charged $20");
			  new Float:beerhealth;
		    GetPlayerHealth(playerid,beerhealth);
			  if(beerhealth <=95) {
        SetPlayerHealth(playerid,beerhealth+5);
  		  }

			}
			else if(strcmp(x_nr,"5",true) == 0)
			{
        if(GetPlayerMoney(playerid) <= 999) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Wallet ($1000)");
			  return 1;
			}
        if(HasWallet[playerid] >= 1) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You already have a Wallet");
			  return 1;
			}

			  GivePlayerMoney(playerid,-1000);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Wallet. You were charged $1000");
			  SendClientMessage(playerid, 0x00C7FFAA, "You can be robbed upto 3 times and not loose any cash");
			  HasWallet[playerid] =3;

		  }
			else if(strcmp(x_nr,"6",true) == 0)
			{
        if(GetPlayerMoney(playerid) <= 499) {
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase Failed_|");
			  SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to buy a Parachute ($500)");
			  return 1;
			}

			  GivePlayerMoney(playerid,-500);
			  SendClientMessage(playerid, 0xA9A9A9AA, "|_24/7 Purchase_|");
			  SendClientMessage(playerid, 0x00C7FFAA, "You have bought a Parachute. You were charged $500");
			  GivePlayerWeapon(playerid,46,1);
		  }
			else
			{
			SendClientMessage(playerid, COLOR_ERROR, "USAGE: /buy 1-6");

			return 1;
			}

	  }
	  return 1;
	}
Reply
#2

i dont understand youre script :P
but i know that the "new ...;" stuff hase to be on top of the publick or on top of the sript
Reply
#3

The command i posted is a command for a shop to buy things.



Except, I want it in a menu format instead of sendclient format.
Reply
#4

If you want a menu (like the menu of the ammunation or the food shops), you can script the "CreateMenu" stuff. If you'll do that I can help you with the items.
You can also use a list dialog. It is more simple, by my opinion.
Reply
#5

Quote:
Originally Posted by Amit B
If you want a menu (like the menu of the ammunation or the food shops), you can script the "CreateMenu" stuff. If you'll do that I can help you with the items.
You can also use a list dialog. It is more simple, by my opinion.
yeah. Thats what i mean (sorry for bad english lol) I want a dialog for that menu
Reply
#6

On top:
pawn Код:
#define dialog_bw 1
(If you has another dialogs, just replace the 1 on a empty dialog ID)

Under OnPlayerCommandText:
pawn Код:
if(!strcmp(cmdtext,"/buymenu",true))
{
  if(IsSpawned[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[15])) return SendClientMessage(playerid,COLOR_ERROR,"You have to be in the checkpoint inside a 24/7 store to use this command");
  ShowPlayerDialog(playerid,dialog_bw,DIALOG_STYLE_LISTBOX,"Buy weapon","Chainsaw ($1500)\nFlowers ($5)\nBaseball bat ($100)\nBeer ($20)\nWallet ($1000)\nParachute($500)","Choose","Cancel");
  return 1;
}
And under OnDialogResponse:
pawn Код:
if(dialogid == dialog_bw && response == 1)
{
  new string[16];
  format(string,sizeof(string),"/buy %d",listitem);
  OnPlayerCommandText(playerid,string);
}
Reply
#7

Thank you for the quick reply, and thank you for the help.


Just 1 more question, How can i make it so, If a person enters the checkpoint the dialog pops up on its own? and when the person buys something the dialog doesn't close until the person presses, cancel?


Plus, i need help with adding the items, i have no idea how too
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)