Converting client to server

Ok I have two files, one is a client menu that saves a bunch of variables, I have to move these variables from client side to server side and run a function that saves them… It’s not working though because apparently it doesn’t know the ply… (player)

cl_begin.lua
[lua]if (points < 1) or (NameText:GetValue() == “”) then
local NameFixBefore = NameText:GetValue()
local NameFixAfter = string.gsub(NameFixBefore, “,”, " ") – THis makes sure there are no comma’s in the name as that will be what we parse by.
Name = NameFixAfter
PlayerAttackLevel = AttackLevel:GetValue() – Make attack nothing
PlayerDefenseLevel = DefenseLevel:GetValue() – Make defense nothing
PlayerCraftingLevel = CraftingLevel:GetValue() – Make crafting nothing
PlayerThieveryLevel = ThieveryLevel:GetValue() – Make thieving nothing
PlayerStaminaLevel = StaminaLevel:GetValue() – Make stamina nothing
PlayerSpeedLevel = SpeedLevel:GetValue() – Make speed nothing
NewPanel:Close()
else
ButtonFinished:SetText( “Unused Points or No Name” )
end[/lua]

init.lua
[lua]function CharacterSave( ply )
if !file.IsDir(“Dusted”) then // If the data file doesn’t have a save path yet.
file.CreateDir(“Dusted”)
end
if !file.IsDir(“Dusted/Saves”) then // If no save directory in the data path
file.CreateDir(“Dusted/Saves”)
end
file.Write(“Dusted/Saves/”…ply:UniqueID()…".txt", Name…","…PlayerAttackLevel…","…PlayerDefenseLevel…","…PlayerCraftingLevel…","…PlayerThieveryLevel…","…PlayerStaminaLevel…","…PlayerSpeedLevel)
end[/lua]

Could you use datastream?

You should use concommands, read this **[Concommand.Add

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Concommand.Add)**

Eh… ConCommands would be a rather bad idea as I don’t want them to have access to the save function for any reason. :wink: I’ll check out the datastream, gotta figure out how to stick it in there.

[editline]22nd March 2011[/editline]

How would I manage to do this? I’ve played around but no matter what I do I can’t get my datastream to send? I haven’t used it before so if you can show me an example that isn’t like the wiki one that’d be glorious!

Datastream uses console commands…

The only thing you should be getting on the client is a choice e.g. Update speed for jumping you shouldn’t actually do the saving on the client, that is an exploit.

>_> You can set them to use console commands or you can use hooks. That’s what I did, nobodies calling my sexy functions anytime soon.

All datastream does is run console commands from the client -> server in a consistent stream.

It wouldnt be hard to overwrite the datastream functions to intercept and modify the data.

Just make the button run a console command.

Do every piece of saving and checking on the server to prevent exploits.