Forum

> > CS2D > Scripts > Unknown Command error in my script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Unknown Command error in my script

10 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Unknown Command error in my script

djow
User Off Offline

Zitieren
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..
1× editiert, zuletzt 18.05.12 22:05:11

alt Re: Unknown Command error in my script

djow
User Off Offline

Zitieren
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?

alt Re: Unknown Command error in my script

Apache uwu
User Off Offline

Zitieren
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

alt Re: Unknown Command error in my script

djow
User Off Offline

Zitieren
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:

Zitat
[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

alt Re: Unknown Command error in my script

EngiN33R
Moderator Off Offline

Zitieren
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.

alt Re: Unknown Command error in my script

djow
User Off Offline

Zitieren
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):
1× editiert, zuletzt 18.05.12 22:04:36

alt Re: Unknown Command error in my script

EngiN33R
Moderator Off Offline

Zitieren
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.

alt Re: Unknown Command error in my script

Apache uwu
User Off Offline

Zitieren
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)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht