Forum

> > CS2D > General > Lua Question - Parse Hook Problem
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Lua Question - Parse Hook Problem

3 replies
To the start Previous 1 Next To the start

old Lua Question - Parse Hook Problem

Anders4000
User Off Offline

Quote
Do any of you guys know what's wrong with this?
The reson why i have this code is because players gets their console spammed with errors when the server strips weapons that they havn't got. (I got an for-statement earlier in my code where it strips weapons from 1-88.) And i couldn't find anything that i could use to check if the player had a specific item.


1
2
3
4
5
6
7
8
9
10
addhook("parse","OnParse")
function OnParse(text)
	for a = 1, 88, 1 do							--a = item id
		for b = 1, game("sv_maxplayers"), 1 do		 --b = player id
			if text = ("strip "..b.." "..a) then
				return 1						 --normal parsing, ignore unknown cmds
			end
		end
	end
end

old Re: Lua Question - Parse Hook Problem

DC
Admin Off Offline

Quote
this doesn't change anything I guess. return 1 just causes normal parsing so nothing changes. it does not suppress error messages or anything (only unknown-command error messages but strip is a known command).

I don't see a way to solve this at the moment. looks like Lua in CS2D needs an additional command.

old Re: Lua Question - Parse Hook Problem

Jermuk
User Off Offline

Quote
Not the best solution but it will work:
Make for every player an array, with all weapons he owns. Update it regulary with OnDrop, OnCollect, OnBuy, ...
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview