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 2164 165 166338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Alright, How does the action for servaction work? Like pressing F2 how does that supposedly work, I have tried some stuff and nothing seems to be right. And, the menu I just use p/player as the way of telling the id, yet, it won't let me and says it is nil.
edited 1×, last 15.02.10 07:10:45 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Homer has written
Alright, How does the action for servaction work? Like pressing F2 how does that supposedly work, I have tried some stuff and nothing seems to be right.


I'm just asking.. ..Isn't the F2-button used for the map-info? (:

old Re: Lua Scripts/Questions/Help

Cure Pikachu
User Off Offline

Quote
Anders4000 has written
Homer has written
Alright, How does the action for servaction work? Like pressing F2 how does that supposedly work, I have tried some stuff and nothing seems to be right.


I'm just asking.. ..Isn't the F2-button used for the map-info? (:

You're wrong.

> For map info, press Esc, then 1.
> Server info is F1.
> F2, F3, F4 are server actions.

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Flacko has written
@Redefinder: No, that's not the error
I've realized a while ago what it was.
I returned 1 inside the loop

Well then it works just fine for me,if usgns don`t match then I can`t join CT.
Flametail has written
it adds the hook, but thats all.

Flametail didn`t figure out the fact that he can join CT when his usgn matches with the one in the lua script

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
But it won't work for other admins
1
2
3
4
5
6
7
8
9
10
11
12
13
admin_usgn = {117860}

addhook("team","adminteam")
function adminteam(id,team)
	if team == 2 then --if ct
		for indx,USGN in ipairs(admin_usgn) do
			if player(id,"usgn") == USGN then
				return 0 --let the admin in
			end
		end
		return 1 --DO NOT LET THE DUDE IN
	end
end
And all you did was renaming a variable that I didn't use, so you didn't change anything at all.

old Re: Lua Scripts/Questions/Help

Flametail
User Off Offline

Quote
redefinder has written
Flacko has written
@Redefinder: No, that's not the error
I've realized a while ago what it was.
I returned 1 inside the loop

Well then it works just fine for me,if usgns don`t match then I can`t join CT.
Flametail has written
it adds the hook, but thats all.

Flametail didn`t figure out the fact that he can join CT when his usgn matches with the one in the lua script


wrong. I know what I am doing when I tested it. I had some of my family join a LAN game

and as such, flacko's still doesnt work, it is attempting to call a nil value.
edited 1×, last 15.02.10 09:07:09 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Hi everyone.

I was thinking about making a script that 'setpos'-s the player.. (and what i mean with a player is not only an admin ) ..by tiles
(For making the script teleport by tiles, i'm just going to do some math ;))
But for now i just wan't to make a script that teleports the player by pixels..

I want the player to be teleport when they say "!setpos " and then 2 numbers..
Fx.
"!setpos 64 128" would teleport the player to x = 64 and y = 128
"!setpos 320 64" would teleport the player to x = 320 and y = 64

But i don't know how to make it.. I only know how to make it very basic, but then they have to type a specific line
fx.
1
2
3
4
5
6
addhook("say","setpos_script"
function setpos_script(id)
	if (txt=="!setpos 64 64") then
		parse("setpos "..id.." 64 64")
	end
end

Can anyone help? (:
edited 5×, last 15.02.10 09:28:06 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
Like say command?

!setpos <id> <x> <y>?


Read it again i updated it xp
Yes.. Just without "<id>" so people can't teleport each other
..Pretty good way to show it actually: !setpos <x> <y>

> And i actually got the math done now.
So if i want to change the pixel-value to tile-value i just have to do this:
X = X x 32 - 16
Y = Y x 32 - 16
edited 4×, last 15.02.10 09:50:48 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Okay, I made parse script with own parameters.
Note:
!setpos <x> <y>

I could make improvements like "You can teleport only on movable tiles!"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook ( [[say]] , [[tele]] )
function tele ( p_ , t )
	local cmd , m = {}, [[[^ ]+]]
	for word in string . gmatch( t , m) do table . insert ( cmd , word ) end
	if ( string . sub ( t , 1 , 7 ) == [[!setpos]] ) then
		local lenght = #cmd
		if ( lenght == 3) then
			local x , y = cmd [ 2 ] , cmd[ 3 ]
			parse ( [[setpos ]] .. p_ .. [[ ]] .. x .. [[ ]] .. y )
		elseif ( lenght < 3) then
			msg2 ( p_ , [[Setpos ERROR: Not Enough Parameters]] )
		elseif ( lenght > 3 ) then
			msg2 ( p_ , [[Setpos ERROR: Too Many Parameters]] )
		end
	end
end
edited 2×, last 15.02.10 10:25:10 pm

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Is it possible to prevent a person from suciding with the command /kill without letting the person die and spawning him in the position he was in.

old Re: Lua Scripts/Questions/Help

Redefinder
User Off Offline

Quote
Flametail has written
wrong. I know what I am doing when I tested it. I had some of my family join a LAN game

and as such, flacko's still doesnt work, it is attempting to call a nil value.

It works fine for me,there are no errors in console.
Do I need to take a picture to show it?

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Blazzingxx has written
Okay, I made parse script with own parameters.
Note:
!setpos <x> <y>

I could make improvements like "You can teleport only on movable tiles!"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[spoiler]addhook ( [[say]] , [[tele]] )
function tele ( p_ , t )
	local cmd , m = {}, [[[^ ]+]]
	for word in string . gmatch( t , m) do table . insert ( cmd , word ) end
	if ( string . sub ( t , 1 , 7 ) == [[!setpos]] ) then
		local lenght = #cmd
		if ( lenght == 3) then
			local x , y = cmd [ 2 ] , cmd[ 3 ]
			parse ( [[setpos ]] .. p_ .. [[ ]] .. x .. [[ ]] .. y )
		elseif ( lenght < 3) then
			msg2 ( p_ , [[Setpos ERROR: Not Enough Parameters]] )
		elseif ( lenght > 3 ) then
			msg2 ( p_ , [[Setpos ERROR: Too Many Parameters]] )
		end
	end
end[/spoiler]

Thank you alot.. But couldn't you add comments to it? (: It would be a very big help for me! o:

Hm.. I might start by trying myself:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[spoiler]
addhook ( [[say]] , [[tele]] )
function tele ( p_ , t )
	local cmd , m = {}, [[[^ ]+]]									--Makes local tables: cmd, m, and then something i don't understand ([[[^ ]+]]).
	for word in string . gmatch( t , m) do table . insert ( cmd , word ) end	--Makes a "for"-loop for string.gmatch( the text , and m witch is = {} )...Damn i don't understand this! xD
	if ( string . sub ( t , 1 , 7 ) == [[!setpos]] ) then					--Looks for "!setpos" from letter 1 to 7 in the send message.
		local lenght = #cmd										--Makes a table (right?) for the length of "cmd".
		if ( lenght == 3) then
			local x , y = cmd [ 2 ] , cmd[ 3 ]						--X = cmd[2] and Y = cmd[3].
			parse ( [[setpos ]] .. p_ .. [[ ]] .. x .. [[ ]] .. y )				--Passes the setpos if #cmd is 3.
		elseif ( lenght < 3) then
			msg2 ( p_ , [[Setpos ERROR: Not Enough Parameters]] )	--Error msg to player if #cmd is lower than 3.
		elseif ( lenght > 3 ) then
			msg2 ( p_ , [[Setpos ERROR: Too Many Parameters]] )		--Error msg to player if #cmd is higher than 3.
		end
	end
end
[/spoiler]

Here is my complete 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
[spoiler]--[[	AKD Say Functions

Credits:

Blazzingxx > King of lua-scripting xD	- Basicly made the script :p
--]]

addhook("say","akd_say_functions_say")
function akd_say_functions_say(id, message)
	local cmd, m = {}, [[[^ ]+]]
	for word in string.gmatch(message, m) do table.insert(cmd, word); end
	if (string.sub(message, 1, 7)==[[!setpos]]) then
		if not (player(id, "health")==0) then
			local lenght = #cmd
			if (lenght==3) then
				local x, y = cmd[2] , cmd[3]
				parse ([[setpos ]]..id..[[ ]]..x*32-16 ..[[ ]]..y*32-16)
			elseif (lenght<3) then
				msg2(id, "©255000000Setpos ERROR: Not Enough Parameters!")
			elseif (lenght>3) then
				msg2(id, "©255000000Setpos ERROR: Too Many Parameters!")
			end
		else
			msg2(id, "©255000000You can't teleport when you are dead!")
		end
	end
end

print("©000255000AKD Say Functions-script successfully launched!")[/spoiler]


- Thank you very very much Blazzing! (;
edited 10×, last 16.02.10 02:10:58 pm

old Re: Lua Scripts/Questions/Help

Flametail
User Off Offline

Quote
Ok, peeps helping with the admin script, I found one that works. it is enclosed in the spoiler to prevent such time from being wasted ever again.

Spoiler >

old I NEED HELP IN THIS LUA SCRIPT

muselt
User Off Offline

Quote
Spoiler >



I HAVE ERROR ON 3, 36 AND 46 LINES...
line 3 error 'for' limit must be a number
line 36 error attempt to index global 'car' (a nil value)
line 46 error attempt to index global 'car' (a nil value)

----------------------------------------------------------------------
ITS NOT TAB'ING...
edited 4×, last 16.02.10 08:29:08 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
@Muselt. Would you please tab your script before posting it here, instead of giving us headache?
And maybe highlight the lines 3, 36 and 46, just to be kind, and so we don't have to count your line up to 46?
edited 8×, last 16.02.10 09:07:56 pm

old Re: Lua Scripts/Questions/Help

Vectarrio
User Off Offline

Quote
muselt has written
Spoiler >



I HAVE ERROR ON 3, 36 AND 46 LINES...
line 3 error 'for' limit must be a number
line 36 error attempt to index global 'car' (a nil value)
line 46 error attempt to index global 'car' (a nil value)

----------------------------------------------------------------------
ITS NOT TAB'ING...

Ok, car is REALLY a nil value, if you did not change it, just write "car=1"
it is 2 last mistakes.
The 1st is how you are doing initArray:
You wrote maxp. It is also nil. write before initArrays call:
maxp=tonumber(game("sv_maxplayers"))
To the start Previous 1 2164 165 166338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview