Items needed:
Time
Patience
So, we need to start with hook, like this:
1
addhook("spawn", "_spawn")
Now you have this one covered, we can do the function!
1
2
2
addhook("spawn", "_spawn") function _spawn(id)
You may wonder why there is the ID. It is because player spawns, it takes his id what we need in script.
Also, we need to add end to the script.
Lets look of the script now:
1
2
3
2
3
addhook("spawn", "_spawn") function _spawn(id) end
So, this script doesnt do anything yet. But it could be made equip you weapons with parse command.
Parse allows you to enter the console command you
want to use like trigger, equip, setmaxhealth, speedmod.
1
2
3
4
2
3
4
addhook("spawn", "_spawn") function _spawn(id) 	parse("equip "..id.." 30") end
So, in spawn it equips the player with AK-47.
Thats it, basic and simple script..
But you may need some randomness to make it more fun, always spawning with AK-47 isn't that fun.
So, we use math.random to get the randomisation.
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("spawn", "_spawn") function _spawn(id) 	local random = math.random(1, 2) 	if random == 1 then 		parse("equip "..id.." 30") 		elseif random == 2 then 		parse("equip "..id.." 32") 	end end
Now you have the randomness between guns, so you can now possibly end with
an AK-47 or M4A1. You can also use the math.random in equip as well, like this:
1
2
3
4
2
3
4
addhook("spawn", "_spawn") function _spawn(id) 	parse("equip "..id.." "..math.random(1,89)) end
That should equip you with random item.
You may want that only CT get certain equips and Tr another. Then you can use this: player(id, "team")
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("spawn", "_spawn") function _spawn(id) 	local random = math.random(1, 2) 	if player(id, "team") == 1 then 		if random == 1 then 			parse("equip "..id.." 30") 		elseif random == 2 then 			parse("equip "..id.." 10") 		end 	elseif player(id, "team") == 2 then 		if random == 1 then 			parse("equip "..id.." 32") 		elseif random == 2 then 			parse("equip "..id.." 11") 		end 	end end
to get XM1014 or AK-47.
I hope you got the spark to start coding
Also, take a for reading.
Edit: Changed name to be better, and more info.
1× editiert, zuletzt 15.02.12 19:11:31