Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2282 283 284338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Triple H
User Off Offline

Zitieren
Now I will tell you step by step what I've do

1.Copy
Baaan hat geschrieben
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
Zitat
dofile("sys/lua/endround.lua")

4.Run game
5.After end of round sound doesn't play.

So I did something wrong ?

alt Re: Lua Scripts/Questions/Help

byengul
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Danikah
User Off Offline

Zitieren
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?

alt geschlossen Re: Lua Scripts/Questions/Help

hyh2
COMMUNITY BANNED Off Offline

Zitieren
Fonduta hat geschrieben
Fonduta hat geschrieben
@hyh2: Can you please download the new code and send me the download link? I cannot edit LUA AT ALL!


Link biatch?

Admin/Mod Kommentar

Stop flaming. /TheKilledDeath

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Zitieren
info.txt hat geschrieben
Attach @b at the end of title for a bigger menu [...]


Never made any menu's myself, but I guess that should do it...

alt Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Zitieren
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!

alt Re: Lua Scripts/Questions/Help

Tajifun
User Off Offline

Zitieren
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 ]
1× editiert, zuletzt 19.10.10 14:44:52

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

DannyDeth
User Off Offline

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

alt Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Banaan
User Off Offline

Zitieren
Tajifun hat geschrieben
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

alt Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Zitieren
DannyDeth hat geschrieben
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.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
@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:
Mehr >

alt help please

Glix
User Off Offline

Zitieren
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

alt Need help with a good Flash Light Script.

Jaso
BANNED Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 2282 283 284338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht