Would this work?

The title says it all:
function savePos()

ply:SetNWInt(“pos”, ply:GetPos)

hook.Add(“PlayerDisconnected”, “playerdisconnected”, savePos)

function loadPos()

ply:SetPos( ply:GetNWInt(“pos”) )

hook.Add(“PlayerInitialSpawn”, “initialspawn”, loadPos)

Where is this saving to? 0.o
and please, do your own testing, find the problems, before posting. If everyone posted a script they made in 5 minutes on a school computer there would be thousands of posts.

You got the idea right but it will not work with the var type you are using. Use this instead. Also the method you are using will not save the pos permanently. When the server restarts or the player leaves it will be wiped. You would either need to save it to SQL or a text document.

It seems he is saving it temporarily to a network int.

That kind of defeats the purpose doesn’t it?


Your functions do not take “ply” as a parameter but you are using it within the functions. Your functions should be defined like this:
[lua]function loadPos( ply )[/lua]
So that the player object can be passed as ply.

SetNWInt will only allow an integer, while a position requires a vector. Either use SetNWVector as suggested, but I suggest you store a variable on the player instead
[lua]ply.my_variable = Vector( 1, 1, 1 )
ply:SetPos( ply.my_variable )[/lua]
You are calling SetNWInt with “ply:GetPos” as a second argument. You should be using parentheses since you are calling a function
Setting a NWInt when the player is disconnecting is pointless, it’ll be inaccessible once the player disconnects, I’m fairly sure NWVars are flushed once the entity becomes NULL.
Try setting PData with a JSON encoded vector instead.

Quit whoring your broken addon all over everyone’s posts.
He didn’t even say this was for DarkRP…

  1. Have you tested it?
  2. I shared it twice
  3. I assumed it’s for Darkrp because…What’s the point of saving position on TTT, JB or sandbox

You know what they say about assume… Makes an ASS of U and ME :smiley:

its** untested **code, but should work

hook.Add(“PlayerInitialSpawn”, function(ply)
if file.Exists(“savepositions/”… string.gsub(victim:SteamID(), “:”, “”)…".txt") then
local pos = file.Read(“savepositions/”…string.gsub(ply:SteamID(), “:”, “”)…".txt", “DATA”)
pos = string.Explode(" ", pos)
ply:SetPos( Vector( tonumber(pos[1]), tonumber(pos[2]), tonumber(pos[3]) ) )

hook.Add(“PlayerDisconnect”, function(ply)
local pos = tostring(LocalPlayer():GetPos())
pos = string.Explode(" “, pos)
for k,v in pairs(pos) do
pos[k] = math.Round(tonumber(v))
file.Write(“savepositions/”… string.gsub(ply:SteamID(), “:”, “”) …”.txt", table.concat(pos, " “))
print(“Saved pos of “… ply:Nick() …” (”…string.gsub(ply:SteamID(), “:”, “”)…”)")

hook.Add(“PlayerDeath”, function(victim, inf, attacker)
if file.Exists(“savepositions/”… string.gsub(victim:SteamID(), “:”, “”)…".txt") then
file.Delete(“savepositions/”… string.gsub(victim:SteamID(), “:”, “”)… “.txt”)

– Just thought you might didn’t need this, so commented it. If it’s needed just comment it again.

Oh I see now thanks

Do you know what pseudo means?

not genuine; sham.

[editline]2nd October 2014[/editline]

synonyms: bogus, sham, phony, artificial, mock, ersatz, quasi-, fake, false, spurious, deceptive, misleading, assumed, contrived, affected, insincere;


Pseudocode (pronounced SOO-doh-kohd) is a detailed yet readable description of what a computer program or algorithm must do, expressed in a formally-styled natural language rather than in a programming language. Pseudocode is sometimes used as a detailed step in the process of developing a program. It allows designers or lead programmers to express the design in great detail and provides programmers a detailed template for the next step of writing code in a specific programming language.

He gives OP code and youse critic him on a word he used. (That also has many context’s )

-Snip It’s still not a word- :smiley:

Pseudocode is a word though…

Most sites seem to use the same method of spell checking… It’s horrible. It leaves out many words that are in the dictionary.