Forum

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

English Spawn item

7 replies
To the start Previous 1 Next To the start

old Spawn item

J4x
User Off Offline

Quote
Hi us community, I was making this script, when you throw a smoke grenade armor, health and ammo should spawn, but the problem is the following: ERROR - "position is out of map bounds"

1
2
3
4
5
6
7
8
9
addhook("projectile","cmp")
function cmp(id,weapon,x,y)
    if weapon == 53 then
	parse("spawnitem 61 "..x.." "..y.."")
	parse("spawnitem 62 "..x.." "..y.."")
	parse("spawnitem 58 "..x.." "..y.."")
	parse("spawnitem 64 "..x.." "..y.."")
	end
end

I know this happens because items can only spawn in tiles but not in pixels , is there a way of checking item tile pisiton?

old Re: Spawn item

Apache uwu
User Off Offline

Quote
Spawnitem will only accept tile positions.

1
2
3
4
5
6
7
8
9
10
11
addhook("projectile","cmp")
function cmp(id,weapon,x,y)
x=math.floor(x/32)
y=math.floor(y/32)
	if weapon == 53 then
		parse("spawnitem 61 "..x.." "..y.."")
		parse("spawnitem 62 "..x.." "..y.."")
		parse("spawnitem 58 "..x.." "..y.."")
		parse("spawnitem 64 "..x.." "..y.."")
	end
end

old Re: Spawn item

archmage
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("projectile","cmp")
function cmp(id,weapon,x,y)
	if weapon == 53 then
		x = math.floor(x/32)
		y = math.floor(y/32)
		if ( x > 0 and x < map("xsize") ) then
			if ( y > 0 and y < map("ysize") ) then
     				parse("spawnitem 61 "..x.." "..y.."")
   				parse("spawnitem 62 "..x.." "..y.."")
  				parse("spawnitem 58 "..x.." "..y.."")
   				parse("spawnitem 64 "..x.." "..y.."")
			end
		end
    	 end
end

Might be "sizex" and "sizey" not sure. Or perhaps it isn't needed. I think it has to be within the map though.

old Re: Spawn item

Apache uwu
User Off Offline

Quote
I ran the script.

When you throw a smoke grenade it spawns:

• Primary Ammo
• Secondary Ammo
• Kevlar+Helm
• Medicine Kit

At the tile of the smoke grenade.

Very creative

old Re: Spawn item

J4x
User Off Offline

Quote
Thanks btw I wanted to make it each time you kill 4 player can u help me?

EDIT: Anyone?
edited 2×, last 17.10.11 04:57:34 am

old Re: Spawn item

DC
Admin Off Offline

Quote
you have to make an array for each player with a killcounter. take a look at the utsfx script in sys/lua/samples to get an idea how stuff like that works!

the counter there is even a bit advanced because it has a timer which resets it. of course you don't have to implement that timer stuff.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview