Jump to content

DataBase [HELP]


Recommended Posts

Boa Tarde,

preciso de ajuda num script que salva kill e HS total so que nao ta salavando, quando player desloga do servidor zera tudo, salva a conta por serial

----- Login

Playerd2 = db_query( "SELECT * FROM players WHERE account=? LIMIT 1", getPlayerSerial(player))
	if Playerd2 and #Playerd2 > 0 then
		setPlayerMoney(player, Playerd2[1]["mwcTotal"] or 0)
		setElementData( player, "zombieskilled_total", Playerd2[1]["ZombiesTotal"])
		setElementData( player, "murders_total", Playerd2[1]["MurdesTotal"])
		setElementData( player, "alivetime_total", Playerd2[1]["AliveTime"])
		setElementData( player, "headshotsz_total", Playerd2[1]["hsTotal"] )
		setElementData( player, "headshotsp_total", Playerd2[1]["HsSPTotal"])
		setElementData( player, "banditskilled_total", Playerd2[1]["BanditTotal"])
	end
	setElementData(player, "logedin", true)

--- Salvamento por serial

addEventHandler("onElementDataChange",getRootElement(),function()
	if getElementType(source) == "player" then
		if getElementData ( source, "logedin" ) then
			local mwcTotal = getPlayerMoney(source)
			local zombiet = getElementData( source, "zombieskilled_total" )
			local murdest = getElementData( source, "murders_total" )
			local alivet = getElementData( source, "alivetime_total" )
			local heatt = getElementData( source, "headshotsz_total" )
			local heatst = getElementData( source, "headshotsp_total" )
			local banditt = getElementData( source, "banditskilled_total" )
			local d = db_query( "SELECT * FROM players WHERE account=? LIMIT 1", getPlayerSerial(source) )
			-- if d and zombiet and murdest and alivet and heatt and heatst and banditt then 
				-- if d and #d > 0 then
                	-- dbExec( dbLevel, "DELETE FROM players WHERE account=?", getPlayerSerial(source))
            	-- end
            	if not SQLite_Check(getPlayerSerial(source)) == true then
				outputChatBox("#FF0000[MW DAYZ ] - #ffffffPress #ff0000'enter' #ffffffto set up a Tent.",getRootElement(),255,255,255,true)
					dbExec(dbLevel, "INSERT INTO players (account, mwcTotal, ZombiesTotal, MurdesTotal, AliveTime, hsTotal, HsSPTotal, BanditTotal) VALUES(?,?,?,?,?,?,?,?)",getPlayerSerial(source), mwcTotal or 0, zombiet or 0,murdest or 0,alivet or 0,heatt or 0, heatst or 0, banditt or 0)
				else
                	dbExec(dbLevel, "UPDATE players SET mwcTotal=?, ZombiesTotal=?, MurdesTotal=?, AliveTime=?, hsTotal=?, HsSPTotal=?, BanditTotal=? WHERE account=?",mwcTotal ,zombiet, murdest,alivet,heatt,heatst,heatst,banditt, getPlayerSerial(source))
                end
			-- end
		end
	end
end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...