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 2157 158 159338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
wups has written
GINO has written
i have a new lua this works title god mode+admin mode
just rename my rcon pw to your rcon pw


Wow, does that code really works?
Itt looks tasty..

Yeah, it looks like it tastes like piss

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Why do you guys use Max health + armor when you are creating God mod?
Why don't you block bullets / remove damage?

I created a god mode script which uses LeeGao's string lua script. I don't have it anymore though

Spoiler >

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
LinuxGuy has written
Why do you guys use Max health + armor when you are creating God mod?
Why don't you block bullets / remove damage?

I created a god mode script which uses LeeGao's string lua script. I don't have it anymore though

Spoiler >

Nice (:
But couldn't there be another way to type the 32 0's in the "god"-table?

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Anders4000 has written
Nice (:
But couldn't there be another way to type the 32 0's in the "god"-table?

probably arrays, but i've got no idea how to implement them.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
1
2
3
4
5
6
7
function t_array(m)
	local a = {}
	for i = 1, m do a[i]=0 end
	return a
end

god = t_array(32)

Actually, now I don't use arrays for such a things.
edited 1×, last 07.02.10 06:45:07 pm

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Blazzingxx has written
1
2
3
4
5
6
7
function t_array(m)
	local a = {}
	for i = 1, m do a[i]=0 end
	return a
end

god = t_array(32)

Thanks alot! Lets see how it looks now:

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
if not string.split then dofile("sys/lua/string.lua") end

function t_array(m)
	local a = {}
	for i = 1, m do a[i]=0 end
	return a
end

god = t_array(32)

--Hooks
addhook("join", "godzero")
addhook("say", "hook_say")
addhook("hit","hook_hit")

--Functions
function godzero(i)
	god[i] = 0
end

function hook_say(i, text)
	--text:qsplit() splits a string based on spaces and quotes
	local cmd = text:qsplit()

	if cmd[1] == "!makegod" then
		local i2 = tonumber(cmd[2])
		if not (i) then return end
		god[i2] = 1
	end
end

function hook_hit(i,source,weapon,hpdmg,apdmg)
	if (god[i] == 1) then
		return 1
	end
end
edited 1×, last 07.02.10 06:56:11 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@Linuxguy,
You should include string.split function since many users here are too lazy.

Suggestion, use such as boolean variables for "god" declaring.

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
@Linuxguy,
You should include string.split function since many users here are too lazy.

Suggestion, use such as boolean variables for "god" declaring.


I agree with your boolean (;
...I think i might read something about the string function on lua's homepage - Don't understand it :p

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
You should use booleans as Blazzing said, this way you can toggle godmode on/off with bool = !bool

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
godtable = {}
for i=1,32 do godtable[i] = false end

function split(str,tok)
	tok = tok or " "
	tok = "[^"..tok.."]+"
	local t = {}
	for word in str:gmatch(tok) do
		table.insert(t,word)
	end
	return t
end

addhook("join","godfalse")
function godfalse(id)
	godtable[id] = false
end

addhook("say","sayz")
function sayz(id,txt)
	txt = split(txt," ")
	if txt[1]:lower() == "!makegod" then
		if txt[2] then
			local p = tonumber(txt[2])
			godtable[p] = !godtable[p] --HERE
			return 1
		end
	end
end

addhook("hit","godhit")
function godhit(id,src,wpn,hpdmg,admg)
	if godtable[id] then
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
What you exactly wanna to make with assert(arg, out) function?
This function like safety check thought. (Helps on error exceptions)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
1
2
3
4
5
6
7
8
function lol(a,b)
	assert(b,"Error in parameter #2")
	print(a+b)
end

lol(1)
--Output
--LUA ERROR: Error in parameter #2
edited 1×, last 07.02.10 08:35:20 pm

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Well, here is my script:

Spoiler >

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
LinuxGuy has written
Well, here is my script:

Spoiler >


Lol, don't credit me It was Blazzingxx that solved it (: ...I think
I just surguested (:

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
- Dark Void - has written
I am having trouble understanding the function assert()
I have read about it on www.lua.org but I still have trouble understanding its uses.


The lua equivalent of assert is as below:

1
2
3
4
function assert(obj, msg)
	if not obj then error(msg, 0) end
	return obj
end

therefore, if the first parameter is a false value (nil or false), then the function raises an error, else it just returns the object.

old Re: Lua Scripts/Questions/Help

Zeik
User Off Offline

Quote
Hi again

am trying to put a hudtxt2 but it gives me this error:
')' expected near 'player'

1
parse('hudtxt2 '..id..' 2 "©250070000  Vida: ..'player(id,"health")'" 420 420 1')

I want to show the HP in the hudtxt...
(I don't know if the pos is right lol)

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
RiT has written
Hi again

am trying to put a hudtxt2 but it gives me this error:
')' expected near 'player'

1
parse('hudtxt2 '..id..' 2 "©250070000 Vida: ..'player(id,"health")'" 420 420 1')


I want to show the HP in the hudtxt...
(I don't know if the pos is right lol)

I think the problem is that you`ve made a mistake by typing an extra ',like so:
1
parse('hudtxt2 '..id..' 2 "©250070000 Vida: ..'player(id,"health")[b]'[/b]" 420 420 1')
Try this and let me know if it works,sorry I am too lazy to test it :I
1
parse('hudtxt2 '..id..' 2 "©250070000 Vida: ..'player(id,"health")" 420 420 1')

old Re: Lua Scripts/Questions/Help

GINO
BANNED Off Offline

Quote
you have many mistakes

1
parse("hudtxt2")"player("id")"player(id,"health")"

now try this i reaserch so much for just this thing
if it doesent work lets think all that its imposible
To the start Previous 1 2157 158 159338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview