Jump to content

Error


Msypon

Recommended Posts

Posted

Line 21: attempt to index field '?'

addEventHandler ( 'onResourceStart', resourceRoot, 
    function ( ) 
        executeSQLCreateTable ( 'SQLData', 'money INT, serial STRING' ) 
    end 
) 
  
addCommandHandler ( 'savesql', 
    function ( player ) 
        local serial = getPlayerSerial ( player ) 
        local money = getPlayerMoney ( player ) 
        executeSQLQuery ( 'UPDATE SQLData SET money = ? WHERE serial = ?', money, serial ) 
    end 
) 
  
addCommandHandler ( 'loadsql', 
    function ( player ) 
        local serial = getPlayerSerial ( player ) 
        local result = executeSQLQuery ( 'SELECT money FROM SQLData WHERE serial = ?', serial ) 
        if ( type ( result ) == "table" and #result == 0 ) or not result then 
            return  
            setPlayerMoney ( player, result[1].money ) 
        end 
    end 
) 

Posted
addCommandHandler ( 'loadsql', 
    function ( player ) 
        local serial = getPlayerSerial ( player ) 
        local result = executeSQLQuery ( 'SELECT money FROM SQLData WHERE serial = ?', serial ) 
        if ( type ( result ) == "table" and #result == 0 ) or not result then 
            return 
        end 
        setPlayerMoney ( player, result[1].money ) 
    end 
) 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (edited)

Where is the 'result' ?

Edited by Guest

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

You are on the database? because the "savesql" command will only update it, it won't insert the row.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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