edited 1×, last 15.02.10 07:10:45 pm
Forum
CS2D Scripts Lua Scripts/Questions/Help 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? (:
Anders4000 has written
I'm just asking.. ..Isn't the F2-button used for the map-info? (:
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.
I've realized a while ago what it was.
I returned 1 inside the loop
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
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
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
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
redefinder has written
Well then it works just fine for me,if usgns don`t match then I can`t join CT.
Flametail didn`t figure out the fact that he can join CT when his usgn matches with the one in the lua script
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
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
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
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
!setpos <id> <x> <y>?
Blazzingxx has written
Like say command?
!setpos <id> <x> <y>?
!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
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
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
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.
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?
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!"
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
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
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
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
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
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
muselt has written
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...
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"))