• HELP! Self Health is going over maxhealth!
    66 replies, posted
Trackster you're completely wrong unless I'm mistaking what he wants. math.Clamp works fine. https://i.imgur.com/Awd9Ole.png
Since when does Derma windows and DButtons are runned serverside?
He's saying he needs to run the SetHealth() function server side. OP did have net receivers, so we can assume he knows how to use them..?
the OP probably didnt think about that. But from what i see with the math.clamp, in my brain it doesnt work like the OP wants it do. But maybe im wrong...idk
code?
You're wrong
ok then. lol..
can i get from you the code pls?
Can I get a jar full of sweat and tears from you?
i just rethinked about it and i realized my mistake. I would be right if it would be ONLY math.clamp but since its in Sethealth, wich SETS the health instead of ADDING it to the health thats already there, the math.clamp version works. If its serverside ofc.
eureka moment(sort of)
Okay I'll help you out a little but you should probably not be spoonfed so here: Entity/SetHealth Entity/GetMaxHealth util.AddNetworkString net.Start net.SendToServer net.Receive math.Clamp You'll need to figure out how to use these, firstly. I'll try frame it for you best i can bud... -Clientside code: Your vgui code can go here ( panel -> buttons ) In your buttons DoClick function ( button.DoClick = function() ... end ), you should send a net message to the server. -Serverside code: All you need to do is setup a network string for receiving / sending ( util.AddNetworkString(...) ) and create a net receive function for that message ( net.Receive( "message", function (length, ply) ... end ) ) In that function, you want to be running ply:SetHealth( ... ) with the math.Clamp() function clamping between 0 and the players max health. Your input should be ply:Health() + 50 ( or whatever amount ). Please, read the above web pages before asking again for help ( if i was unclear here then sure ask for clarification ), but you should make sure to read these pages, understand them AND then have another crack at it before asking for more help or spoonfed code.
Ight thank you very much my friend! It worked perfectly! Heres the code: util.AddNetworkString( "SetHealth1" )  net.Receive( "SetHealth1", function( length, ply ) ply:SetHealth( math.Clamp( ply:Health() + 25, 0, ply:GetMaxHealth() ) ) end) util.AddNetworkString( "SetHealth2" )  net.Receive( "SetHealth2", function( length, ply ) ply:SetHealth( math.Clamp( ply:Health() + 50, 0, ply:GetMaxHealth() ) ) end) util.AddNetworkString( "SetHealth3" ) net.Receive( "SetHealth3", function( length, ply ) ply:SetHealth( math.Clamp( ply:Health() + 75, 0, ply:GetMaxHealth() ) ) end) util.AddNetworkString( "SetHealth4" ) net.Receive( "SetHealth4", function( length, ply ) ply:SetHealth( math.Clamp( ply:Health() + 100, 0, ply:GetMaxHealth() ) ) end)
This is insecure since anyone could send those net messages and set their health, you should probably add some checks server-side
Here we go again
what?
If the code you're making was for production, then in theory anyone could set their HP to full at any time by sending those net messages. What you did was purely solving your problem, but not actually doing anything productive. Proper net messages need to be effectively protected via serverside checks to ensure no foul play is possible.
And how can i secure the net messages?
Depends how you want your add-on to be used, if it's admin only menu then you would check if they're admin server-side.
Its a Entity medkit for SCP-RP
Its a Entity medkit for SCP-RP. so what do i need to put in?
you can use these to check if a player is an admin or superadmin: Player/IsAdmin Player/IsSuperAdmin
just want to let u know i want that everyone can heal him with that
You need to use the net libary to be able to use server sided stuff from the client. CodeBlue has a great tutorial on that if you search for him on YouTube:)
then why did you...
what? i did?
No this is serverside. That's actually a whole other issue I wanted to touch on because this is pretty heavily exploitable.
Whats about a timer?
Yeah, what about it? That wouldn’t fix anything, that would just delay the exploit.
Yeah but i want that the user can use the medkit too!
Sorry, you need to Log In to post a reply to this thread.