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 246 47 48338 339 Next To the start

old Re: Lua Scripts/Questions/Help

KaiserWilhelm
User Off Offline

Quote
Just mod the lua script for classes already included in your sys/lua/sample folder. change all th names and weapons to what you want, add a random.math function for t spawns, and your set.

Or you could search through the other 45 pages of good lua, because this has already probably suggested.

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
is it possible to return more than one weapon for the spawn hook using only one variable

eg. arena = 51,47

--on spawn
return arena

something like that?

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
Read the info.txt and your answer is yes.

1
2
3
4
5
spawn(id)						on spawn
-id: player id
>return:	"" - (nothing) spawn with regular items
		"x" - spawn with melee weapon only
		"typeid,typeid,..." - spawn with these items and melee

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
addhook("menu","buymen")
function buymen(id,menu,sel)
     if (menu=="Select Extra Item (1/1)") then
          dolars = player(id,"money")
               if dolars>3999 then
	    parse("equip "..id.." 88")
                    parse("setmoney "..id.." "..player(id,"money")-4000)
                    msg2(id,"©255255255You have bought Portal Gun!")
               else
                    msg2(id,"©255000000Not enough money to buy Portal Gun!")
               end
               end

Guys, I need some help here.. how do I make that Portal Gun can buy ONE time only?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Quote
Guys, I need some help here.. how do I make that Portal Gun can buy ONE time only?

Make value :
portal = array(32)

dont forget that "portal == 1" then round starts.

Then you buy check if "portal = 1" and if it is, buy weapon & portal = 0

If you still dont know how to do that, I will make example.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Admirdee has written
and yes I need example for that

Serveration to call menu
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
34
35
36
37
38
39
40
41
42
function array(m)
	local arrays = {}
	for i = 1, m do
		arrays[i]=0
	end
	return arrays
end

portals = array(32)

function portal_menu(id)
	menu(id,'Do you want portal weapon?,YES!,NO!')	
end

addhook("startround","startrounds")
function startrounds()
	for i = 1,32 do
		if (player(i,"exists")) then
			portals[i] = 0
		end
	end
end

addhook("serveraction","serveractions")
function serveractions(id)
	portal_menu(id)
end

addhook("menu","menus")
function menus(id,menu,sel)
	if (menu=="Do you want portal weapon?") then
		if (sel == 1) then
			if (portals[id]<1) then
				portals[id] = 1
				parse('equip '..id..' 88')
				msg2(id,'You have portal weapon!@C')
			else
				msg2(id,'Only one portal for round!@C')
			end
		end
	end
end
Now if you are making something, dont forget credits

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
I need help with the sample script. every minute its soposed to show a msg but insted in the console i get error msg saying expected number got nill.the join msg works fine
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
--------------------------------------------------
-- Simple Advertising by Unreal Software        --
-- 22.02.2009 - www.UnrealSoftware.de           --
-------------------------------------------------- 

if sample==nil then sample={} end
sample.ads={}

--------------------------------------
-- WELCOME MESSAGE ON JOIN          --
--------------------------------------
addhook("join","sample.ads.join")
function sample.ads.join(p)
	msg2(p,"Welcome to my Server, "..player(p,"name").."!")
end


--------------------------------------
-- ADVERTISING EVERY MINUTE         --
--------------------------------------
addhook("minute","sample.ads.minute")
function sample.ads.minute()
	msg(p,"Hope your having fun, "..player(p,"name").."!")
	msg(p,"Counter-Strike 2D is awsome!")
end

old Re: Lua Scripts/Questions/Help

Kyky-Pyky
User Off Offline

Quote
playa slaya,
I'm sorry, rushed,
right
1
2
3
4
5
6
7
8
9
10
11
--------------------------------------
-- ADVERTISING EVERY MINUTE --
--------------------------------------
addhook("minute","sample.ads.minute")
function sample.ads.minute()
	for p in ipairs(player(0,"table"))
		do
			msg2(p,"Hope your having fun, "..player(p,"name").."!")
		end
	msg("Counter-Strike 2D is awsome!") 
end
edited 1×, last 31.08.09 12:12:22 pm

old Save functions needed

BetaM
User Off Offline

Quote
Spoiler >

I heard that you can save some variables to files. I want to save ac1, ac2, and ac3. How?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
"You". Me? Or who else?

You need to use write and reading functions.

Write:
f = assert(io.open(file_dir,'w'))
f:write(ac1..' '..ac2..' '..ac3)
f:close()
edited 1×, last 31.08.09 02:02:53 pm

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
It works, but ac1,ac2 and ac3 resets always when I restart the server, so it isn't actually working.
EDIT: OK, I spent 3 hours of work, and it works now!
edited 1×, last 31.08.09 03:57:24 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
mat5b has written
It works, but ac1,ac2 and ac3 resets always when I restart the server, so it isn't actually working.
EDIT: OK, I spent 3 hours of work, and it works now!

lol, You just need right hooks & also dont forget clear code.

Btw, You get how to read file?

old sfx

phihung940
User Off Offline

Quote
hey guys ! can you give the code of "Multikill sound" script plz !

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
it's already implemented. Just open the server.lua and search for a line called:
--dofile("sys/lua/samples/utsfx.lua")
and delete the two - in front of it:
dofile("sys/lua/samples/utsfx.lua")

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
playa slaya has written
how can i make it where insted of killing so many ppl in an ammont of time its how many you kill in all

I will help you, but I dont know what you mean ...
Retype your question
To the start Previous 1 246 47 48338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview