• Money system using meta and derma - Inquiry
    7 replies, posted
Hey guys. I've written all the code for a working money system, using meta. However, here's the problem I'm having: Essentially, if I want to add money for the player, let's say a derma button does this, and adds 500 money, this code is executed on the clientside, and the serverside does not update it's money amounts. How can I bridge the clientside derma button that adds 500 money and a serverside function that runs upon clicking the button that runs the serverside addmoney function?
I would use a console command. Of course the argument would be delivered as a string, but that is easily dealt with.
[QUOTE=Ludicium;40326262]I would use a console command. Of course the argument would be delivered as a string, but that is easily dealt with.[/QUOTE] This would work, but I prefer [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1b73.html"]net[/URL].
[QUOTE=The Android1;40326283]This would work, but I prefer [URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1b73.html"]net[/URL].[/QUOTE] Okay, I was able to send numbers to the server. How do I tell the server what player send the data? In other words, how do I send userdata by using the net stuff?
[QUOTE=Dreken;40333004]Okay, I was able to send numbers to the server. How do I tell the server what player send the data? In other words, how do I send userdata by using the net stuff?[/QUOTE] When you define the callback function for net.Receive the parameters for the function should be. [lua] local function blahblahblah( length, _player ) // do stuff end net.Receive("BLAH_STRING", blahblahblah) [/lua]
[QUOTE=Ludicium;40333079]When you define the callback function for net.Receive the parameters for the function should be. [lua] local function blahblahblah( length, _player ) // do stuff end net.Receive("BLAH_STRING", blahblahblah) [/lua][/QUOTE] I've gotten that part to work already, I just wrote it a little differently. When I do: [lua]MsgN("Player: ".._player)[/lua] It prints the number 32. Why is that? How do I convert that number to my userdata?
I guess i flipped the parameters then XD, switch length and _player *EDIT* no mine are most certainly in the correct order
THANK YOU! Edit: I had to add len, ply. [lua]net.Receive("AddCash", function (len, ply)[/lua] Before that, I just had ply. So my first parameter was called ply but it was actually getting length. Silly me. The second parameter in that argument is the player, but you have to have the first argument present to get to the second one.
Sorry, you need to Log In to post a reply to this thread.