Forum

> > CS2D > Scripts > Spawn Item
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn Item

3 replies
To the start Previous 1 Next To the start

old Spawn Item

KhaledMaher
BANNED Off Offline

Quote
Well i know this easy for some guys
but i am new and you can say i am noob scripting too

i want to know how to make item spawn on the mouse position

√ Thanks for help

old Re: Spawn Item

Masea
Super 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
item_id = 1 --item id here. (example: 1 = usp)

positions = {}

addhook("join","_join")
function _join(id)
	positions[id] = {x = 0, y = 0}
end

addhook("clientdata","_cd")
function _cd(id,m,x,y)
	if m == 2 then
		positions[id].x, positions[id].y = x, y
	end
end

function spawn_item_mouse(id)
	reqcld(id,2)
	local x, y = math.floor(positions[id].x/32), math.floor(positions[id].y/32)
	parse("spawnitem "..item_id.." "..x.." "..y)
end
You didn't tell us when that item spawn. So I've made only the function for now. Use it wherever you want.
edited 1×, last 12.01.17 07:43:09 pm

old Re: Spawn Item

GeoB99
Moderator Off Offline

Quote
@user Masea: Your code will bug at 13 line cause of unexpected
,
before
positions[id].y
table.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview