Forum

> > CS2D > Scripts > Spawn item
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Spawn item

7 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Spawn item

J4x
User Off Offline

Zitieren
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?

alt Re: Spawn item

Apache uwu
User Off Offline

Zitieren
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

alt Re: Spawn item

archmage
User Off Offline

Zitieren
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.

alt Re: Spawn item

Apache uwu
User Off Offline

Zitieren
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

alt Re: Spawn item

J4x
User Off Offline

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

EDIT: Anyone?
2× editiert, zuletzt 17.10.11 04:57:34

alt Re: Spawn item

DC
Admin Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht