Okay so, I've noticed over my many years of scripting that concommand.Add chooses at random times to be sulky, for no apparent reason.
Examples of this include me creating a command something like this [lua]
function Blah() print("reh") end
concommand.Add("ccom",Blah)[/lua], and whenever I try to call "ccom", through Lua or console, it says "ccom" is an unknown command.
However, more often than not, when concommand.Add decides to be sullen, I am able to fix this by adding something, like a "2", to the end of the command, so it'd be "ccom2", rather than "ccom".
Why it does this I've never been able to figure out, but then I don't care too much when its so easily fixed.
However, I've encountered just such a sullenness again. Here is the code. Rest assured that all variables are assigned properly, and arguments are being passed properly.
[lua] function ParsePurchase(user,com,arg)
local uid = arg[1]
if _Shop[uid] then
local t = _Shop[uid]
if user:CanAfford(t.Cost) then
user:AddCash(t.Cost * -1)
AddItemToInventory(user,uid)
else
user:PrintMessage(3,"You can not afford this item.")
end
end
function Empty()
end
concommand.Add("testfunc",Empty)
concommand.Add("~dr~_purchase2",Empty)[/lua]
And here's the problem. Calling either "testfunc" or "~dr~_purchase2" (the latter has to be done via script, obviously), it says they're both unknown commands.
If I do "lua_run Empty()" or "lua_run ParsePurchase(player.GetByID(1),"",{"9mm-mg"}", however (9mm-mg is the argument I'm trying to pass, again, just trust me on this), then the functions call perfectly fine.
Furthermore, if I do this, "lua_run concommand.Add("juice",ParsePurchase)", and then put into my console "juice 9mm-mg", then ParsePurchase calls perfectly fine.
Why is concommand.Add so fickle, and how can I fix it?
:saddowns:
[editline]02:16AM[/editline]
Fuck I'm stupid.
I figured it out.
I hate ends.
Hate them, hate them, hate them.
Still, my question stands at the first part.
Damn it, damn it, damn it.
:emo:
Which part are you exactly still having problems with? Why concommands act weird? I've never actually had that problem.
Sorry, you need to Log In to post a reply to this thread.