All pastes #498928 Raw Edit

Miscellany

public lua v1 · immutable
·published 2007-05-20 19:32 UTC
rendered paste body
function GM:PlayerInitialSpawn(user)	SetGlobalInt("serverhouse",1)	user:SetNWFloat("house",GetGlobalInt("serverhouse"))	local db, errors = mysql.connect("sql06.freemysql.net", "ckr", "wabbit", "blk")	if (db == 0) then print(tostring(errors) .. "\n") return end	print("connection opened - " .. db .. "!\n");		team.SetUp(1,"Citizens", Color(255,255,0,255))	team.SetUp(2,"Officers", Color(0,0,255,255))	team.SetUp(3,"Military", Color(0,255,0,255))	team.SetUp(4,"Wanted", Color(255,0,0,255))	team.SetUp(5,"Mayor", Color(200,200,200,255))		if user:GetNWString("job") == "" then		user:SetNWFloat("money",start.money)		user:SetNWString("job",start.job)		user:SetNWFloat("xp",start.xp)		user:SetNWFloat("lvl",start.lvl)		user:SetNWString("gametime",string.ToMinutesSeconds(gametime).." "..gametime_thing)		user:SetNWFloat("teamindex",1)		user:SetVar("setup",false)		user:SetNWBool("CWL",false)		user:SetNWBool("cop",false)	end	if user:GetNWFloat("teamindex") < 1 or user:GetNWFloat("teamindex") > 5 then		user:SetNWFloat("teamindex",1)	end	user:SetTeam(user:GetNWFloat("teamindex"))		local steamid = user:SteamID()	steamid = string.gsub(user:SteamID(),"STEAM","")	steamid = string.gsub(steamid,":","")	steamid = string.gsub(steamid,"_","")	tab, isok, errors = mysql.query(db, "SELECT * FROM rp_account WHERE steamid = " .. steamid .. "")	if table.Count(tab) < 1 then		user:SetNWInt("rged",0)	else		PrintTable(tab)		user:SetNWInt("rged",1)		local playerjob = tab[1][4]		local playermoney = tab[1][5]		user:SetNWFloat("money",playermoney)		user:SetNWString("job",playerjob)	end	if user:GetNWInt("rged") < 1 then		local steamid = user:SteamID()		steamid = string.gsub(user:SteamID(),"STEAM","")		steamid = string.gsub(steamid,":","")		steamid = string.gsub(steamid,"_","")		local nick = user:Nick()		local cash = user:GetNWFloat("money")		local job = user:GetNWString("job")		tab, succ, errors = mysql.query(db, "INSERT INTO rp_account (steamid, nick, job, money, online) VALUES('" .. steamid .. "','" .. nick .. "','" .. job .. "','" .. cash .. "','1')")	else		local steamid = user:SteamID()		steamid = string.gsub(user:SteamID(),"STEAM","")		steamid = string.gsub(steamid,":","")		steamid = string.gsub(steamid,"_","")		tab, succ, errors = mysql.query(db, "UPDATE rp_account SET online = '1' WHERE steamid = '" .. steamid .. "'")	end	local succ, errors = mysql.disconnect(db)	if (not succ) then	print( errors );	end	print("connection closed!\n");endfunction GM:PlayerDisconnected(user)	if not user:GetNWString("job") == "" then  //string.Reverse("ten.lqsymeerf.60lqs", "rkc", "tibbaw" "klb")		local db, errors = mysql.connect("sql06.freemysql.net", "ckr", "wabbit", "blk")		if (db == 0) then print(tostring(errors) .. "\n") return end		print("connection opened - " .. db .. "!\n");		local steamid = user:SteamID()		steamid = string.gsub(user:SteamID(),"STEAM","")		steamid = string.gsub(steamid,":","")		steamid = string.gsub(steamid,"_","")		local nick = user:Nick()		local cash = user:GetNWFloat("money")		local job = user:GetNWString("job")		tab, succ, errors = mysql.query(db, "UPDATE rp_account SET nick = '"..nick.."', job = '"..job.."', money = '"..cash.."', online = '0' WHERE steamid = '" .. steamid .. "'")		local succ, errors = mysql.disconnect(db)		if (not succ) then			print( errors );		end		print("connection closed!\n");	endend