Jump to content

[HELP] Saving interface bar value in SQL


furruz

Recommended Posts

I'm working on a hunger script on MTA Paradise. I want to save on SQL the value of the hunger bar when the player quits.

I got the function to get the bar value but it is only Client-side. How can i pass the bar value information to the server to save it on SQL?

Link to comment

my codes:

[Client]

  
  
function onQuitGame( player, hambre1 ) 
    local hambre1 = exports.hunger:getHungerState(player) 
  
triggerServerEvent ( "guardarhambre", getLocalPlayer(), hambre1 )  
end 
addEventHandler( "onClientPlayerQuit", getRootElement(), onQuitGame ) 

[server]

function hambreHandler ( player, hambre1 ) 
    hambre = hambre1 
    --setElementData(player,"hambre",hambre1) 
    exports.sql:query_free( "UPDATE characters SET hunger = "..hambre.." WHERE characterID = " .. tonumber( getCharacterID( player ) ) ) 
     
     
end 
addEvent( "guardarhambre", true ) 
addEventHandler( "guardarhambre", getRootElement(), hambreHandler ) 

It does not save the data. No errors in log

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...