Forum

> > CS2D > Scripts > Auto equip on spawn
Forums overviewCS2D overview Scripts overviewLog in to reply

English Auto equip on spawn

14 replies
To the start Previous 1 Next To the start

old Re: Auto equip on spawn

Yates
Reviewer Off Offline

Quote
@user Promaster: No. Stop. Bad boy. Read the documentation. Use the return instead to equip items on spawn.

cs2d lua hook spawn

Quote
Attention: Do NEVER use the "equip" command within this hook! It will probably lead to problems! Use the return value of the hook instead!

old Re: Auto equip on spawn

apex2d
User Off Offline

Quote
i suck at codes but
Pls don't open the Spoiler
this is the nearest result
Spoiler >


That code will spawn a Gaskmask Beneath you

old Re: Auto equip on spawn

Mora
User Off Offline

Quote
@user apex2d: yes you are.

1
2
3
4
addhook("spawn","Equip_")
function Equip_(id)
	return 60
end
As yates mentioned, there is also example how to use it on link he provide:
IMG:https://i.imgur.com/nNcfioQ.png

old Re: Auto equip on spawn

Masea
Super User Off Offline

Quote
@user apex2d: If you're suck at it, why you needed to post on this thread? Or are you also suck as can't even think you shouldn't have done this?

old Re: Auto equip on spawn

PersonNamedVictor
User Off Offline

Quote
i know i meant how do i use the code mora gave. like do i put it in the console? do i put a special ent or trigger?

cause i want the ct's in my map to instantly come with a gasmask on them.

so it fits the lore of the map more

old Re: Auto equip on spawn

Masea
Super User Off Offline

Quote
Gas Masks aren't actually equipable though. If it is as well as up to cs2d lua hook spawn hook.

I could share the code but I'm not at the home now. It basically would be about spawning a gas mask under the player and set player position to anywhere and set back to the original position. And you'll eventually be equipped with a gas mask.

old Re: Auto equip on spawn

Talented Doge
User Off Offline

Quote
Here you are:

1
2
3
4
5
6
7
8
addhook("spawn", "_spawn")

function _spawn(p)
	parse("spawnitem 56 "..player(p, "tilex").." "..player(p, "tiley"))
	local x, y = player(p, "tilex"), player(p, "tiley")
	parse("setpos "..p.." "..(player(p, "tilex") + 0.5) * 32 + 16 .." ".. (player(p, "tiley") + 0.5) * 32 + 16)
	parse("setpos "..p.." "..x * 32 + 16 .." ".. y * 32 + 16)
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview