Forum
Scripts
Lua Scripts/Questions/Help Vectar666 has written
NPC is an object type 30, so...
senar has written
Hi again.
can some one post a script that make you when you kill npc you get 300$ please?
can some one post a script that make you when you kill npc you get 300$ please?
NPC is an object type 30, so...
1
2
3
4
5
6
2
3
4
5
6
addhook("objectkill","npckill")
function npckill(id,playerid)
	if object(id,"type")==30 then --checks if this object is NPC
		parse("setmoney "..playerid.." "..(player(playerid,"money")+300)) --adds $300
	end
end
Thanks alot that relly worked :).
i makeing a script with menu i finished it but when i test it i click F2 for the menu and nothing happend
what i must add to the script? edited 1×, last 12.09.10 07:28:23 pm
MSek has written
why it spaming me with errors?
try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook( "ms100", "kamikaze_move")
function kamikaze_move()
	local t = player(0,"table")
	for i=1,#t do
		local id = t[i]
		local x, y, tx, ty
		x = player( id, "x")
		y = player( id, "y")
		tx = math.floor(x/32)
		ty = math.floor(y/32)
		if tile( tx, ty, "walkable") then
			parse('setpos '.. id ..' '.. (x+3) ..' '.. (y+3))
		end
	end
end
CJ7 has written
try this:
MSek has written
why it spaming me with errors?
try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook( "ms100", "kamikaze_move")
function kamikaze_move()
	local t = player(0,"table")
	for i=1,#t do
		local id = t[i]
		local x, y, tx, ty
		x = player( id, "x")
		y = player( id, "y")
		tx = math.floor(x/32)
		ty = math.floor(y/32)
		if tile( tx, ty, "walkable") then
			parse('setpos '.. id ..' '.. (x+3) ..' '.. (y+3))
		end
	end
end
Hey. Can change math.floor = math.water?
help me!
I use a say hook.
I want to make the original message not visible.
Like when I say hi, its gonna play a sound but not show the hi.
In the end I use the return 1 but this is NOT working!!!
It works in an other part of the script, but not in the current I am editing!
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
49
50
51
52
53
54
55
56
57
58
59
60
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
49
50
51
52
53
54
55
56
57
58
59
60
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
function ns_menu_spawn1(id)
	menu(id,"NPC - Spawn Menu 1,NPCs")
end
function ns_menu_spawn2(id)
	menu(id,"NPC - Spawn Menu 2,<- Back,Zombie,HeadCrab")
end
function ns_spawn_npc1(id,x,y,bid)
	parse('spawnnpc '1' '..x..' '..y..'90' ')
end
function ns_spawn_npc2(id,x,y,bid)
	parse('spawnnpc '2' '..x..' '..y..'90' ')
end
function ns_spawn_npc3(id,x,y,bid)
	parse('spawnnpc '3' '..x..' '..y..'90' ')
end
addhook("serveraction","ns_serveraction")
function ns_serveraction(id,b)
	if (b==1) then
		ns_menu_spawn1(id)
	end
addhook("serveraction","ns_spawn_serveraction")
function ns_spawn_serveraction(id)
	ns_menu_spawn1(id)
end
addhook("menu","ns_menu")
function ns_menu(id,t,b)
	if (t=="NPC - Spawn Menu 1") then
		if (b==1) then
			ns_menu_spawn2(id)
		end
	if (t=="NPC - Spawn Menu 2") then
		if (b==1) then
			ns_spawn_npc1
			ns_menu_spawn2
		end
		if (b==2) then
			ns_spawn_npc2
			ns_menu_spawn2
		end
		if (b==3) then
			ns_spawn_npc3
			ns_menu_spawn2
		end
Help!
1
2
2
LUA ERROR <ai_update_dead>: attempt to call a nil value Freezing bots to stop lua error msg flood! Use bot_freeze 0 to unfreeze bots!
But i dont get any error of the script on dedicated. So i dont know how to fix this x.x
By the way the script is S-Hero 1.0
Edit;
I have tried
- Using console to unfreeze bots.
- Adding bot_free 0 to server.cfg
Can change this script : Glow for admin only and admin can give glow other players
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
addhook("say","glowz")
function glowz(id,t)
if (string.sub(t,1,4) == "glow") and (string.len(t) > 4) then
freeimage(id)
image("gfx/player/ffx.bmp",1,0,200+id)
imagealpha(id,0.5)
imageblend(id,1)
if (string.find(t,"red") ~= nil) then imagecolor(id,255,0,0) ;end
if (string.find(t,"green") ~= nil) then imagecolor(id,0,255,0) ;end
if (string.find(t,"blue") ~= nil) then imagecolor(id,0,0,255) ;end
if (string.find(t,"purple") ~= nil) then imagecolor(id,255,0,255) ;end
if (string.find(t,"yellow") ~= nil) then imagecolor(id,255,255,0) ;end
if (string.find(t,"lblue") ~= nil) then imagecolor(id,0,255,255) ;end
if (string.find(t,"white") ~= nil) then imagecolor(id,255,255,255) ;end
elseif (t == "!glow") then
freeimage(id)
end
end
Sorry pwncookies
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
49
50
51
52
53
54
55
56
57
58
59
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
49
50
51
52
53
54
55
56
57
58
59
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
function ns_menu_spawn1(id)
menu(id,"NPC - Spawn Menu 1,NPCs")
end
function ns_menu_spawn2(id)
menu(id,"NPC - Spawn Menu 2,<- Back,Zombie,HeadCrab")
end
function ns_spawn_npc1(id,x,y,bid)
parse('spawnnpc '1' '..x..' '..y..'90' ')
end
function ns_spawn_npc2(id,x,y,bid)
parse('spawnnpc '2' '..x..' '..y..'90' ')
end
function ns_spawn_npc3(id,x,y,bid)
parse('spawnnpc '3' '..x..' '..y..'90' ')
end
addhook("serveraction","ns_serveraction")
function ns_serveraction(id,b)
if (b==1) then
ns_menu_spawn1(id)
end
end
addhook("serveraction","ns_spawn_serveraction")
function ns_spawn_serveraction(id)
ns_menu_spawn1(id)
end
addhook("menu","ns_menu")
function ns_menu(id,t,b)
if (t=="NPC - Spawn Menu 1") then
if (b==1) then
ns_menu_spawn2(id)
end
elseif (t=="NPC - Spawn Menu 2") then
if (b==1) then
ns_spawn_npc1
ns_menu_spawn2
elseif (b==2) then
ns_spawn_npc2
ns_menu_spawn2
elseif (b==3) then
ns_spawn_npc3
ns_menu_spawn2
end
end
heocon953 has written
Hey. Can change math.floor = math.water?
help me!
CJ7 has written
try this:
MSek has written
why it spaming me with errors?
try this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook( "ms100", "kamikaze_move")
function kamikaze_move()
	local t = player(0,"table")
	for i=1,#t do
		local id = t[i]
		local x, y, tx, ty
		x = player( id, "x")
		y = player( id, "y")
		tx = math.floor(x/32)
		ty = math.floor(y/32)
		if tile( tx, ty, "walkable") then
			parse('setpos '.. id ..' '.. (x+3) ..' '.. (y+3))
		end
	end
end
Hey. Can change math.floor = math.water?
help me!
It's math.floor as opposed to math.ceiling, it's a mathematical function which has nothing to do with a floor or water. It just rounds numbers. Eg turns 4.5 into 4.
Addhook("say", "saycrap")
Function saycrap(id, txt)
If txt="crap" then
Return 1
End
Well not xactly this
DaKnOb has written
Ok. The problem was fixed. Since I am from iPhone I will send you the code but it may have some errors.
Addhook("say", "saycrap")
Function saycrap(id, txt)
If txt="crap" then
Return 1
End
Well not xactly this
Addhook("say", "saycrap")
Function saycrap(id, txt)
If txt="crap" then
Return 1
End
Well not xactly this

there should be 2 ends
FiiD has written
Vectar I saw your script for NPCs...really cool...I use it...thanks...and I got a question...I trying to make scripts from yesterday and I h ave a queston...can any please explain me a little the Loops and/or say me how much hooks are available...just the hooks in CS2D folder/sys/lua/info or are there more hooks???
only the ones in info.txt, Theres no others
but u dont need to use hooks u cant just do
function NAME() -- you can have (id) when you use menus but else not
i tried many times but im still learning lua 1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
addhook("team","onlyadminsct")
	admins = {15587,16304}
function isadmin(id,txt)
for _, usgn in ipairs(admins) do
	if player(id,"usgn") == usgn then
		return true
	end
end
return false
end
function onlyadminsct(id,team,look)
-----idk what do here------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("team","onlyadminsct")
admins = {15587,16304}
function isadmin(id,txt)
for _, usgn in ipairs(admins) do
	if player(id,"usgn") == usgn then
		return true
	end
end
return false
end
function onlyadminsct(id,team,look)
	if team == 2 then
		if isadmin(id) then
			return 0
		else
			parse("maket "..id)
		end
	end
end
FiiD has written
Thanks HaRe!!! YOu helped me really much...I needed to know that Function NAME()...I want to make a script so hat just I can open some walls...Triger Use...but I have a one more question...where to find a good Lua Scripting tuttorial??? Is the best Tuttorial from TheKilledDeath or is there a better...I learn now from that tuttorial...
np also Theres mutch tuts u can search in google for some tuts ill try to find some tuts, But the forum helped me mutch to learn lua scripting.
When i see the Lua Script Thread has an new message i always look and look at the script to learn more and more. Ive gain mutch experience and learned it in like 1 week
also if you want ID in the function NAME()
you just have to add
1
2
3
4
5
6
7
2
3
4
5
6
7
function NAME() 	for id = 1,32 do 		if (player(id,"exists")) then 			-- Now you have the IDs 		end 	end end
Lua Scripts/Questions/Help


Offline
