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 2310 311 312338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
kNedLiik has written
1
2
3
4
5
6
7
8
9
10
addhook("spawn"equip")
function equip(id)
	if (player(id,"team") == 1) then
		parse("strip "..id.." 2")
	elseif (player(id,"team") == 2) then
		parse("strip "..id.." 2")
		parse("equip "..id.." 58")
		parse("equip "..id.." 6")
	end
end

I can help you kato just add me at skype.


Look above my friend (:

But i see that your hook was actually better than mine (:
Just a little mistake.

Kato use this hook and func instead:
1
2
addhook("spawn","fequip")
function fequip()

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
Anders4000 has written
kNedLiik has written
1
2
3
4
5
6
7
8
9
10
addhook("spawn"equip")
function equip(id)
	if (player(id,"team") == 1) then
		parse("strip "..id.." 2")
	elseif (player(id,"team") == 2) then
		parse("strip "..id.." 2")
		parse("equip "..id.." 58")
		parse("equip "..id.." 6")
	end
end

I can help you kato just add me at skype.


Look above my friend (:

But i see that your hook was actually better than mine (:
Just a little mistake.

Kato use this hook and func instead:
1
2
addhook("spawn","fequip")
function fequip()


how long are u scripting ?
You make script much complicated

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Just realized that your script is actually better than mine (:
Mine is more complicated. But that's cus I made a Roundstart hook. Then i have to make a for statement to get through all the players. But you use the spawn hook. Then you don't have to use a for statement to get through the players, cus the spawn hook is called for every player (:

Your script is smaller than mine. And it does the same, therefore yours is better.

Kato, listen to kNed, not me
- Anders4000

old Re: Lua Scripts/Questions/Help

AbAeterno
User Off Offline

Quote
Yay, i solved my problem

1
2
3
4
5
6
7
8
addhook("hit","pl_hit")
 function pl_hit(id, source)
  if (source>1) or (source == 1) then
   return 1
  else
   return 0
  end
 end

old Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Quote
PunishedNoob has written
Yay, i solved my problem

1
2
3
4
5
6
7
8
addhook("hit","pl_hit")
 function pl_hit(id, source)
  if (source>1) or (source == 1) then
   return 1
  else
   return 0
  end
 end


uhh i want to teach you something ..
1
2
3
4
-- you could use :
if (source>=1) then
--or
if (source>0) then
>= its above and the number like
">= 1" = 1 ,2 ,3 ..
">1" = 2,3,4 ..
"~=1" all the number exept 1
"==1" if == 1

well its more easy to you put
">=1" in

old Re: Lua Scripts/Questions/Help

Ice-cream16
User Off Offline

Quote
I want lear make Lua.
As example, i want make easy script with picture over* head player.(how in multigame).
Please write here this script and say what is what.
edited 1×, last 17.11.10 05:37:09 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
kNedLiik has written
Anders4000 has written
Someone tell me what rp means (: Is it the town maps?

RP = Role Play

Ahh, ty I actually found out looking at some scipts, but somehow forgot it again s:

Thanks (:
- Anders4000

old Re: Lua Scripts/Questions/Help

Blargh
User Off Offline

Quote
ok i'm noob into scripting

erm.. this is working but it's spamming the console with

Quote
Lua: Adding function 'imgf' to hook 'die'


and the server lags bad O.o
what did I do wrong?

1
2
3
4
5
6
addhook("die","imgf")
function imgf(id)
	freeimage(blargh[id])
	end
	end
end

also I want a script example something like ~ an area in tiles where players cant damage each others like a safezone
edited 1×, last 17.11.10 07:36:47 pm

old Re: Lua Scripts/Questions/Help

Blargh
User Off Offline

Quote
thanks admir

also I want a script example something like ~ an area in tiles where players cant damage each others like a safezone

where can i find all the hooks ?
edited 1×, last 17.11.10 07:44:09 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
kNedLiik has written
can someone explain me
1
for i = 1,#lol do


Eg:
1
2
3
for i = 1, 10 do	--This will go over the code below untill the variable(integer) i has reached 10. And it starts on 1.
	print("Hello "..i)
end

So in that example it will print out the following lines:
Spoiler >


If you didn't understand search: "For statement" on google (:
- Anders4000

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
1
for i = 1,#lol do

will only work like this:

1
2
3
4
lol = {1,54,68,10,68} --table
for i = 1,#lol do --it is like for i = 1,5 do,because lol has 5 ühm numbers
print(i)
end

Output has written
1
2
3
4
5

old Log Hook (AMX2D)

VaiN
User Off Offline

Quote
Tried searching and couldn't find any info on this.

I'm trying to change how logs work. I just want it to not log the unimportant repeated stuff like USGN server list and stats generation, so it's not flooding my logs with unnecessary data.

For some reason it seems to stop logging altogether after finding the string, instead of just ignoring what I'm specifying.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
init_mod("serverlog")

function hook_log_serverlog(text)
	if string.find(text,"U.S.G.N.: Sending serverlist") ~= nil then
		return 1
	elseif string.find(text, "U.S.G.N.: Serverlist") ~= nil then 
		return 1
	elseif string.find(text, "Cron Execution") ~= nil then
		return 1
	elseif string.find(text, "generating stats.") ~= nil then
		return 1
	elseif string.find(text, "stats generated in ") ~= nil then
		return 1
	else
		return 0
	end
end

return serverlog.name

Edit: Nevermind it's working fine
edited 1×, last 17.11.10 10:16:15 pm

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
VaiN has written
Tried searching and couldn't find any info on this.

I'm trying to change how logs work. I just want it to not log the unimportant repeated stuff like USGN server list and stats generation, so it's not flooding my logs with unnecessary data.

For some reason it seems to stop logging altogether after finding the string, instead of just ignoring what I'm specifying.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
init_mod("serverlog")

function hook_log_serverlog(text)
	if string.find(text,"U.S.G.N.: Sending serverlist") ~= nil then
		return 1
	elseif string.find(text, "U.S.G.N.: Serverlist") ~= nil then 
		return 1
	elseif string.find(text, "Cron Execution") ~= nil then
		return 1
	elseif string.find(text, "generating stats.") ~= nil then
		return 1
	elseif string.find(text, "stats generated in ") ~= nil then
		return 1
	else
		return 0
	end
end

return serverlog.name

Is this not the right way to approach this? Is return 1 supposed to stop all future log events or just the current one?


You cant do this since the luas loades after the USGN SERVERLIST and that

old classes

WARM1NATOR
User Off Offline

Quote
I modified classes.lua that it has 9 classes instead of 6. But how can I set more that 9 classes?
To the start Previous 1 2310 311 312338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview