Forum

> > CS2D > General > Random Weapon?
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Random Weapon?

9 replies
To the start Previous 1 Next To the start

old Random Weapon?

redstar
User Off Offline

Quote
Hi all,

I want to create an entity to get a random weapon (like the mistery box in CoD 5)

Somebody know how to do it?

Thx

old Re: Random Weapon?

Zune5
COMMUNITY BANNED Off Offline

Quote
Yeah lua scripts basically. And even if you requested it to DC, he probably would make a .lua script instead.

old Re: Random Weapon?

DC
Admin Off Offline

Quote
yes. use a Lua script.
the cs2d command you need is spawnitem (see changelog). you have to call it in Lua with the parse command.

old Re: Random Weapon?

Lee
Moderator Off Offline

Quote
the concept is rather simple actually, all you need is a table that contains the code for all of the weapons, seed the random generator to the epoch time and use math.random(1, #wpntable) as the index, this will return a weapon code that is picked out at random.

old Re: Random Weapon?

redstar
User Off Offline

Quote
Thx you all, but i don't know how to do.
Can you tell me everything to do?

(sorry it's maybe wrong but im french --)

old Re: Random Weapon?

Tehmasta
User Off Offline

Quote
lee, you dont need math.random(1,#wpntable)
math.random(#wpntable) would suffice, since if you only pass 1 parameter, it chooses a random number from 1 to that number
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview