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 2147 148 149338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
change "w" to weapon
And Check your USGN number, maybe it's wrong, and it seems that USGN is offline, try to add -- to if(player(id,"usgn")... and one end.
edited 2×, last 26.01.10 01:39:35 pm

old Re: Lua Scripts/Questions/Help

jabba
User Off Offline

Quote
I tried to do a usebutton hook:

function comprarcasa(id,x,y)
if(player(id,"exists")) then
px = player(id,"tilex")
py = player(id,"tiley")
if px == 21 and py == 21 then
msg2(id,"©255000000 ID: "..casas[1].."")
if casas[1] == 255 then
casas[1] = id
msg2(id,"©255000000 ID: "..casas[1].."")
parse("setmoney "..id.." "..player(id,"money")-1000)
elseif casas[1] ~= id then
msg2(id,"©255000000 Somente o dono pode abrir a casa")
msg2(id,"©255000000 ID: "..casas[1].."")
return 1
end
end
end
end

And is not working, only for admins... =\

Please! All I need to know is if the 'usebutton' hook is working! I don't need no help with Scripting!
edited 1×, last 26.01.10 05:51:23 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Nice work.

I tried that socket module that you prefer, but only one thing I could do...
Read a text file from certain link.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Blazzingxx has written
Nice work.

I tried those sockets module that you prefer, but only one thing I could do...
Read a text file from certain link.


The http compatible sinks can not be used for an embedded system so you have to manipulate everything through raw sockets. But given that, you just need to write a few more layers to manipulate the structural data. For example, the following will work for all valid xml derived data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function string.tags(text, tag, __list)
	local sub = List{text:find("<[%%s]-%s.->.-<[%%s]-/[%%s]-%s[%%s]->"%{tag, tag})}
	if not __list then __list = List{} end
	if #sub > 0 then
		__list = __list + {text:sub(unpack(sub))}
		return text:sub(sub[2]+1):tags(tag, __list)
	else
		return __list
	end
end

function tagstrip(text)
	local sub = List{text:find("<.->")}
	if #sub > 0 then
		return tagstrip(text:replace(unpack(sub)))
	else
		return text
	end
end

function string.replace(text, start, ed)
	if not ed then ed = #text end
	return text:sub(0, start-1)..text:sub(ed+1)
end

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Hey, i'm new here and new too Lua too.

I am working on some codes for my Server,
but have some problems with it.

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
-----------------------
-- HUD: RADAR --
-----------------------
addhook("second","Radar")
function Radar(id,x,y,walk)
	rot = player(id,"rot")
	parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..x..' Y: '..y..' " 10 105')
end

-----------------------
-- HUD: LVL --
-----------------------
addhook("second", "CurrentLevel")
function CurrentLevel(id,level, killer)
	level=sample.ut.level[killer]
	parse('hudtxt2 '..id..' 3 "©000255000Level: '..level..' " 10 115')
end

-----------------------
-- HUD: WEP --
-----------------------
addhook("second", "CurrentWep")
function CurrentWep(id,level, weapon)
	parse('hudtxt2 '..id..' 3 "©000255000Level: '..weapon..' " 10 125')
end

Problems:
1. I got "some" Lua Errors
2. Can i do it in 1 Func instand of 3? (Because of the Func Paramters)
3. Why does the Radar is running but Lvl & Wep not?

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
1. You MUST do it in one function;
2. parameters must be in DIRECTLY right order.
And if you write name of other parameter in place, that must be for first parameter, it will be the name of FIRST parameter, and will make you confused. And hook "SECOND" DOES NOT HAVE ANY PARAMETER. try return function player(id,"smth")
Try this:
1
2
3
4
5
6
7
8
9
10
11
12
addhook("second","second")
function second()
	for id=1,game("sv_maxplayers") do
		if(player(id,"exists") then
     			rot[id] = player(id,"rot")
     			parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")' Y: '..player(id,"y")..' " 10 105')
    			level=sample.ut.level[id]
    			parse('hudtxt2 '..id..' 4 "©000255000Level: '..level..' 10 115')
     			parse('hudtxt2 '..id..' 5 "©000255000Level: '..item(player(id,"weaponid"),"name")..' " 10 125')
		end
	end
end
edited 1×, last 26.01.10 08:58:53 pm

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-----------------------
-- HUD: LVL --
-----------------------
addhook("second", "CurrentLevel")
function CurrentLevel(id,[b]level[/b], killer)
     level=sample.ut.level[killer]
     parse('hudtxt2 '..id..' 3 "©000255000Level: '..level..' " 10 115')
end

-----------------------
-- HUD: WEP --
-----------------------
addhook("second", "CurrentWep")
function CurrentWep(id,[b]level[/b], weapon)
     parse('hudtxt2 '..id..' 3 "©000255000Level: '..weapon..' " 10 125')
end
I don`t think a level parameter exists.

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Thanks for the tipps, but i think i try it the wrong
way I really did too much in C++ and Basic <_<

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-----------------------
-- COMPLETE HUD --
-----------------------
addhook("second","HUD")
function HUD()
	x = player(id,"x")
	y = player(id,"y")
	weapon = player(id,"weapontype")
	level = player(id,"score")

	parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..x..' Y: '..y..' " 10 105')
	parse('hudtxt2 '..id..' 3 "©000255000Weapon: '..weapon..' " 10 115')
	parse('hudtxt2 '..id..' 3 "©000255000Level: '..level..' " 10 125')
end

Wrong right? (Cant test it atm x_X)
Shame on my lua skills <_<


Edit:
The Version a bit more up doesnt work.
(fixed the "(" :P)

Still get Nil Errors
edited 1×, last 26.01.10 09:41:44 pm

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
Got it so now:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-----------------------
-- COMPLETE HUD --
-----------------------
addhook("second","HUD")
function HUD()
     for id = 1, game("sv_maxplayers"), 1 do
          if player(id,"exists") then
               rot[id] = player(id,"rot")
               parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")' Y: '..player(id,"y")..' " 10 105')
               level=sample.ut.level[id]
               parse('hudtxt2 '..id..' 4 "©000255000Level: '..level..' 10 115')
               parse('hudtxt2 '..id..' 5 "©000255000Level: '..item(player(id,"weaponid"),"name")..' " 10 125')
          end
     end
end

Now i got an Error with the "Rot" Value oO

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-----------------------
-- COMPLETE HUD --
-----------------------
addhook("second","HUD")
function HUD()
	 rot = {}
     for id = 1, game("sv_maxplayers"), 1 do
          if player(id,"exists") then
               rot[id] = player(id,"rot")
               parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")' Y: '..player(id,"y")..' " 10 105')
               level=sample.ut.level[id]
               parse('hudtxt2 '..id..' 4 "©000255000Level: '..level..' 10 115')
               parse('hudtxt2 '..id..' 5 "©000255000Level: '..item(player(id,"weaponid"),"name")..' " 10 125')
          end
     end
end

Right? Now i got an Error in this line:

1
parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")' Y: '..player(id,"y")..' " 10 105')

Error:
Attempt to call a number value

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Why doesn`t this work?
1
2
3
4
5
6
7
8
9
10
11
12
-----------------------
-------ADMIN SAY-------
-----------------------
addhook("say","adminsay")
function adminsay(id)
	for i,_usgn in ipairs(RANK.ADMIN) do
		if player(id,"usgn") == _usgn then
		msg(©000255000 "..player(player, "name").." (Admin): "..text)
		return 1
	  	end
	end
end
It`s purpose is to make message of admin green and add word (Admin) to it.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
I fixed it.
Don't forget about level variables...

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("second","HUD")
function HUD()
	rot = {}
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			rot[id] = player(id,"rot")
			parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")..' Y: '..player(id,"y")..' " 10 105')
			level=sample.ut.level[id]
			parse('hudtxt2 '..id..' 4 "©000255000Level: '..level..' 10 115')
			parse('hudtxt2 '..id..' 5 "©000255000Level: '..item(player(id,"weaponid"),"name")..' " 10 125')
		end
	end
end

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Blazzingxx has written
I fixed it.
Don't forget about level variables...

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("second","HUD")
function HUD()
	rot = {}
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			rot[id] = player(id,"rot")
			parse('hudtxt2 '..id..' 3 "©000255000Coordinates X: '..player(id,"x")..' Y: '..player(id,"y")..' " 10 105')
			level=sample.ut.level[id]
			parse('hudtxt2 '..id..' 4 "©000255000Level: '..level..' 10 115')
			parse('hudtxt2 '..id..' 5 "©000255000Level: '..item(player(id,"weaponid"),"name")..' " 10 125')
		end
	end
end


I quoted it just in case if you haven't noticed...

old Re: Lua Scripts/Questions/Help

SenSidethink
User Off Offline

Quote
I did noticed it.

But i still get soem Problems.

1. The Weapon HUD dont Change.
(If u start with USP and change to Deagle for
example it shows still USP)

Error in this Line:
1
parse('hudtxt2 '..id..' 5 "©000255000Weapon: '..item(player(id,"weaponid"),"name")..' " 10 125')

2. The "Level" thing doesnt even because of the
Error above.

3. The Coordinates are scary
Not like 250,2500 its 250,8438843 and so.


Edit: Fixed Error 2.

1 & 3 are still there

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
I suggest use tilex, tiley in coordinates.
Use "weapontype" value to return weapon id of player. (instead "weaponid")
To the start Previous 1 2147 148 149338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview