Markn1 Posted December 27, 2018 Share Posted December 27, 2018 (edited) Столкнулся с проблемой сохранения, помогите ее решить. Дебаг ничего не выдает function onResStartP () executeSQLQuery ( "CREATE TABLE IF NOT EXISTS License ( p_acc TEXT, driving_lic INTEGER DEFAULT 0 )" ); outputDebugString ( "Table license created" ); for i, player in ipairs(getElementsByType("player")) do local acc = getAccountName ( getPlayerAccount ( player ) ); local getDataCS = executeSQLQuery ( "SELECT driving_lic FROM License WHERE p_acc=?", acc ); if ( #getDataCS ~= 0 ) then setElementData ( player, "driving_lic", ( getDataCS[1]["driving_lic"] ) or false ); else executeSQLQuery ( "INSERT INTO License VALUES ( ?, ? )", acc, false ); end end end addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource ( ) ), onResStartP ) function onLogin ( _, account ) local acc = getAccountName( account ); local getDataCS = executeSQLQuery ( "SELECT driving_lic FROM License WHERE p_acc=?", acc ); if ( #getDataCS ~= 0 ) then setElementData ( source, "driving_lic", ( getDataCS[1]["driving_lic"] ) or false ); else executeSQLQuery ( "INSERT INTO License VALUES ( ?, ? )", acc, false ); end end addEventHandler ( "onPlayerLogin", root, onLogin ) function onResStop () for i, player in ipairs(getElementsByType("player")) do local acc = getAccountName ( getPlayerAccount ( player ) ); local getLic = ( getElementData ( player, "driving_lic" ) ); executeSQLQuery ( "UPDATE License SET driving_lic=? WHERE p_acc=?", getLic, acc ); end end addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource ( ) ), onResStop ) function onPlayerQuit ( ) local acc = getAccountName ( getPlayerAccount ( source ) ); local getLic = ( getElementData ( player, "driving_lic" ) ); executeSQLQuery ( "UPDATE License SET driving_lic=? WHERE p_acc=?", getLic, acc ); end addEventHandler( "onPlayerQuit", root, onPlayerQuit ) addEventHandler( "onPlayerLogout", root, onPlayerQuit ) После того как сдал на права: addEvent ( "finishDriveServer", true ) addEventHandler ( "finishDriveServer", root, function ( thePlayer ) local veh = getPedOccupiedVehicle ( source ); local acc = getAccountName ( getPlayerAccount ( source ) ); local getLic = ( getElementData ( thePlayer, "driving_lic" ) ); if veh then local vehHealth = getElementHealth ( veh ) / 10; if ( vehHealth < 60 ) then outputChatBox ( "Автомобиль поврежден более чем на 40%, вы не сдали на права!", source, 255, 255, 255, true ); else setElementData ( source, "driving_lic", true ); outputChatBox ( "Поздравляем, Вы успешно прошли все испытания и сдали на права!", source, 255, 255, 255, true ); executeSQLQuery ( "UPDATE License SET driving_lic=? WHERE p_acc=?", getLic, acc ); end removePedFromVehicle ( source ); destroyElement ( veh ); setElementDimension ( source, 0 ); end end ) Мое предположение, при старте ресурса: setElementData ( player, "driving_lic", ( getDataCS[1]["driving_lic"] ) or false ); Edited December 27, 2018 by Markn1 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now