Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 2294 295 296338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

StirlizZ-Fapicon
Super User Off Offline

Zitieren
Hi all, i`m trying to make specialHUD image for each team but it s not working.
1
2
3
4
5
6
7
8
addhook("join", "sethud")
function sethud(id,team)
if(player(id, "team")==1 then
HUDRadar = image("gfx/TER_team.png", 0, 0, 0)
elseif(player(id, "team")==2 then
HUDRadar = image("gfx/CT_team.png", 0, 0, 0)
end
end

What s wrong?

alt Re: Lua Scripts/Questions/Help

maPmaKer
User Off Offline

Zitieren
Banaan hat geschrieben
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
admins = { 12345, 54321 } -- USGN ID's

addhook("say","kick")
function kick(id,txt)
	for i=1,#admins do
		if player(id,"usgn") == admins[i] then
			if string.sub(txt, 1, 5) == "!kick" then
				local kid = string.sub(txt, 7, 8)
				parse("kick "..kid)
				return 1	-- don't show the text
			elseif string.sub(txt, 1, 4) == "!ban" then
				local bid = string.sub(txt, 6, 7)
				local usgn = player(bid,"usgn")
				parse("banip "..bid)
				if usgn ~= 0 then
					parse("banusgn "..usgn)	 -- if the player is logged into USGN, also ban his USGN ID
				end
				return 1	-- don't show the text
			end
		end
	end
end

This script bans both IP and (if possible) USGN

Can I have a cookie now?


The lua is great. You can have mroe cookies

THANKS BTW!

alt Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Zitieren
Guys this code works, its my updated part of xp.lua example. It has IMG-DEBUG: free and create, makes 1 frees one, but when there are more players it starts overloading and going over 3000 creates, and frees only 1

1 player:
IMG-DEBUG: free 1
IMG-DEBUG: create 1
IMG-DEBUG: free 1
IMG-DEBUG: create 1

2 players:
IMG-DEBUG: free 1
IMG-DEBUG: create 1
IMG-DEBUG: free 1
IMG-DEBUG: create 2
and so on...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
checkdelay = 0
addhook("second","ms_rank")
function ms_rank()
checkdelay=checkdelay+1
	if checkdelay>=1 then
	checkdelay=0
		for id = 1,32 do
			freeimage(id)
			if (player(id,"exists")) then
				if (player(id,"bot") == false) then
					if level[id] >= 1 and level[id] <= 25 then
						id1=image("gfx/Ranks/Rank"..(level[id]-1)..".bmp",0,0,200+id)
					else
						level[id]=24
						exp[id]=math.abs((500*level[id])-1)
					end
				end
			end
		end
	end
end

Any way to fix it or is cs2d lua system error?


@Fapicon
addhook("join", "sethud")
function sethud(id,team)
if player(id, "team")==1 then
HUDRadar = image("gfx/TER_team.png", 0, 0, 0)
elseif player(id, "team")==2 then
HUDRadar = image("gfx/CT_team.png", 0, 0, 0)
end
end

When you open ( you need to close ) or if its in open you don't need it.

Edit: oh try mode 2 or 3.

Like:
addhook("join", "sethud")
function sethud(id,team)
if player(id, "team")==1 then
HUDRadar = image("gfx/TER_team.png", 0, 0, 2) <-- last number
elseif player(id, "team")==2 then
HUDRadar = image("gfx/CT_team.png", 0, 0, 2) <-- last number
end
end
1× editiert, zuletzt 28.10.10 21:17:16

alt Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Zitieren
@iDios did you set the tile1 and tile2 for NPC? tile1 is X, tile2 is Y, and they're tiles, not pixels. I dunno, it should appear.

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
help some 1 :

1
2
3
msg2(id,player(hunting[id],"name").." Killed You")

Lua Error: attempt to concatenate a boolean value
Help ?

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
@TDShuft, there isn't enough information for us to help you with just that one line. Try to include the rest if you can.

alt Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Zitieren
No, when it says boolean value when it should be any other value, it means it's "false", thus, most probably, you didn't set it right.

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
GlockPwner hat geschrieben
No, when it says boolean value when it should be any other value, it means it's "false", thus, most probably, you didn't set it right.

The player() function returned false because the hunting[id] argument wasn't valid (maybe it is not a valid ID or it's not even a number value), that's why it complains about boolean concatenation.

alt Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Zitieren
@GlockPwner
Ok, now the NPC appear But he don't talk when player say "hi" And can you make the opposite rotation
Thanks you !

alt Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Zitieren
@iDios

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
ction initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
npcstate=initArray(32)
-- interact positions are where the player should stand, npctiles are where the NPCs stand
interact1 = 1336
interact2 = 1336
npctile1 = 1337
npctile2 = 1337

tile1=(npctile1*32+16)
tile2=(npctile2*32+16)
npc1=image('gfx/npcsprite.png',tile1,tile2,1)
imagepos(npc1,tile1,tile2,180)

addhook("say", "npctalk")
function npctalk(id,t)
if(player(id,"tilex")==interact1 and player(id,"tiley")==interact2) then
if(txt=="hi" and npcstate[id]==0) then
msg2(id, "©255255255Do you want to be an admin?")
npcstate[id]=1
end
if(txt=="yes" and npcstate[id]==1) then
msg2(id, "©000255000Then register to www.daknob.com!")
npcstate[id]=0
end
end
end

And make sure you change the sprite and positions! And memorize/mark them!

alt Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Zitieren
TDShuft hat geschrieben
help some 1 :

1
2
3
msg2(id,player(hunting[id],"name").." Killed You")

Lua Error: attempt to concatenate a boolean value
Help ?


We can't help if we can't see the whole hook, post your hook.

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
Flacko hat geschrieben
GlockPwner hat geschrieben
No, when it says boolean value when it should be any other value, it means it's "false", thus, most probably, you didn't set it right.

The player() function returned false because the hunting[id] argument wasn't valid (maybe it is not a valid ID or it's not even a number value), that's why it complains about boolean concatenation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function get_enemy(id)
local math_id=math.random(1,32)
	if math_id==id then
		get_enemy(id)
	else
		if player(math_id,"exists") then
			hunting[id]=math_id
			updatehud(id)
		else
			get_enemy(id)
		end
	end
	updatehud(id)
	get_new_img(id)
end
well this is where i get hunting[id]

alt Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Zitieren
try:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function get_enemy(id)
local math_id=math.random(1,32)
 -- for id=1, 32 do
     if math_id==id then
          get_enemy(id)
     else
          if player(math_id,"exists") then
               hunting[id]=math_id
               updatehud(id)
          else
               get_enemy(id)
          end
     end
     updatehud(id)
     get_new_img(id)
end
 -- end

remove lines "--"

alt Re: Lua Scripts/Questions/Help

TDShuft
User Off Offline

Zitieren
The Camo hat geschrieben
try:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function get_enemy(id)
local math_id=math.random(1,32)
 -- for id=1, 32 do
     if math_id==id then
          get_enemy(id)
     else
          if player(math_id,"exists") then
               hunting[id]=math_id
               updatehud(id)
          else
               get_enemy(id)
          end
     end
     updatehud(id)
     get_new_img(id)
end
 -- end

remove lines "--"

--'
that function its to 1 player not to ALL !
"for id=1,32 do" its for all 32 players
--'
and i dont want to change that function i want to change that msg omg ..

alt Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Zitieren
Fehuziom hat geschrieben
How to in Hook Projectile change X Pixels and Y Pixels to X Tile and Y Tile ? (change pixels to tile)


/32

example

1
player(id,"x")/32
Zum Anfang Vorherige 1 2294 295 296338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht