Can someone spend 2 mins of there time to help me out ? :(

help

#1

(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
image


#2

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.


#3

I think I tried that but I will try again


#4

No because I tried this with the database and it worked fine


#5

But it is completely different. You are not using a database.


#6

But how else would I do it because the identifier is a server sided native correct?


#7

Ok I have no idea then how else to do it could you maybe show me?


#8

I am busy right now.


#9

ok well can you just do it when you got time and then pm me it?


#10

You should try and do it yourself, that way you learn.


#11

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?


#12

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?


#14

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)

#15

Thanks (20 char limit)


#16

No text has appeared in the txt file?


#17

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

#18

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

#19

image

Txt file

Also which native were u trying to use because there is 2
GetPlayerIdentifier and GetNumPlayerIndetifiers

You used GetPlayerIdentfier(s)