Forum

> > CS2D > Scripts > Random weapon
Forums overviewCS2D overview Scripts overviewLog in to reply

English Random weapon

6 replies
To the start Previous 1 Next To the start

old Random weapon

Jaso
BANNED Off Offline

Quote
I need a script for a button.
So when you press the button the script will check if you have enough money for example 500 and then it will give you an random weapon.
And you need to wait 20 seconds before you get the weapon.
And if you already have one weapon it says you already have a weapon.

But please remove this weapons/items from the script:
•Portal gun
•Laser
•Claws
•Mine
•Laser mine
•Snow ball
•No armors
•Flare
•And no gas grenade
edited 2×, last 14.02.11 03:49:10 pm

old Re: Random weapon

robed
User Off Offline

Quote
yes there is,it just cost 3000p
go to the second door and you will see ?box then press "E" ++++++WAAAAAACCCCHHHAAAAAAA+++++++

but the random box in that one is fast 1 second random weapon

i dont know if the 20seconds random box is possible

old Re: Random weapon

Clean
User Off Offline

Quote
@jaso
It's only possible to make if you have a map for your script.
Explaining why:
Because to make the script you want, it should contain position of your "button".
Something like:
x = 10
y = 67

Just an example.

old Re: Random weapon

KaBooMa
User Off Offline

Quote
Alright jaso, Sorry if i brought this thread back to life...i felt like such a new task was pasted by

idlove if the way i worked it didnt get trolled too only way i think you can. im sure there is a cleaner way

here is the code:

Spoiler >


Once you have all that in a .lua open it up and change the config. its on very top. for 20 seconds put 20

Also, to work this beauty, place tile 11 somewhere and say buygun. I did my test with a box10x10 and a 2x2 box with tile 11. If your unsure of what tile 11 is, just hover over tiles int he map editor. Tile 11 should be the eleventh one. Enjoy! Tell me if theres any problems. It should strip he player of ANY weapon already on and place the new one on.

EDIT: Opps, first reply wasnt fully updated. I was in a hurry. Should work now. Update me.

old Re: Random weapon

EngiN33R
Moderator Off Offline

Quote
Why so complicated, Akmin?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function contains(table, element)
    for _, value in pairs(table) do
        if value == element then
            return true
        end
    end
    return false
end

function initArray2(f,v)
	local cmd={}
	for c=1,f do
		cmd[c]=v
	end
	return cmd
end

boxused=initArray2(32,false)
price=1000
restrictedweapons={88,45,78,77,87,75,79,80,81,82,83,84,54,72} -- put restricted weapons here

function randomweapon(id)
	weapon=math.rand(1,88)
	if not (contains(restrictedweapons,weapon)) then
		parse("equip "..id.." "..weapon)
	else
		randomweapon(id)
	end
end

addhook("use","randbox")
function randbox(id)
	if (player(id,"tilex")==BUTTONX and player(id,"tiley")==BUTTONY) then
		if (not boxused[id] and player(id,"money")>=price) then
		randomweapon(id)
		boxused[id]=true
		parse("setmoney "..id.." "..(player(id,"money")-price))
		timer((dur*1000),"parse","lua boxused["..id.."]=false")
	elseif (not boxused[id] and player(id,"money")<price) then
		msg2(id,"You don't have enough money!")
	elseif (boxused[id]) then
		msg2(id,"You've already used the random box!")
	end
end
BUTTONX and BUTTONY are the button position in tiles.
It obviously works on button pressing, set the position yourself.
Wrote it in 5 minutes, please check for bugs.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview