English Lua Scripts/Questions/Help

6,770 replies
Goto Page
To the start Previous 1 2 ... 282 283 284 ... 338 339 Next To the start
18.10.10 07:00:14 pm
Up
Triple H
User
Offline Off
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 ?
18.10.10 07:54:19 pm
Up
byengul
User
Offline Off
Code:
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
After 2 years i'm back to cs2d. cookie for everyone
18.10.10 08:35:46 pm
Up
Banaan
User
Offline Off
@Triple H look in the logs and look for error messages
18.10.10 09:21:26 pm
Up
Danikah
User
Offline Off
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?
18.10.10 09:58:02 pm
Up
Triple H
User
Offline Off
I have to delete sfx in sxf/blah/blah.wav and now works thanks.
19.10.10 12:56:31 am
Up
Smuckie
User
Offline Off
Fonduta has written:
@hyh2: Can you please download the new code and send me the download link? I cannot edit LUA AT ALL!
-
19.10.10 06:49:32 am
Up
hyh2
COMMUNITY BANNED
Offline Off
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?
IMG:http://www.graphicsgrotto.com/animatedgifs/comments/thankyou/images/agcthankyou4.gif

Admin/mod comment:

Stop flaming. /TheKilledDeath
19.10.10 12:18:38 pm
Up
saladface27
User
Offline Off
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?

Code:
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
19.10.10 12:50:36 pm
Up
Tajifun
User
Offline Off
Hey.
can anybody tell me how to make a "big" menu like this:
http://www.unrealsoftware.de/u_scr/u202b_4c8630a2s3.jpg

btw:
Its mat5b's RPG script. not mine :b
Tajifun yay.
19.10.10 01:04:30 pm
Up
Banaan
User
Offline Off
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...
19.10.10 02:21:42 pm
Up
RyceR
User
Offline Off
Can anybody give me script to save chat in sys/lua/CHAT.txt file?
like:
Code:
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!
IMG:http://img704.imageshack.us/img704/4043/userbargimp.png
19.10.10 02:36:09 pm
Up
Tajifun
User
Offline Off
Thanks Banaan. :]

You know how to make a menu like in weiwens pokemon script:

Code:
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
Tajifun yay.
19.10.10 02:37:36 pm
Up
saladface27
User
Offline Off
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 >
19.10.10 02:49:44 pm
Up
DannyDeth
User
Offline Off
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.
19.10.10 03:02:52 pm
Up
RyceR
User
Offline Off
to random menu for any player try use it:
Code:
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
IMG:http://img704.imageshack.us/img704/4043/userbargimp.png
19.10.10 03:10:39 pm
Up
Banaan
User
Offline Off
Tajifun has written:
Thanks Banaan. :]

You know how to make a menu like in weiwens pokemon script:

Code:
1
2
3
4
5
6
7
8
9
10
Title
[ Button 1 ]
[ Button 2 ]


-- empty :o



[ Button 3/9 ]


Do you mean
Code:
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:
Code:
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
19.10.10 03:31:59 pm
Up
saladface27
User
Offline Off
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.
19.10.10 03:33:55 pm
Up
Lee
Moderator
Offline Off
@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:
Code:
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 >
19.10.10 03:36:04 pm
Up
Glix
User
Offline Off
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
Create free website for your clan! Create server control panel webE --->http://www.000webhost.com/581961.html
Up
Jaso
BANNED
Offline Off
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.
To the start Previous 1 2 ... 282 283 284 ... 338 339 Next To the start