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 2258 259 260338 339 Next To the start

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
why it spaming me with errors?
Spoiler >

old Re: Lua Scripts/Questions/Help

senar
User Off Offline

Quote
Vectar666 has written
senar has written
Hi again.
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
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 09:28:23 pm

old Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Quote
MSek has written
why it spaming me with errors?
Spoiler >


try this:
1
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

old Re: Lua Scripts/Questions/Help

kalis
User Off Offline

Quote
CJ7 has written
MSek has written
why it spaming me with errors?
Spoiler >


try this:
1
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!

old Re: Lua Scripts/Questions/Help

maPmaKer
User Off Offline

Quote
Can someone make a script which can stop the dispenser to produce primary and secondary ammo? Or if it does then how to remove the ammo packs from the map using lua?

old EMERGENCY!

sixpack
User Off Offline

Quote
EMERGENCY:

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!

old Re: Lua Scripts/Questions/Help

senar
User Off Offline

Quote
my script has menu (press F2 to spawn NPCs) but when i click F2 nothing happend and here is my script
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
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!

old Re: Lua Scripts/Questions/Help

Pwncookies
User Off Offline

Quote
Hello, im getting the following error:

1
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

old Re: Lua Scripts/Questions/Help

Theronz
User Off Offline

Quote
Hi I have question to this script

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
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

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
@senar:

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
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

old Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Quote
heocon953 has written
CJ7 has written
MSek has written
why it spaming me with errors?
Spoiler >


try this:
1
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.

old Re: Lua Scripts/Questions/Help

sixpack
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
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


there should be 2 ends

old .YeaH.

FiiD
User Off Offline

Quote
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???

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

FASTDIE
User Off Offline

Quote
hey i need help with this i want make cts only for admins but idk how to do this i tried many times but im still learning lua
1
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------------

old .YeaH.

FiiD
User Off Offline

Quote
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...

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
@FaStDiE try it:

1
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

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
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
function NAME()
	for id = 1,32 do
		if (player(id,"exists")) then
			-- Now you have the IDs
		end
	end
end
To the start Previous 1 2258 259 260338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview