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 2176 177 178338 339 Next To the start

old RPG SHOP

Kostyan1996
User Off Offline

Quote
OMG! ITS VERY HARD FOR ME!!!
Give plz rpg shop script and say me how to USE THAT!!!1111ONEONEoneone...
Thank

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
can someone help with this script :
if sample==nil then sample={} end
sample.gl={}
sample.gh={}
addhook("always","sample.gl.always")
addhook("say","sample.gh.say")

function sample.gl.always()
parse("sethealth 1 250")
parse("setmaxhealth 1 250")
end

function sample.gh.say(p,txt)
if (txt=="god 0") then freehook("always","sample.gl.always"); end
if (txt=="god 0") then parse("killplayer 1"); end
if (txt=="god 1") then addhook("always","sample.gl.always"); end
if (txt=="god 1") then parse("equip 1 83"); end
end

its right but .. i ned like god just for cts ( all of cts team )

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Quote
@ Khaleed

All of CTs have god mode? Well try this code then (I did a change, so don't mind OK?) (Fixed up, Thanks Flacko! )

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
if khaleed==nil then khaleed={} end 
khaleed.gl={} 
khaleed.gh={} 

addhook("always","khaleed.gl.always") 
addhook("say","khaleed.gh.say") 

--This function will save me some writing 
--to get the team of a player 
function p_team(id) return player(id,"team") end 

function khaleed.gl.always() --Always hook has no parameters 
	--Loop thru all the players in server 
	for indx,id in ipairs(player(0,"table")) do 
		if p_team(id)==2 then 
			parse("sethealth "..id.." "..250); 
			parse("setmaxhealth "..id.." "..250); 
		end 
	end 
end 

function khaleed.gh.say(id,txt) 
     --Turn to lowercase so the cmd is case-unsensitive 
	txt = txt:lower() 
	if p_team(id)==2 then 
		if txt=="god 0" then 
			freehook("always","khaleed.gl.always"); 
			parse("killplayer "..id); 
		elseif txt=="god 1" then 
			addhook("always","khaleed.gl.always"); 
			parse("equip "..id.." "..83); 
		end 
	end 
end
edited 3×, last 14.04.10 02:40:55 pm

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
math.random = (0, trigger("blabla"))

or :

1
math.random = (0, ("trigger blabla"))

What is better and what is wrong, if this two codes are bad write me that good code
edited 2×, last 18.03.10 04:20:41 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Drone: None of them is right.
1
2
3
4
5
6
7
8
math.randomseed(os.time())

func()
	local rand = math.random(0,25) --generate number in range [0;25]
	if rand == 0 then --so chances will be 1/25
		--do stuff
	end
end

old Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Quote
DRoNe has written
1
math.random = (0, trigger("blabla"))

or :

1
math.random = (0, ("trigger blabla"))

What is better and what is wrong, if this two codes are bad write me that good code
You can only use numbers on that I guess...
1
math.random = (0, 10) -- [i]// This will perform a random calculation between 0 and 10, as far as I know.[/i]
In pros this code could be applied to almost any of the cs2d functions, although the cons would be that I don't really know nor do I have any examples of how this could be used since I'm not a good scripter. Appreciate my effort to help because I've been gone for a while...
edited 1×, last 18.03.10 05:35:07 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Kimkat: Help is always appreciated

@Pikachu: Your code has some small mistakes, I commented it and I think it should be fixed.
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
if khaleed==nil then khaleed={} end
khaleed.gl={}
khaleed.gh={}

addhook("always","khaleed.gl.always")
addhook("say","khaleed.gh.say")

--This function will save me some writing
--to get the team of a player
function p_team(id) return player(id,"team") end

function khaleed.gl.always()--Always hook has no parameters
	--Loop thru all the players in server
	for indx,id in ipairs(player(0,"table")) do
		if p_team(id)==2 then
			parse("sethealth "..id.." "..250);
			parse("setmaxhealth "..id.." "..250);
		end
	end
end

function khaleed.gh.say(id,txt)
	--Turn to lowercase so the cmd is case-unsensitive
	txt = txt:lower()
	if p_team(id)==2 then
		if txt=="god 0" then
			freehook("always","sample.gl.always");
			parse("killplayer "..id);
		elseif txt=="god 1" then
			addhook("always","sample.gl.always");
			parse("equip "..id.." "..83);
		end
	end
end
edited 2×, last 18.03.10 10:01:32 pm

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Flacko has written
@Kimkat: Help is always appreciated

@Pikachu: Your code has some small mistakes, I commented it and I think it should be fixed.
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
if khaleed==nil then khaleed={} end
khaleed.gl={}
khaleed.gh={}

addhook("always","khaleed.gl.always")
addhook("say","khaleed.gh.say")

--This function will save me some writing
--to get the team of a player
function p_team(id) return player(id,"team") end

function khaleed.gl.always()--Always hook has no parameters
	--Loop thru all the players in server
	for indx,id in player(0,"table") do
		if p_team(id)==2 then
			parse("sethealth "..id.." "..250);
			parse("setmaxhealth "..id.." "..250);
		end
	end
end

function khaleed.gh.say(p,txt)
	--Turn to lowercase so the cmd is case-unsensitive
	txt = txt:lower()
	if p_team(id)==2 then
		if txt=="god 0" then
			freehook("always","sample.gl.always");
			parse("killplayer "..id);
		elseif txt=="god 1" then
			addhook("always","sample.gl.always");
			parse("equip "..id.." "..83);
		end
	end
end

on my server it says :
LUA ERROR: sys/lua/God.lua:14: attempt to call a table value

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
use find and replace to apply the following patch

1
for indx,id in player(0,"table") do

=>

1
for indx,id in ipairs(player(0,"table")) do

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
leegao has written
use find and replace to apply the following patch

1
for indx,id in player(0,"table") do

=>

1
for indx,id in ipairs(player(0,"table")) do

lol no 1 can do it i think :S
it says on console :
LUA ERROR: sys/lua/God.lua:10: bad argument #1 to 'player' <number expected, got nil>
its on :
[code]
function p_team(id) return player(id,"team") end
[code/]

old Re: Lua Scripts/Questions/Help

Fasttt
User Off Offline

Quote
1
2
3
4
5
6
7
marks = {1,2,3,4,5,6}

mark_1 = marks[1]
mark_2 = marks[2]
mark_3 = marks[4]
mark_4 = marks[5]
mark_5 = marks[6]

how to optimize this code? I mean like this:

1
2
3
for i = 1, #marks, 1 do
mark_..i = marks[i]
end

but my function does not works

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Ah, that's pretty easy.
But It's pointless your idea of making stuff like that.

Fix:

1
2
3
4
5
6
7
8
local i
local marks = {1,2,3,4,5,6}

for i = 1, #marks, 1 do
	_G["mark_"..i] = marks[i]
end

print(mark_1.." "..mark_2) --> "1 2"

old Re: Lua Scripts/Questions/Help

leoska
User Off Offline

Quote
GOD mod???

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function array(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
player_count=game('sv_maxplayers')
pl_god=array(player_count)

addhook("hit","_hit")
function _hit(p)
if pl_god[p] == 1 then return 1; end
end

addhook("say","_say")
function _say(p,t)
if (t=='god 1') then pl_god[p]=1 return 1; end
if (t=='god 0') then pl_god[p]=0 return 1; end
end

old Re: Lua Scripts/Questions/Help

Fasttt
User Off Offline

Quote
thank you, Blazzingxx. in my example my idea is really stupid, but it's just example. code of my script is too huge to show its full here

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Flacko has written
Ugh
1
2
3
function khaleed.gh.say(p,txt)
--Change that to
function khaleed.gh.say(id,txt)

nothing ..
like it just protects from he
but like if someone shoot me i lose health

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
Hello,
I want to make a pm mod myself.
I want to make a command like this:
1
pm <ID> <MESSAGE>
So now i want to find out <ID> and <MESSAGE>
Pls help
(sorry for bad english)

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
2
3
4
5
addhook("startround","blablafunc")
function blablafunc(trigger)
blabla = math.random(0,1)
	parse ("trigger ..blabla")
end

Why it does not work?

old Re: Lua Scripts/Questions/Help

Patasuss
User Off Offline

Quote
@DRoNe
1
2
3
4
5
addhook("startround","blablafunc")
function blablafunc(trigger)
blabla = math.random(0,1)
     parse ("trigger "..blabla)
end

But pls help me with my prob too
To the start Previous 1 2176 177 178338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview