Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 2283 284 285338 339 Next To the start

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
@Lee: thanks for the explanation So I should use math.randomseed(os.time()) then use two instances of math.random (one to discard the first random number and another to generate my value)?
Currently I'm reseeding math.random using os.time everytime my function is called. Is this necessary?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
steam-cs2d has written
1
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
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.

old Re: Lua Scripts/Questions/Help

Glix
User Off Offline

Quote
moderator thanks this work, but i need in
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
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

old Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Quote
That's how looks corectly script for endround.

1
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

old Need help with a GOOD Flash light Script!

Jaso
BANNED Off Offline

Quote
I need a good flash light script i have been already looking for one i only finded 2 but the biggest problem was that if you are in very dark places you couldnt see anything with your flash light so my question is if some could create a (GOOD) Flash light script which gives more light in very dark places i need this to create horror maps so it would be nice if some one could create one or already has one.

old Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Quote
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
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

old Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Quote
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
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
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.

old Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Quote
do you mean
More >

?

old Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Quote
@Banaan: I think that you don't understand me
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

old Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Quote
Yeah the script does that, I was just too lazy to write it like that.

If CT wins, the ct sound will be ct sound + 1, if T wins, the t sound will be t sound + 1

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
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


1
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)
--]]--

old Random stuff drop

Casper-
User Off Offline

Quote
hey guys i wonder how can i make when player died and he spawns some item on floor like :
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 IMG:https://i51.tinypic.com/2dkbuyv.jpg
edited 1×, last 19.10.10 09:19:22 pm

old Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Quote
After puting this script with endround i have this error
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
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

old Re: Lua Scripts/Questions/Help

Smuckie
User Off Offline

Quote
hyh2 has written
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.

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Triple H has written
After puting this script with endround i have this error
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
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
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
- 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
Spoiler >
edited 2×, last 20.10.10 06:50:14 am

old Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Quote
Oops I appear to be blind... I think I just missed a page full of replies there.

Sorry for that =/
edited 1×, last 20.10.10 10:10:22 am
To the start Previous 1 2283 284 285338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview