Forum
CS2D Scripts Lua Scripts/Questions/Help1
math.randomseed(os.clock())
1
print(math.random(1100))
For your money thing, try using another value to store the player's money, serverside. Update it every time the player gets money, and use hudtxt2 to show the value on his screen.
1
LUA ERROR:sys/lua/samples/Bounty_Hunter_DEMO.lua:61:attemp to index field 'mainmenu' (a function value)
Instead of using mainmenu to store the players' selections, use another table with a different name.
@DRoNE
Use math.random()
1
math.random(0, 5)
EDIT: ninja'd
Can you write me one example?, im begginer
1
parse ("sv_sound \"blabla/"[b]..math.random(1,3)..[/b]"\"")
is this good? if i want random sound file of 3 soundifles
You should try on your own before asking.
And i need last thing to my script, i don't know write
spawnplayer at T or CT spawn.
When do you want to spawn players at spawn base?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Players Spawn (Table) Script -- blazz = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} } function blazz.load() 	local x, y, name 	for x = 0, map([[xsize]]) do 		for y = 0, map([[ysize]]) do 			if entity(x,y,[[exists]]) then 				name = entity(x,y,[[typename]]) 				if name == [[Info_T]] then 					table.insert(blazz.spawn_t_x, x) 					table.insert(blazz.spawn_t_y, y) 				elseif name == [[Info_CT]] then 					table.insert(blazz.spawn_ct_x, x) 					table.insert(blazz.spawn_ct_y, y) 				end 			end 		end 	end end blazz.load()
and it here is possible?
1
parse ("spawnplayer "..id.."..info_ct.."..info_ct")
That's example how to use those tables.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
blazz = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} } function blazz.load() 	local x, y, name 	for x = 0, map([[xsize]]) do 		for y = 0, map([[ysize]]) do 			if entity(x,y,[[exists]]) then 				name = entity(x,y,[[typename]]) 				if name == [[Info_T]] then 					table.insert(blazz.spawn_t_x, x * 32) 					table.insert(blazz.spawn_t_y, y * 32) 				elseif name == [[Info_CT]] then 					table.insert(blazz.spawn_ct_x, x * 32) 					table.insert(blazz.spawn_ct_y, y * 32) 				end 			end 		end 	end end blazz.load() function blazz.setpos(p) -- Random Terrorists Spawning 	local team, id = player(p,[[team]]) 	if team == 2 then 		id = math.random(#blazz.spawn_t_x) 		parse(string.format([[setpos %s %s %s]],p,blazz.spawn_t_x[id],blazz.spawn_t_y[id])) 	elseif team == 1 then 		id = math.random(#blazz.spawn_ct_x) 		parse(string.format([[setpos %s %s %s]],p,blazz.spawn_ct_x[id],blazz.spawn_ct_y[id])) 	end end addhook([[spawn]],[[blazz.spawn]]) function blazz.spawn(p) 	blazz.setpos(p) end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
drspawn = { spawn_t_x = {}, spawn_t_y = {}, spawn_ct_x = {}, spawn_ct_y = {} } function drspawn.load() local x, y, name for x = 0, map([[xsize]]) do for y = 0, map([[ysize]]) do if entity(x,y,[[exists]]) then name = entity(x,y,[[typename]]) if name == [[Info_CT]] then table.insert(drspawn.spawn_ct_x, x * 32) table.insert(drspawn.spawn_ct_y, y * 32) end end end end end drspawn.load() function pldie(p) local team, id = player(p),[[team]]) 	if (team==2) then 		if (dr.lifes[id] >= 6) then 			if (player(id,die)) then 				id = math.random(#drspawn.spawn_ct_x) 				parse(string.format([[setpos %s %s %s]],p,drspawn.spawn_ct_x[id],drspawn.spawn_ct_y[id])) 				dr.lifes[id] = dr.lifes[id] - 1 				msg2(id,"©000255000Your lifes : '..dr.lifes[id]..'/4@C")			 			end 		end 	end end addhook([[spawn]],[[drspawn.spawn]]) function drspawn.spawn(p) drspawn.setpos(p) end
will this work? i chages your values(blazz) to (drspawn)
i combine your script with my ..
edited 3×, last 14.03.10 06:37:10 pm
I'm making a big Role-Playing Map and i want a level script how can i make a script like this;
Killing Players Gives Exp
Breaking Breakable things Gives Exp
I've another question but first i must know this level script
edited 1×, last 14.03.10 06:42:10 pm
I was asked to show the code, here it is. As you can see the color-coding is at the beginning of the string. Maybe it's simply because I'm trying to do it through Lua?
If I'm not wrong, you should use the Alt+169 code.
Btw, what did you mean by your character encoding?
i need a script with:
bind key (n) to jump, it can only jump over obstacle, and a stamina bar.
Thanks, now I know why the binds closed the game .
Can you tell me what mainmenu's good for? I'm just curious.