Forum

> > CS2D > Scripts > Spawn Buildings Script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn Buildings Script

4 replies
To the start Previous 1 Next To the start

old Spawn Buildings Script

Ahmad
User Off Offline

Quote
Hello, i was trying to make a script more efficient (spawning buildings) and i made this code:

Spoiler >


It doesnt work for me and I was wondering if anyone could tell me what ive done wrong.

help will be appreciated

old Re: Spawn Buildings Script

Apache uwu
User Off Offline

Quote
Well many times when I write a script I see where it repeats.

Instead of copy & paste you can simply check if the button is not zero, then run the code with the button that the user pressed.

ex.

1
2
3
4
5
6
7
function objectmenu(id,title,buton)
	if title=="Spawn building" then
		if buton~=0 then
			menu(id,"'..spawny[button]..',Up,Down,Left,Right,Back")
		end
	end
end

old Re: Spawn Buildings Script

krabob
User Off Offline

Quote
@user Apache uwu: You can't have "buton" then have "button", it should be like this:

1
2
3
4
5
6
7
function objectmenu(id,title,button)
     if title=="Spawn building" then
          if button~=0 then
          menu(id,"'..spawny[button]..',Up,Down,Left,Right,Back")
          end
     end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview