Forum

> > CS2D > Scripts > How to create a file??
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to create a file??

23 replies
Page
To the start Previous 1 2 Next To the start

old Re: How to create a file??

Skyppy
User Off Offline

Quote
user Raaj Nadar has written
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.

old Re: How to create a file??

Dousea
User Off Offline

Quote
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
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview