Saving Data

Hallo, i am working on a system where a player has to decide at the start if he want a female player model or a male player model. I want to save the data but i dont know how i do this and if i should use PData or sql.

Pls help

You should use the SQL library instead of PLAYER:Set/GetPData. This avoids any possible collisions.

Ok so when i click the Male Model button it does ply:SetPData(“model”, male) and same with the Female?

And when i want to check if the Model is Male/Female then i have to use ply:GetPData(“model”) right?

That’s right. But again this function is subject to collisions (see: https://wiki.facepunch.com/gmod/Player:SetPData)

Should i do it like this?

sql.Query(“CREATE TABLE model_table( LocalPlayer():Nick() , “MALE” )” )

You have some examples on this page to help you.

Hi, i tried it but the only thing i got is this:

sql.Query([[INSERT INTO ‘gender_db_table’( id , name ) VALUES( {1} , {2})]], { ply:SteamID64(), “Male”})

and this dose not work.