(Speaking on the be half of the owner)
I am having problem with this if anyone could help me please?
server file:
AddEventHandler("playerConnecting", function()
identifier = GetPlayerIdentifiers(source)[1]
TriggerClientEvent("moneySave")
end)
Client file:
RegisterNetEvent("moneySave")
AddEventHandler("moneySave", function ()
local playerName = GetPlayerName(GetPlayerPed(-1))
file = io.open("test.txt", "a")
if file then
file:write("ID: "..identifier)
file:write("\n")
file:write("ID: "..identifier)
end
end)
Here is my error i get
You are not closing the file.
EDIT: The player is not spawned in and you are trying to get their identifier. You need to wait for them to spawn.
I think I tried that but I will try again
No because I tried this with the database and it worked fine
But it is completely different. You are not using a database.
But how else would I do it because the identifier is a server sided native correct?
Ok I have no idea then how else to do it could you maybe show me?
ok well can you just do it when you got time and then pm me it?
You should try and do it yourself, that way you learn.
2 Likes
I have no idea tho could you just give me a clew because I just cant figure this out I have tried for hours now?
1 Last thing I have tired so many possible ways I just dont know how I though people where supposed to help each other well all u have done is given me code that dont work and said do it your self all I ask is for little help with 1 script?
Some help:
This in server side, in the right moment to get the player identifier…
local identifier = GetPlayerIdentifiers(source)[1]
TriggerClientEvent("moneySave", source, identifier)
Client:
RegisterNetEvent("moneySave")
AddEventHandler("moneySave", function (idtf)
local playerName = GetPlayerName(GetPlayerPed(-1))
file = io.open("test.txt", "a")
if file then
file:write("ID: "..idtf)
file:write("\n")
file:write("ID: "..idtf)
end
end)
No text has appeared in the txt file?
So that is another question,.
Good function for you:
function saveonfile(msg)
local file = io.open('resources/resourcename/test.txt', "a")
newFile = msg
file:write(newFile)
file:flush()
file:close()
end
so like this then?
CLIENT.LUA
RegisterNetEvent("moneySave")
AddEventHandler("moneySave", function (idtf)
local playerName = GetPlayerName(GetPlayerPed(-1))
saveonfile("Identifier: "..idtf)
saveonfile("\n")
saveonfile("Name: "..playerName)
end)
function saveonfile(msg)
local file = io.open('resources/vs_money/test.txt', "a")
newFile = msg
file:write(newFile)
file:flush()
file:close()
end
Txt file
Also which native were u trying to use because there is 2
GetPlayerIdentifier and GetNumPlayerIndetifiers
You used GetPlayerIdentfier(s)