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 218 19 20338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
still getting this problem.
My badwords.txt(just beginning and end of file):
Quote
*xxx*,
xxx,
*xxx,
xxx*,
xxx


My filter.lua (part where the error is):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function string.trimpun(t)
	local letters = t:letters()
	local first = letters[1]
	local last = letters[#letters]
if not (type(first) == "string") then return t end
     if not (type(last) == "string") then return t end
	while (first:inside(puns)) do
		t = t:sub(2)
		first = t:sub(1, 1)
	end
	while (last:inside(puns)) do
		t = t:sub(1, #t-1)
		last = t:sub(#t, #t)
	end

	return t
end

while (first:inside(puns)) do

error here.

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
1
2
3
4
5
6
print(type(first))
if not (type(first) == "string") then return t end
     if not (type(last) == "string") then return t end
	while (first:inside(puns)) do
		t = t:sub(2)
		first = t:sub(1, 1)

Like this?
Tried this dunno where it should say string. If in cs2d then not. Tried also swearing. Doesn't work.
Checked server console - same error at "while (first:inside..."

btw.
what does it do? warnings and kick?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
oh, I see what you did...

In server.lua, do not hook filter to say, , create a new function(player, text) and then use if filter(text) then ACTION end.

old Re: Lua Scripts/Questions/Help

Kaka024
User Off Offline

Quote
hard to understand lol. You mean - make new script, and
1
2
3
4
5
addhook(say,player)
function(player,text)
if filter(text) then
?? what here ??
end
right?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
add this afterwards

1
2
3
4
5
6
7
addhook("say", "filtertext")

function filtertext(id, text)
	if filter(text:lower()) then
		print("Naughty word detected")
	end
end

And in filter.lua, add dofile("string.lua") and dofile("table.lua") in the beginning of the file. If you're using an earlier version of my string library, delete the dofile reference to it.

old Re: Lua Scripts/Questions/Help

Todesengel
User Off Offline

Quote
There me not really helpful in the German forum was helped at times I ask you in English thread. First, I have a script written the RPG if you kill a person in a cell will be teleported and it appears a message indicating that you have killed someone and are in prison. Everything works out pretty well only if the other team switches or kill themselves on the console, the same message also appears. how can I change that?
Here is the code

1
2
3
4
5
addhook("die","hook_die")
	function hook_die(victim,killer,weapon,x,y)
parse ("setpos "..killer.." 4320 1376")
	msg2 (killer,"©255000000 You've killed someone, you 	are in the jail@C")
end

Okay now to my second problem.
I would like for my map a supermarket write script that when one stands before the bar, and [E] expresses a menu appears where you can buy weapons & can. My question is, How do I get a menu from where I've listed 10 weapons. I would like it best with trigger_Use have. Can anyone create something here in this thread? Because I think there are many good players to deal with Lua Leegao know, among other things ^ _ ^

Thanks

old Use trigger?

KimKat
GAME BANNED Off Offline

Quote
How to make a use trigger that if triggered it equips the player in lua?

This is like what I've come up with under a minute...
1
2
3
4
5
addhook("use","trigger.equip.player")
function trigger.equip.player (if, trigger, p, equip)
     parse(if trigger "entity" then "equip ..p.. 58")
     msg2(p, "..p.. has equipped a Kevlar+Helm!")
end
I haven't tried the code, but someguy told me it failed.

By the way is there a way to add delay time on triggers before being able to trigger certain entities?
1
2
3
4
addhook("delay","trigger.ontime")
  function trigger.ontime (if, trigger, t, ms)
	parse(if (t, "32000ms") then trigger "entity1,entity2,entity3')
  end
edited 2×, last 24.06.09 05:37:13 pm

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
BeLiioN has written
Everything works out pretty well only if the other team switches or kill themselves on the console, the same message also appears. how can I change that?
Here is the code


Use hook kill instead of hook die.

Quote
Because I think there are many good players to deal with Lua Leegao know, among other things ^ _ ^

Thanks


Sorry, I no longer write scripts for CS2D, I do write general purpose scripts but I no longer have the energy to write game-specific scripts.

old Re: Lua Scripts/Questions/Help

kikinep
User Off Offline

Quote
hi i want to do a join script that when someone join from mexico say player has joined from mexico or from usa say player has joined from usa like that but i dont know how to do it only i know how to do the join script that say player has joined thx answer

old Re: Lua Scripts/Questions/Help

Alpha Beta
User Off Offline

Quote
kikinep has written
hi i want to do a join script that when someone join from mexico say player has joined from mexico or from usa say player has joined from usa like that but i dont know how to do it only i know how to do the join script that say player has joined thx answer

Thats impossible.

old Re: Lua Scripts/Questions/Help

wups
User Off Offline

Quote
I think im dumb or it's something wrong with my function.


What is really wrong in this code?
It can find x and y.
But it can't check if x is 1, and y is 4.

1
2
3
4
5
6
7
8
addhook("use","omg")
function omg(p,e,d,x,y)
	msg(" "..x.." "..y)
	if (x==1) and (y==4) then
		msg(doh)
		parse("equip "..p.." 30") 
	end
end

Heavy, nothing is impossible.
Sockets or a file with ips to many locations.

old Re: Lua Scripts/Questions/Help

Alpha Beta
User Off Offline

Quote
@wups: I'm not sure but replace "and" by "&&"
So it looks like that;
1
2
3
4
5
6
7
8
addhook("use","omg")
function omg(p,e,d,x,y)
	msg(" "..x.." "..y)
	if (x==1) && (y==4) then
		msg(doh)
		parse("equip "..p.." 30")
	end
end

Yep.. but you can't use sockets in CS2D (yet), can you?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Heavy has written
Yep.. but you can't use sockets in CS2D (yet), can you?


Not unless you can softhook lua-socket in. Your other option is to use short poll, which makes it semi-possible to do what he suggested if you can get geoip-resolution api but you'll need to add an intermediate step

@BeLiioN: I think wups is currently trying to resolve your problem

Oh and yeah, it's tempting to use Java conditional operators but Lua uses the verbose form "and" and "or" and "not"
To the start Previous 1 218 19 20338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview