我有一个问题,这是我的疑问:
unique_id = LocalPlayer():GetNWString ("SteamID")
sql.Query("UPDATE player_info SET money = money - 5 WHERE unique_id = '"..unique_id.."'")
这是mysqlite和LUA,我需要它在执行时减去“x”金额。
调用函数
function PlayerInitialSpawn( ply )
timer.Create("SteamIDDelay", 1, 1, function()
SteamID = ply:SteamID()
ply:SetNWString("SteamID", SteamID)
timer.Create("SaveStats", 10, 0, function() SaveStats( ply ) end)
PlayerExists( ply )
ply:ChatPrint( "Stats Saved!" )
end)
end
保存统计功能
function SaveStats ( ply )
money = ply:GetNWInt("money")
unique_id = ply:GetNWString ("SteamID")
sql.Query("UPDATE player_info SET money = "..money.." WHERE unique_id = '"..unique_id.."'")
end