Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: givemoney

  1. #1
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts

    givemoney

    Code:
    if(menu == game["menu_ingame"] || (level.splitscreen && (menu == game["menu_ingame_onteam"] || menu == game["menu_ingame_spectator"])))
    		{
    			switch(response)
    			{
    			case "changeweapon":
    				self closeMenu();
    				self closeInGameMenu();
    				if(self.pers["team"] == "allies")
    					self openMenu(game["menu_weapon_allies"]);
    				else if(self.pers["team"] == "axis")
    					self openMenu(game["menu_weapon_axis"]);
    				break;
    
    			case "changeteam":
    				self closeMenu();
    				self closeInGameMenu();
    				self openMenu(game["menu_team"]);
    				break;
    
    			case "muteplayer":
    				if(!level.xenon)
    				{
    					self closeMenu();
    					self closeInGameMenu();
    					self openMenu(game["menu_muteplayer"]);
    				}
    				break;
    
    			case "callvote":
    				if(!level.xenon)
    				{
    					self closeMenu();
    					self closeInGameMenu();
    					self openMenu(game["menu_callvote"]);
    				}
    				break;
    			}
    
    			// givemoney
    			if(response.size > 9 && response.substr(0, 9) == "givemoney")
    			{
    				s = response.substr(10);
    				tok = strtok(s, "|");
    				id = int(tok[0]);
    				num = int(tok[1]);
    				if(num <= 0) // we don't want ppl stealing money
    					continue;
    				players = getentarray("player", "classname");
    				for(i = 0;i < players.size;i++)
    				{
    					if(players[i] != self && players[i] getentitynumber() == id)
    					{
    						players[i].money += num;
    						self.money -= num;
    						players[i] iprintlnbold(num + " money from " + self.name);
    					}
    				}
    			}
    		}
    Where is error in this givemoney?

    Thanks.

  2. #2
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Rocky View Post
    Code:
    if(menu == game["menu_ingame"] || (level.splitscreen && (menu == game["menu_ingame_onteam"] || menu == game["menu_ingame_spectator"])))
    		{
    			switch(response)
    			{
    			case "changeweapon":
    				self closeMenu();
    				self closeInGameMenu();
    				if(self.pers["team"] == "allies")
    					self openMenu(game["menu_weapon_allies"]);
    				else if(self.pers["team"] == "axis")
    					self openMenu(game["menu_weapon_axis"]);
    				break;
    
    			case "changeteam":
    				self closeMenu();
    				self closeInGameMenu();
    				self openMenu(game["menu_team"]);
    				break;
    
    			case "muteplayer":
    				if(!level.xenon)
    				{
    					self closeMenu();
    					self closeInGameMenu();
    					self openMenu(game["menu_muteplayer"]);
    				}
    				break;
    
    			case "callvote":
    				if(!level.xenon)
    				{
    					self closeMenu();
    					self closeInGameMenu();
    					self openMenu(game["menu_callvote"]);
    				}
    				break;
    			}
    
    			// givemoney
    			if(response.size > 9 && response.substr(0, 9) == "givemoney")
    			{
    				s = response.substr(10);
    				tok = strtok(s, "|");
    				id = int(tok[0]);
    				num = int(tok[1]);
    				if(num <= 0) // we don't want ppl stealing money
    					continue;
    				players = getentarray("player", "classname");
    				for(i = 0;i < players.size;i++)
    				{
    					if(players[i] != self && players[i] getentitynumber() == id)
    					{
    						players[i].money += num;
    						self.money -= num;
    						players[i] iprintlnbold(num + " money from " + self.name);
    					}
    				}
    			}
    		}
    Where is error in this givemoney?

    Thanks.
    First, you've put the "givemoney" code inside a switch() function without a case.

    Second, you are using some kind of struct (response.substr()) without it being defined.

  3. #3
    Lieutenant Loveboy's Avatar
    Join Date
    Nov 2012
    Posts
    546
    Thanks
    229
    Thanked 72 Times in 46 Posts
    Hello Rocky! You have put your script on the wrong place. Here is a nice tutorial how to give other players money: http://killtube.org/showthread.php?6...-other-players
    If you have got problems or errors there, then just write here.

  4. #4
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    i know how to make that with quick messages alone. i made it.. but i need by command /openscriptmenu givepower VALUE OF MONEY|ID

    ...

  5. #5
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Rocky View Post
    i know how to make that with quick messages alone. i made it.. but i need by command /openscriptmenu givepower VALUE OF MONEY|ID

    ...
    You need to precache the menu before you can use the name. Otherwise your menu will be -1.

  6. #6
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    Code:
    // givemoney
    			if(response.size > 9 && getsubstr(response, 0, 9) == "givemoney")
    			{
    				s = getsubstr(response, 10);
    				tok = strtok(s, "|");
    				id = int(tok[0]);
    				num = int(tok[1]);
    				if(num <= 0) // we don't want ppl stealing money
    					continue;
    				players = getentarray("player", "classname");
    				for(i = 0;i < players.size;i++)
    				{
    					if(players[i] != self && players[i] getentitynumber() == id)
    					{
    						players[i].money += num;
    						self.money -= num;
    						players[i] iprintlnbold(num + " money from " + self.name);
    					}
    				}
    			}
    I really dont understand how you think i need precache.

    I finded this.
    Code:
    	default:
    				str = strtok(response,"|");
    				if(str.size==3)
    				{
    					if(str[0]=="give")
    					{
    						id=int(str[1]);
    						num=int(str[2]);
    						players=getentarray("player","classname");
    						if(self.pers["money"]>=num && num>0 && isplayer(players[id]) && players[id]!=self)
    						{
    							players[id] ER_zumbis\_ER::givemoney(num);
    							self ER_zumbis\_ER::givemoney(num*-1);
    							printstr("gotmoney",players[id],self.name);
    
    						}
    						else if(num<0)
    							self iprintlnbold(&"ER_STOLEN_MONEY");
    					}
    				}
    				break;

  7. #7
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    You have not given us ONE good point of information.

    1. Where does your script fail?

    2. How does it fail?

    3. How do you call your script?

    4. Have you tried ANY debugging in your script?

    As long as your script seems to be ok from our point-of-view, there is very little we can do.

    Please answer the above points as extensively as possible, so we can actually help instead of just listen to you whine about some script not working

  8. #8
    Brigadier General
    Join Date
    Oct 2012
    Posts
    994
    Thanks
    20
    Thanked 588 Times in 388 Posts
    Quote Originally Posted by Rocky View Post
    Code:
    // givemoney
    			if(response.size > 9 && getsubstr(response, 0, 9) == "givemoney")
    			{
    				s = getsubstr(response, 10);
    				tok = strtok(s, "|");
    				id = int(tok[0]);
    				num = int(tok[1]);
    				if(num <= 0) // we don't want ppl stealing money
    					continue;
    				players = getentarray("player", "classname");
    				for(i = 0;i < players.size;i++)
    				{
    					if(players[i] != self && players[i] getentitynumber() == id)
    					{
    						players[i].money += num;
    						self.money -= num;
    						players[i] iprintlnbold(num + " money from " + self.name);
    					}
    				}
    			}
    I really dont understand how you think i need precache.

    I finded this.
    Code:
    	default:
    				str = strtok(response,"|");
    				if(str.size==3)
    				{
    					if(str[0]=="give")
    					{
    						id=int(str[1]);
    						num=int(str[2]);
    						players=getentarray("player","classname");
    						if(self.pers["money"]>=num && num>0 && isplayer(players[id]) && players[id]!=self)
    						{
    							players[id] ER_zumbis\_ER::givemoney(num);
    							self ER_zumbis\_ER::givemoney(num*-1);
    							printstr("gotmoney",players[id],self.name);
    
    						}
    						else if(num<0)
    							self iprintlnbold(&"ER_STOLEN_MONEY");
    					}
    				}
    				break;
    I finded this
    Good for you! So what? Why mention it? If it is giving you errors, please state the nature of the medical emergency.

  9. The Following User Says Thank You to Tally For This Useful Post:

    IzNoGoD (19th January 2014)

  10. #9
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    it dont have errors,only that with precache.. idk what Mitch think :]

  11. #10
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Rocky View Post
    it dont have errors,only that with precache.. idk what Mitch think :]
    Your code works like this:
    PHP Code:
    openscriptmenu -1 givepower|id|value (1)
    openscriptmenu -1 give|id|value (2
    You can do this: openscriptmenu givepower id|power. But the menu 'givepower' needs to be precached.
    PHP Code:
    precacheMenu("givepower"); 
    (this will give a error in console, because the menu isn't there)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •