• Strange problem with net.Receive()
    7 replies, posted
Hi everyone ! I'm making a little gamemode on my own and I have a little problem since I re-organized my code. I have a table called "classes", in wich there is some attributes (like other tables). I've implemented some methods to this table, doing this way : function classes:callClass(ply) -- My code end In a server-side file, I got a net.Receive(), in wich I've putted a method of the classes table. I'm doing like that : net.Receive("mybeautyfulnet", classes:Method) When I get in game, I got this beautifull error : [ERROR] gamemodes/mygamemode/gamemode/modules/mymod/sv_my_mod.lua:40: function arguments expected near ')' I can't find the reason of this error, I think everything is okay... If someone can help me to fix this issue, it can be very cool Thanks a lot in advance for all your help, Gabyfle
Read this page: net.Receive The examples on there show how a net.Receive should be setup properly.
You're not missing any function arguments on net.Receive(). You're missing them on classes.Method. The function is clases.Method, not classes:Method. Using a colon instead of a period means it will try to run the function, as in doing classes:Method(). It is complaining that you're missing the () after the word Method, and that any arguments Method may need are not being supplied. Namely, Method needs to take two arguments: Length and Ply, as described in moku's link.
So, if I follow what you are saying to me, I have to create an anonymous function in wich I call my method ?
I am not 100% certain; it's been a long time for me since I coded for this game. But I don't think the function needs to be anonymous; I think you're just referencing it with the wrong punctuation symbol.
The function does not have to be anonymous - the issue with your original code is you are using a colon instead of a dot. This still won't work with your method, however, since it takes a class as the first argument, yet net callbacks provide len and player arguments.
I didn't know this subtlety of language, thanks I have no more errors, but my code does not work, the parameters are not passed (len and ply = nil)...
really class:function(arguments) is just a fancy way of doing class.function(self,arguments)
Sorry, you need to Log In to post a reply to this thread.