Now I will tell you step by step what I've do
1.Copy Baaan has written
addhook("endround","playsound")
function playsound()
talive = player(0,"team1living")
if (#talive == 0) then
parse("sv_sound sfx/fun/unstoppable.wav")
else
parse("sv_sound sfx/fun/doublekill.wav")
end
end
2.Paste it to endround.lua
3.Then went to server.lua and write Quote
dofile("sys/lua/endround.lua")
4.Run game
5.After end of round sound doesn't play.
So I did something wrong ? 1
tilex, tiley = math.random(m.spawn1[1], m.spawn2[1], m.spawn3[1]), math.random(m.spawn1[2], m.spawn2[2], m.spawn3[2])
whats wrong?? please help me i want to make 3 spawn point @Triple H look in the logs and look for error messages Hello everybody!
I just want a simple (I repeat, simple, else I don't understand it ) LUA script which randomly chooses a player and teleports it to a certain point. Like mat5b's mg_multigame's LUA, but simpler. So, can somebody help me? I have to delete sfx in sxf/blah/blah.wav and now works thanks. Fonduta has written
@hyh2: Can you please download the new code and send me the download link? I cannot edit LUA AT ALL!
hyh2 COMMUNITY BANNED Offline
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? Admin/mod comment
Stop flaming. /TheKilledDeath Hi,
This code is meant to randomly choose a ct - but the ct won't get chosen if they have been previously.
The script chooses the cts in order of id, not randomly, eventhough i'm using math.random.
Does anyone know what i'm doing wrong?
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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
chosen=initArray(32)
placer=0
function choosePlacer(team)
local can_choose
can_choose={}
for i=1,32 do
if(player(i,"team")==team and chosen[i]==0)then
table.insert(can_choose,i)
end
end
if(# can_choose > 0)then
math.randomseed(os.clock())
placer=can_choose[math.random(1, # can_choose)]
chosen[placer]=1
print("chosen "..player(placer,"name").." (ID: "..placer..")")
else
print("FAILED")
end
end
addhook("second","init")
function init()
choosePlacer(2)
end
info.txt has written
Attach @b at the end of title for a bigger menu [...]
Never made any menu's myself, but I guess that should do it... Can anybody give me script to save chat in sys/lua/CHAT.txt file?
like:
1
2
3
[11:18 PM]RyceR says: Hi all!
[11:18 PM]BombeR-MaN says: Hi
[11:19 PM]StAr says: You must die, BombeR-MaN!
Thanks Banaan. :]
You know how to make a menu like in weiwens pokemon script:
1
2
3
4
5
6
7
8
9
10
Title
[ Button 1 ]
[ Button 2 ]
-- empty :o
[ Button 3/9 ]
edited 1×, last 19.10.10 02:44:52 pm
Lua is doing something very wierd...
I'm using math.random, but the code chooses players in an order!?
in a team of 32 CTs, my script picks players with IDs in the order of:
12,13,14,11,15,16,17,9,18,19,20,5 (can you see a pattern?)
i have a feeling its probably to do with my math.random?
heres my code, can someone help?
Spoiler function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
chosen=initArray(32)
placer=0
can_choose={}
function choosePlacer(team)
can_choose={}
choose=0
for i=1,32 do
if(player(i,"team")==team and chosen[i]~=1)then
table.insert(can_choose,i)
end
end
if(# can_choose > 0)then
math.randomseed(os.clock())
print("# can_choose ="..#can_choose)
choose=math.random(#can_choose)
can_choose["..choose.."]="..can_choose[choose])
placer=can_choose[choose]
chosen[placer]=1
print("chosen "..player(placer,"name").." (ID: "..placer..")")
else
print("FAILED")
end
end
addhook("second","init")
function init()
choosePlacer(2) --choose a ct
end
Umm, math.random cannot be perfectly random! 32 is on of those numbers that gets stuck in infinite pattern loops, and excludes some of the numbers. This is because computers are incapbale of being truly random. So some clever okey thought up a way to mess this up by using patterns that are additions/subtractions of certain numbers times'ed Pi and rounded off. This is how you get really random numbers. The problem lies within the person that thought of the way to do 'random' numbers in Lua. The only way you can change this is by altering CS2D's source code, which is illegal. So unfortunatly I do not know how to fix this. to random menu for any player try use it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("startround","round")
function round()
	stopsearch=0
end
addhook("ms100","random")
function random()
	first = math.random(1,#player(0,'table'))
	if player(first,"exits") and player(first,"health") > 0 then
		if player(first,"bot") then
			stopsearch=0
		else
			stopsearch=1
			menu(first,"Menu,Button 1,Button 2,Button 3")
		end
	end
end
Tajifun has written
Thanks Banaan. :]
You know how to make a menu like in weiwens pokemon script:
1
2
3
4
5
6
7
8
9
10
Title
[ Button 1 ]
[ Button 2 ]
-- empty :o
[ Button 3/9 ]
Do you mean
1
menu(id,"title,button 1,button 2,,,,,,,button 9")
-- as I said, I haven't really done menus so I don't know if this will work...
@ RyceR:
1
2
3
4
5
6
7
8
addhook("say","save")
function save(id,msg)
	content = "["..os.date("%I:%M").." "..string.upper(os.date("%p")).."] "..player(id,"name").." says: "..msg
	file = io.open("sys/lua/CHAT.txt","a")
	file:write(content.."\n")
	file:close()
end
DannyDeth has written
Umm, math.random cannot be perfectly random! 32 is on of those numbers that gets stuck in infinite pattern loops, and excludes some of the numbers. This is because computers are incapbale of being truly random. So some clever okey thought up a way to mess this up by using patterns that are additions/subtractions of certain numbers times'ed Pi and rounded off. This is how you get really random numbers. The problem lies within the person that thought of the way to do 'random' numbers in Lua. The only way you can change this is by altering CS2D's source code, which is illegal. So unfortunatly I do not know how to fix this.
Thanks for your help, hopefully it shouldn't have much of an effect on my final mod. Lee Moderator Offline
@saladface27:
Pseudo-random number generators need to be seeded first. Ideally, most languages automatically seed the generator if you don't explicitly seed it yourself, Lua on the other hand is pretty much the only one that does not.
Note: The first number generated by a seeded RNG is very nonsensitive so it is prone to collision with other firsts, simply discard the first call:
1
2
3
--@Top of the file
math.randomseed(os.time())
math.random() -- Discards the first value after seeding.
Here's the reason for there to be a need to seed a RNB:
More There's no way to synthetically generate random numbers as we ourselves do not truly know what random really means. However, we do have various sources to confirm that a large sample of random numbers follows a certain normal random distribution, so a RNB basically generates a sequence of numbers that conforms to this random distribution based on an initial parameter (the seed). Since this sequence is very volatile to even the slightest changes to the seed, we merely need a value that always changes with respect to the running time of the program, and the simplest set of values that satisfies this condition is the set of time (os.time()).
Code:
addhook("say","player_say")
function player_say(id,txt)
if(txt=="!usp") then
parse("equip "..id.." 1")end
if(txt=="!glock") then
parse("equip "..id.." 2")end
if(txt=="!deagle") then
parse("equip "..id.." 3")end
end
end
how make it like you need use it on map (trigger_use)(name, trigger)(trigger)(339) and he equip wen click that trigger!!
like that
Code:
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
sory for my bad english 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.