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 249 50 51338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
1
so that i can say all players with the name déjavu... gets automatically banned by join is it possible??

It's possible, but I wouldn't advise it.

http://failboat.me/2009/wordfilter-in-lua/
download the zip file
extract into sys/lua/ folder
edit the first 2 lines of filter.lua to

1
2
if not string.trim then dofile("sys/lua/string.lua") end
if not table.find then dofile("sys/lua/table.lua") end

Add the following to server.lua

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
43
44
45
46
47
48
dofile('sys/lua/filter.lua')

function alter_filter(words)
	words = words or wordlist
	local cache = ""
	for word in wordlist do
		cache = cache .. word .. ",\n"
	end
	cache = cache:sub(1, #cache-2)
	
	f_handle = open('sys/lua/badwords.txt')
	f_handle:write(cache)
	f_handle:close()
end

addhook("join", "filter_join")
function filter_join(p)
	local name = player(p, "name")
	if filter(name) then
		parse("kick "..p)
	end
end

addhook("say", "filter_add")
function filter_add(p, cmd)
	cmd = cmd:split()
	if cmd[1] == 'add_name' then
		table.remove(cmd, 1)
		cmd = string.join(cmd, " "):trim()
		table.insert(wordlist, cmd)

		msg2(p, cmd.." was added to the list")
	elseif cmd[1] == 'rem_name' then
		table.remove(cmd, 1)
		cmd = string.join(cmd, " "):trim()
		local p = table.find(wordlist, cmd)
		if p then
			table.remove(wordlist, p)
		else
			msg2(p, "Can not remove - Not found")
		end
	else
		return
	end

	return 1

end

Note: I wrote this on the fly so you'll have to try to debug it if anything comes up. Edit badwords.txt to get a list of unplayable names. Read the syntax for the words on

http://failboat.me/2009/wordfilter-in-lua/

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
somegamer has written
so, in order to get a list of players who have knives, i would do something like...

or is it like that? dont bother telling me im hopeless. i figured that one out when i started trying.

also when i strip the knife at spawn, i lose the knife for about 10 minutes, then it mysteriously re apears?


If you want a table with the players that have knife you can try this:

1
2
3
4
5
6
7
8
9
10
playerswithknife={}--Global table
function always()--No parameters
	for id in ipairs(player(0,"table")) do --Cycle through players
		for weapon in ipairs(playerweapons(id)) do
			if weapon == 50 then
				table.insert(playerswithknife,id)
			end
		end
	end
end

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("menu","buyammo")
function buyammo(id,menu,sel)
if (menu=="ammo") then
dolars = player(id,"money")
if sel==1 then
if dolars>199 then
parse("equip "..id.." 61")
parse("equip "..id.." 62")
parse("setmoney "..id.." "..player(id,"ammo")-200)
msg2(id,"©255255255You have bought of ammo!")
else
msg2(id,"©255000000Not enoguh money to buy !")
end
end
end
end

Need help from the pros scripter :D,
If player already full ammo,
how to make that "You weapon ammo already FULL!" ?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Admirdee has written
Need help from the pros scripter :D,
If player already full ammo,
how to make that "You weapon ammo already FULL!" ?

For that you dont need any pro skills. (I thought you pro )

Just use cs2d functions.

And I have suggestion:
Make tables for max ammo, max ammoin
ammo_max = {96,120} -- max ammo for glock and usp
ammoin_max = {12,20} -- max ammoin for glock and usp
So if you buy glock it woud be look like that:
1
2
3
4
5
if player([b]id[/b],"ammo") < ammo_max[b][id of weapon][/b] then
	BLABLABLA...
else
	MSG('Your Ammo is already full')  :ugly: 
end

or....
1
2
3
if player([b]id[/b],"ammo") == ammo_max[b][id of weapon][/b] then
	MSG('Your Ammo is already full')  :ugly: 
end
I just gave you idea. If you will still have problems, I will make script
edited 1×, last 08.09.09 02:12:20 pm

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
What's wrong here?
Spoiler >

It says end expected

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@mat5b
No one cant help you becouse you dont show all values.

hud txt command... lol, there is no color parammeter. Only on my superhero hudtext(id,slot,txt,x,y,a) > sh_txt(id,slot,clr,txt,x,y,a) update

And I think you made a mistake not in this part of script.

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
mat5b has written
You are right. But it's not the problem. What does return player(id,"bot") ?
returns 1 if the player is a bot

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Quote
For that you dont need any pro skills. (I thought you pro )

I'm just learn it for 2 weeks

Quote
Just use cs2d functions.

And I have suggestion:
Make tables for max ammo, max ammoin
ammo_max = {96,120} -- max ammo for glock and usp
ammoin_max = {12,20} -- max ammoin for glock and usp
So if you buy glock it woud be look like that:
1
2
3
4
5
if player([b]id[/b],"ammo") < ammo_max[b][id of weapon][/b] then
	BLABLABLA...
else
	MSG('Your Ammo is already full')  :ugly: 
end

or....
1
2
3
if player([b]id[/b],"ammo") == ammo_max[b][id of weapon][/b] then
	MSG('Your Ammo is already full')  :ugly: 
end
I just gave you idea. If you will still have problems, I will make script


a glock and usp as example, what about the other weapon, like M4,Ak,RPG it's that you need ammo max and ammo in same like USP/Glock?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
You need to make values:
ammo_max = {96.... alll weapons max ammo...
ammo_max[30] = 90 < thats ak - 47max ammo.
30 - ak id
And if there is no weapon id :
ammo_max = {120,96,59,35,100,120,0,0,0,32,32} < o as if weapon not exists. after zeros its continue as shotguns.

I hope you understand

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
How to make that a snowballs explodes after 'impact'?

I tried a hook with projectile, but it haven't worked.

Can someone please help me?

old Re: Lua Scripts/Questions/Help

LilCoder
BANNED Off Offline

Quote
I made that once, super grenades

Here the code is:

1
2
3
4
5
6
7
8
9
10
11
function explosion(x, y, size, damage)
	parse("explosion "..x.." "..y.." "..size.." "..damage)
end


addhook("projectile","my_projectile")
function my_projectile(id,weapon,x,y)
if(weapon == 75) then  --snowball
            explosion(x,y,300, 300) -- size + damage = 300
end
end
To the start Previous 1 249 50 51338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview