Currently I'm reseeding math.random using os.time everytime my function is called. Is this necessary?
Forum
CS2D Scripts Lua Scripts/Questions/HelpCurrently I'm reseeding math.random using os.time everytime my function is called. Is this necessary?
steam-cs2d has written
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
addhook("use","player_use") function player_use(id,trigger) 	if(trigger=="339") then 		parse("equip "..id.." 1")end 	if(trigger=="337") then 		parse("equip "..id.." 2")end 	if(trigger=="338") then 		parse("equip "..id.." 3")end 	end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("use","player_use_weapon") function player_use_weapon(id, type_, _, x, y) 	if type_ ~= 100 then return end 	trigger = entity(x, y, "name") 	hash = { 		["339"] = 1, 		["337"] = 2, 		["338"] = 3, 		-- Add in additional entries here if necessary. 	} -- For a better level of abstraction that decreases code redundancy 	local equip = "equip %s %s" 	if hash[trigger] then 		parse(equip:format(trigger, hash[trigger])) 	end end
Quote
Currently I'm reseeding math.random using os.time everytime my function is called. Is this necessary?
Nah, once should be enough. Calling randomseed doesn't actually accumulate any significant overhead since the random function is usually a lazy generator, but no one can guarantee that always taking the first result of a progressive number of random generators is truly random.
my server like it buy "it" when click the trigger_use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("use","player_use_weapon") function player_use_weapon(id, type_, _, x, y) if type_ ~= 100 then return end trigger = entity(x, y, "name") hash = { ["339"] = 1, ["337"] = 2, ["338"] = 3, -- Add in additional entries here if necessary. } -- For a better level of abstraction that decreases code redundancy local equip = "equip %s %s" if hash[trigger] then parse(equip:format(trigger, hash[trigger])) end end
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("endround","playsound") function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2.wav\"") elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1.wav\"") end end
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("endround","playsound") function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2.wav\"") elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1.wav\"") end end
Triple H has written
I need help with my script "endround" If I want to play first song and next round second sound and at next round another sound. What should I edit in my script
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("endround","playsound") function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2.wav\"") elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1.wav\"") end end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("endround","playsound") sound1 = 0 sound2 = 0 function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2."..sound2..".wav\"") 		sound2 = sound2 + 1 		if (sound2 == 3) then sound2 = 0 end elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1."..sound1..".wav\"") 		sound1 = sound1 + 1 		if (sound1 == 3) then sound1 = 0 end end end
first round it will play zxc2.0, second round zxc2.1, third round zxc 2.2, fourth round zxc2.0 again, etc.
can some 1 tell me all the times
like
day , hour ,seconds , minutes ,month ,year
and like that
?
I want something like this
ROUND 1 CT WIN plays sound 1ct
ROUND 2 CT WIN plays sound 2ct
ROUND 3 T WIN plays sound 1t
ROUND 4 T WIN plays sound 2t
something like that
If CT wins, the ct sound will be ct sound + 1, if T wins, the t sound will be t sound + 1
TDShuft has written
based in os.timer
can some 1 tell me all the times
like
day , hour ,seconds , minutes ,month ,year
and like that
can some 1 tell me all the times
like
day , hour ,seconds , minutes ,month ,year
and like that
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
os.date("*t") -- Returns the following table --[[-- { 	year = 2010, 	month = 10, 	day = 19, 	hour = 14, 	min = 28, 	sec = 16, 	wday = 3, -- Day of Week 	yday = 292, -- Day of the year (out of 365) 	isdst = true -- Are we in Daylight Saving time } So you can do something like print(os.date("*t").year) --]]--
I kill T
He dies and he drops something he didnt had (like laser)
i tried it with some kill hooks and stuff but i dont know much about X and Y coordination stuff so please help me
Thanks afterwards! BureX !
EDIT :
IGNORE WHAT I WROTE UP THERE I GOT IT WORKIN'
only i got this problem now
edited 1×, last 19.10.10 09:19:22 pm
1
LUA ERROR: sys/lua/endround.lua:8: malformed number near '4FUN'
My script looking like that :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("endround","playsound") sound1 = 0 sound2 = 0 function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2."CoN_(FFA)(4FUN)/ct20".wav\"") sound2 = sound2 + 1 if (sound2 == 3) then sound2 = 0 end elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1."CoN_(FFA)(4FUN)/nrs2".wav\"") sound1 = sound1 + 1 if (sound1 == 3) then sound1 = 0 end end end
hyh2 has written
Link biatch?
Fonduta has written
Fonduta has written
@hyh2: Can you please download the new code and send me the download link? I cannot edit LUA AT ALL!
Link biatch?
http://www.mediafire.com/?hcrkjwdffvbha8k
I want to remove the Laser, RPG, and Super Armor from the buying list.
Also, instead of saying "You have not enough money!" make it say "You do not have enough money." and put the $ sign on the left side of the amount, instead of the right. Like this $800.
Edit the script, and give me the new download link.
It is the Advanced buying menu script.
Triple H has written
After puting this script with endround i have this error
My script looking like that :
1
LUA ERROR: sys/lua/endround.lua:8: malformed number near '4FUN'
My script looking like that :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("endround","playsound") sound1 = 0 sound2 = 0 function playsound(mode) if mode==1 or mode==50 or mode==40 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2."CoN_(FFA)(4FUN)/ct20".wav\"") sound2 = sound2 + 1 if (sound2 == 3) then sound2 = 0 end elseif mode==2 or mode==51 or mode==41 then parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1."CoN_(FFA)(4FUN)/nrs2".wav\"") sound1 = sound1 + 1 if (sound1 == 3) then sound1 = 0 end end end
This is a clean version:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("endround","playsound") sound1 = 0 sound2 = 0 function playsound(m) 	if m==1 or 40 or 50 then 		parse("sv_sound \"CoN_(FFA)(4FUN)/zxc2.CoN_(FFA)(4FUN)/ct20.wav\"") 			sound2 = sound2 + 1 		if (sound2 == 3) then sound2 = 0 end 	elseif m==2 or 41 or 51 then 		parse("sv_sound \"CoN_(FFA)(4FUN)/zxc1.CoN_(FFA)(4FUN)/nrs2.wav\"") 			sound1 = sound1 + 1 		if (sound1 == 3) then sound1 = 0 end 	end end
Untested.
Triple H, you put quotes in the parse that were just messed up.. it made cs2d think that you wanted ct20".wav parsed as a variable well basically you screwed up and i fixed it up here.
||========================================||
@TDShuft, please refer to the info.txt that is in the lua folder before asking such questions about the image function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- image("path",x,y,mode,[pl])	Creates an image (dynamic object) on the map and returns the ID. 				Mode 0: floor image (covered by players etc) 				Mode 1: top image (covering players) 				Mode 2: HUD image (covering everything, part of the interface) 				Mode 3: super top image (covering everything on the map) 				Mode 101-132: draw under this player (id+100) 				Mode 201-232: draw over this player (id+200) 				Mode 133-164: draw over this player and over entities (id+132) 				When drawing at player, x and y are used this way: 				x<=0: do not rotate with player, x>0: rotate img with player 				y<=0: only draw if not covered by fog of war, y>0: draw always 				[pl] is an optional parameter. 0 (default value) means that 				all players see this image. If you set it to a player ID then 				only this player will see this image! 				The command returns the ID of the dynamic object image!
@Fonduta
edited 2×, last 20.10.10 06:50:14 am
Sorry for that =/
edited 1×, last 20.10.10 10:10:22 am