PointShop2 PS2_AddStandardPoints, Client Side

I am making a little derma that adds points to a player on ps2:

ply = LocalPlayer()
local points = ply.PS2_Wallet.points
local Frame = vgui.Create( “DFrame” )
Frame:SetSize( 300, 150 )
Frame:SetTitle( “Free Money !!” )
Frame:SetVisible( true )
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
local Redeem = vgui.Create(“DButton”, Frame)
Redeem:SetSize(280, 110)
Redeem:SetText(“Redeem one time reward of 2000 points !”)
Redeem.DoClick = function()
if ply.PS2_Wallet then
ply:PS2_AddStandardPoints(2000, “You got your one time reward of 2000 points !”)



The problem is that PS2_AddStandardPoints is server sided… so I cannot execute it on a derma script, because they’re client sided !
That’s why I wanna know how to execute a server sided function on a derma, that is client sided.

Thanks !

This can be achieved by using net messages. Here’s some links that can help you.




Tip: NEVER TRUST THE CLIENT! Run some checks to see if the client is an Admin, Superadmin, etc. if necessary.

The net library is what you’re looking for.

-sniped :frowning:

You mean some checks like a “if” that check if he’s admin ? C:
And thank you for your answer !!

It’s a bit different in your case. If it’s a one time reward, I would suggest using NWBools.

You should run

Entity:SetNWBool on the server, and run

Entity:GetNWBool on the client to see if they have gotten the reward yet.


net.Receive( "YourMessage", function( len, ply )
    if ( IsValid( ply ) ) then
        if ply:GetNWBool( "YourNWBool", false ) == false then
            ply:SetNWBool( "YourNWBool", true )
            ply:PS2_AddStandardPoints(2000, "You got your one time reward of 2000 points !")
end )

Oh, thank you… I had the idea of doing it with a ClientConVar… but I MUST NOT, they could just change it to 1 again, and have the reward again. This helped me alot ! c:

Should I do something like :

– in sv
ply:SetNWBool( “reward”, true )

– in cl
if LocalPlayer():GetNWBool(“reward”) == true then
give the points

No problem. I added a snippet of code above to give you a rough idea of what to do.

Oh did not see it, forget about the code I asked.

[editline]19th November 2016[/editline]

Just what does “len” mean in the first line ? c:

The length of the net message - 99% of the time it’ll do/mean nothing but needs to be there before ply because that’s how argument orders work

Thank you very much… good to know.

What’s an example of use for len, anyway? I don’t think I’ve ever seen it used before.

[editline]19th November 2016[/editline]

Also, why rate me dumb for trying to help, Sir TEST?

A dumb example:

-- server
net.WriteInt(someNumber, 32)
net.WriteData(someBinaryString, #someBinaryString)

    local num = net.ReadInt(32)
    local dat = net.ReadData(len/8 - 4)
    SomeCrapFunction(num, dat)