Forum

> > CS2D > Scripts > Get Random Weapon and teleport
Forums overviewCS2D overview Scripts overviewLog in to reply

English Get Random Weapon and teleport

1 reply
To the start Previous 1 Next To the start

old Get Random Weapon and teleport

Jedediastwo
User Off Offline

Quote
Someone can help me with the script?

If player press buton X: 1, Y:1, they can get random kits. like:

1 - M4a1, Deagle, HE
2 - AK-47, Deagle, HE
3 - AWP , USP , HE
4 - RPG LAUNCHER, GLOCK, HE

And the player will be teleported to one of the tiles:
X: 10, Y: 10
X: 15, Y: 15
X: 20, Y: 20

old Re: Get Random Weapon and teleport

VADemon
User Off Offline

Quote
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
addhook("usebutton", "equipButton")

equipButtons = {
	{1, 1}	-- add more buttons if you need
}

equipTeleportLocations = {
	{10, 10},
	{15, 15},
	{20, 20}
}

-- http://www.cs2d.com/img/ref_items.png
equipKits = {
	-- The NAME must always be the first item in this table and don't forget to add it!
	{"Rifler Kit", 30, 51, 87, 57},
	{"Enforcer Kit", 41, 58, 3}
}

function equipButton(id, tilex, tiley)
	--msg("Tilex/y: ".. tilex .."|".. tiley)
	for k, coords in pairs(equipButtons) do
		--msg("Checking coords: ".. coords[1].."|".. coords[2])
		if coords[1] == tilex and coords[2] == tiley then
			
			equipKit(id, math.random(1, #equipKits))
			equipTeleport(id, math.random(1, #equipTeleportLocations))
			
		end
	end
end

function equipKit(id, key)
	msg2(id, "You were equipped with the ".. equipKits[ key ][1])
	for i = 2, #equipKits[ key ] do
		parse("equip ".. id .. " ".. equipKits[ key ][i])
	end
end

function equipTeleport(id, key)
	local x, y = equipTeleportLocations[key][1] * 32 + 16, equipTeleportLocations[key][2] * 32 + 16
	
	parse("setpos ".. id .." ".. x .." ".. y)
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview