Forum

> > CS2D > Scripts > Unknown Command error in my script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Unknown Command error in my script

10 replies
To the start Previous 1 Next To the start

old Unknown Command error in my script

djow
User Off Offline

Quote
So, i wrote this simple script to work similar the comand "listplayers", except for the usgn name part (banaan usgn name..)

it works pretty well but it still giving that "unknown command" error after the script action happens, doesnt mater que place i put the "return 1 or return 2", it always give the same thing..

ps: i dont want to read a whole lua book to learn the language, my deal is only with this script, hope u guys help me fixing it..
edited 1×, last 18.05.12 10:05:11 pm

old Re: Unknown Command error in my script

djow
User Off Offline

Quote
didnt get it, im not programmer, like i said, my only deal in lua is with that particular script..

how that you've said is going to be on the code?

old Re: Unknown Command error in my script

Apache uwu
User Off Offline

Quote
Works fine, as seen in the example I really haven't changed anything. You just need to use return 2.

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
if list==nil then
	list={}
end
list.console={}

--[[ Enable if you don't have usgnname
_player=player
function player(id,value)
	if value=="usgnname" then
		return "UNKNOWN"
	else
		return _player(id,value)
	end
end
--]]

addhook("parse","list.console.parse")
function list.console.parse(cmd)
	if cmd=="list" then
		for _,i in pairs(player(0,"table")) do
			print("# "..i..", "..player(i,"name")..", IP "..player(i,"ip")..", USGN #"..player(i,"usgn")..", USGN Name: "..player(i,"usgnname")..",")
		end
	return 2
	end
end

old Re: Unknown Command error in my script

djow
User Off Offline

Quote
thanks dude, its working fine in this way you show too..

but still returns the same thing after all, it seems the return 1 or return 2 (your way) is not working on the script, check out the log:

Quote
[15:35:00] # 1, ELITEBRAZIL djowqt, IP 0.0.0.0, USGN #2723, USGN Name: djow,
[15:35:00] ERROR: Unknown command 'list' (list)
[15:35:00] Use quotation marks for parameters with blanks. e.g.: mp_unbuyable "Tactical Shield"
[15:35:00] Visit CS2D.com/help for a command reference

old Re: Unknown Command error in my script

EngiN33R
Moderator Off Offline

Quote
I just tested it on my computer, it works fine. Are you sure you saved the file correctly and all? As silly as it may sound, it happens often enough.

Also, to avoid conflicts of any sorts, you should change the _player=player line to

1
if not _player then _player=player end

It basically checks if _player doesn't already exist, and if it doesn't it sets it to the original player function.

old Re: Unknown Command error in my script

djow
User Off Offline

Quote
lol, i found out what was happening, there was another script conflicting with this one and somehow causing this error.. ¬¬

I just removed the other one from the server.lua and now everything is working fine

what could be possibly happening?..

check out, here are both (the list one and the "conflicting" one):
edited 1×, last 18.05.12 10:04:36 pm

old Re: Unknown Command error in my script

EngiN33R
Moderator Off Offline

Quote
You should set priorities to the hooks, set one hook to 1 and the other to 2 - you'll have to find out if order matters by means of experiment. I think that should remove the conflict.

old Re: Unknown Command error in my script

Apache uwu
User Off Offline

Quote
Well since a greater priority level means that it will run first, simply place a huge number to the list command parse hook.

ex.
1
addhook("parse","list.console.parse",999)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview