Forum

> > CS2D > Scripts > LFS3| Bot picks random classes
Forums overviewCS2D overview Scripts overviewLog in to reply

English LFS3| Bot picks random classes

2 replies
To the start Previous 1 Next To the start

old LFS3| Bot picks random classes

Ace Howl
User Off Offline

Quote
Hello!
Again... the problem and request.
1. I created a simple class script. The problem (request maybe) is how to make bots choose random class.
This is the script. Open the spoiler for code ( if this useful ).
More >


2. (This is an alternate) Same as the 1. I want all spawned bots equiped with specific weapon ( tried unfunctional "player(id,"bot") or "player(i,"bot")" ).

Hope someone solve it.
edited 2×, last 15.11.14 01:14:02 pm

old Re: LFS3| Bot picks random classes

EngiN33R
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
function m_spawn(id)
	if (player(id,"bot")) then
		p_menu(id,"Select Weapon Class",math.random(1,6)) -- change the last number of math.random to the amount of classes you have (right now you have 6 in your p_menu function)
		-- Alternatively, if you want to have the bots equipped with certain weapons and have certain armour/health values, write the parse statements in this block.
	else
		parse("setarmor "..id.." 1")
		parse("strip "..id)
		parse("setmaxhealth "..id.." 200")
		parse("setmoney "..id.." 500")
	end
end

The above should work. Though, if I were you, I would change the code in a few places – there are some things that aren't gonna work properly, like the endround function that won't work properly if it's ever actually executed, and your wpndmg lines. cs2d cmd mp_wpndmg requires the exact name of the weapon as it appears in the buy menu and in the player's inventory, not whatever you want to call it:

More >

old Thanks

Ace Howl
User Off Offline

Quote
Thanks for the solution. Actually, the Armor value ( which is appears as 1 ) is acting like select a class at once. I don't know how to select like that though. Anyway, thanks for the help.

[EDIT]New:
Sorry user EngiN33R, but the code doesn't work. The bot still have same state. This what is suppose to to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- This is the one that you stated

addhook("spawn","bot_spawn")
function bot_spawn(id)
	if (player(id,"bot")) then
		selecti(id,"Select Your Class",math.random(1,7))
	end
end

-- This is the menu
function selecti(id)
	menu(id,"Select Your Class,Assault,Special,Sniper,Support,Medic,Engineer,Anti Tank")
end
-- I updated to seven classes list
edited 3×, last 03.12.13 12:11:42 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview