Derma Give Money Network Issues

Solved

net.ReadInt takes a number as a first argument denoting the length of the integer. It should be the same value as what you’re using to send the integer. Also, you are trusting the client way too much. Oh and num isn’t defined.

Yeah I didn’t want to paste the complete code for the client side; just the essentials. There is more which limits the input of the client that has been omitted for clarity. Thanks, I will try it and see what happens. Lol can’t believe I made such a simple mistake but that’s what humans do best I suppose.

Edit: An issue still persists where receiver does not register as an entity. When sending money over the value works but the entity data does not transfer:



[ERROR] gamemodes/.../init.lua:145: attempt to call method 'StatsAddCoins' <a nil value>
   1. func - gamemodes/.../init.lua:145
     2. unknown - lua/includes/modules/net.lua:32


is the reciver the player who sends the networking?

The receiver is intended to be the player (entity) receiving money.

print it before sending and check if its ok

Every attempt to print it fails clientside. I tried concommand( “say” … ) and that didn’t work so well either. The nil value may be because it is a boolean still, but I am not sure as I set receiver to a player with the for loop. It’s a mess.

Just print(receiver) and look in console…

false gets printed in console

just a heads up this is a very bad way to network giving/sending money, you don’t check if pl or rec actually has the cash or if the number is positive, anyone with half a brain could exploit this.


 if ( gcmenunumwang:GetValue() < 1 ) or ( gcmenunumwang:GetValue() > coins ) 

Was omitted on purpose to focus on the issue at hand. =p Thank for the heads up, I’m aware.

if gcmenunumwang is on the client then it can still be exploited. you should verify on the server

The complete if statement (which I have not posted as it is not the focus of this post) disables the submission button if the above conditions aren’t met. I wasn’t aware a DNumberWang ( gcmenunumwang ) displayed on a derma menu for the client could not be put on the client side. Could you explain? Sorry if I am misunderstanding what you are saying. What do you mean to verify?

Also what about the entity issue? That’s my main question at the moment.

Dude I can just send the net message manually, no need to go through your button

[editline]17th May 2015[/editline]

never trust the client, never
You are executing code on someone elses machine, they got full control of their machine and can change, add and remove any code they wish

I understand and agree but regardless of trust issues why does:



                                        local receiver = false
	
					for _,v in pairs( player.GetAll() ) do
						if tonumber( v:UniqueID() ) == tonumber( uid ) then
							receiver = v
						end
					end


not acknowledge receiver set as an entity of type player but instead set receiver as a nil value? Just trying to understand the issue here.

I might be the dumb one here, but you’re returning absolutly nothing in the code you just pasted. You set the value of receiver to v yes, but are you returning it afterwards? Most likely you’ll need to do :



return receiver


Also, rule #1 of programming : Everyone is dumb and never trust anybody.