Forum

> > CS2D > Scripts > How to create a file??
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to create a file??

23 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: How to create a file??

Skyppy
User Off Offline

Zitieren
user Raaj Nadar hat geschrieben
OK I am online in phone as soon as I log on in my PC I will post the error script thanks Leave and bounty


Okay but later of what you can please post the code, and i make the lua complete with this for you.

alt Re: How to create a file??

Dousea
User Off Offline

Zitieren
It is just for an example. You can do anything with that code. cs2d lua hook join hook bests to load the file and do your commands, while cs2d lua hook leave hook to save and write the file. In these codes there's no cs2d lua cmd addhook, you can add it by yourself.
function joinhook (id)
	local file = io.open ("sys/lua/" .. player (id, "name") .. ".txt", "r")
	
	if (file) then
		local values = {}
		
		for value in file:read ():gmatch ("[^%s+]") do
			table.insert (values, value)
		end
		
		parse ("setscore " .. id .. " " .. values[1])
		parse ("setdeaths " .. id .. " " .. values[2])
		
		file:close ()
	end
end

function leavehook (id)
	local file = io.open ("sys/lua/" .. player (id, "name") .. ".txt", "w+")
	
	file:write (player (id, "score") .. " " .. player (id, "deaths"))
	file:close()
end
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht