Hi there, i'd like to have a databse table and, on player login with resource "logingui" ( i think with the exported event "clientLoginSuccess" but i'm not sure ) the server gives the player the cash the player has the last time he logged in. I did this script but it doesn't work... :
function aggiorna (source)
local sourcemoney = getPlayerMoney ( source )
result2 = executeSQLQuery("SELECT cash FROM cashes WHERE player=?", source )
executeSQLQuery("UPDATE cashes SET cash=? WHERE player='".. source .."'", sourcemoney )
outputChatBox ( "Money updated", source )
end
addEventHandler ( "onPlayerQuit", getRootElement(), aggiorna )
function daisoldi (source)
local result = executeSQLSelect ( "cashes", "cash", "player = '" .. source .. "'" )
givePlayerMoney ( source, result[1].cash )
end
addEventHandler ( "clientSuccessLogin", getRootElement(), daisoldi )
function creatavola ( )
executeSQLQuery("CREATE TABLE IF NOT EXISTS cashes ( cash NUMERIC, player TEXT )" )
local source = getLocalPlayer
outputChatBox ( "SQL Table successfully created" , source )
end
addEventHandler ( "onResourceStart", getRootElement(), creatavola )
For non-italia readers ( 98% of forum members ), "aggiorna" means refresh. "daisoldi" means givemoney . "creatavola" means createtable.
The table is created but when it have to refresh player money i get this error:
' attempt to concatenate a local 'source' ( a userdata value ) '
Question
AlexMiller
Hi there, i'd like to have a databse table and, on player login with resource "logingui" ( i think with the exported event "clientLoginSuccess" but i'm not sure ) the server gives the player the cash the player has the last time he logged in. I did this script but it doesn't work... :
For non-italia readers ( 98% of forum members
), "aggiorna" means refresh. "daisoldi" means givemoney . "creatavola" means createtable.
The table is created but when it have to refresh player money i get this error:
' attempt to concatenate a local 'source' ( a userdata value ) '
Thank you.
Link to comment
4 answers to this question
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