General > Developers Corner

Lua n00b questions

<< < (2/10) > >>

Megiddo:
I missed that first line, ha ha. Even that line isn't going to work for the same reasons. csayDraw is our client side function, but we have an equivalent server side one that should be used here instead.

krooks:
Thanks for the replies, I will give it a go when I get some spare time here, hopefully tonight.

One thing that I found is as I had the running code (that printed in chat), it actually caused an exploit!
If dieing while holding shift, you would be able to speak to live people while floating around dead. In TTT, that is a big no-no.

Any idea why that might have happened? Did I leave something open or?
I wonder if it will still do this once using csay? Maybe the hud_printtalk is staying open somehow for people to use while dead?

krooks:
This is an edited post.
So I tried to do this a whole bunch of ways, none worked, then I realized I needed to use SendLua.
Here's what I currently have:

--- Code: ---victim:SendLua('ULIB.csayDraw(victim, "CLUMSY!")')
--- End code ---
and I get

--- Quote ---LuaCmd:1: attempt to index global 'ULIB' (a nil value)

--- End quote ---

I then tried

--- Code: ---victim:SendLua("function ShowKiller(victim,inflictor,killer)WordBox( 8, scrW() /2, ScrH() /2, \"CLUMSY!\", Color(255,100,100,255), Color(255,255,255,100))end")
--- End code ---
Which doesnt give me any errors (woo!), but nothing happens.

JamminR:
Well, first, there is no such thing as ULIB unless you've specifically created it.
(Lua is 100% case sensitive...ULIB is not the same as ULib) :)

And second, for whatever reasons I can't fully now remember, SendLua may not be the best practice.
(Meg/Stickly/Isnipe/others may correct me here).
I thought User messages were better, until I went to look them up on the Gmod wiki and see that 'net' library is now preferred.
Basic theory...have a function on the client side that includes the drawcommand...send a net message from server to client when it's needed.
Or, if the hook you're using is already shared or client, have the client function called. :)

Megiddo:
Please use this function instead of csayDraw.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version