ahmedo01 Posted November 7, 2014 Share Posted November 7, 2014 function saveonlogout(prevA) local player = getAccountPlayer(prevA) local money = getPlayerMoney( source ) local occupation = getElementData( source, "Occupation") local team = getPlayerTeam( source ) local teamname = getTeamName( team ) local x,y,z = getElementPosition( source ) local dimension = getElementDimension( source ) local interior = getElementInterior( source ) local skin = getElementModel( source ) local account = getPlayerAccount( source ) local accountname = getAccountName( account ) outputChatBox("You are logged out") if money and occupation and team and x and y and z and dimension and interior and skin and teamname then local savelocation = mysql_query(moduledb, "UPDATE 'playerlocations' SET x = '"..x.."', y = '"..y.."', z = '"..z.."' WHERE accountname = '"..accountname.."'") local saveothers = mysql_query(moduledb, "UPDATE 'playerinfo' SET money = '"..money.."', occupation = '"..occupation.."', team = '"..teamname.."', dimension = '"..dimension.."', interior = '"..interior.."', skin = '"..skin.."' WHERE accountname = '"..accountname.."'") --mysql_free_result(savelocation) --mysql_free_result(saveothers) else outputChatBox("Error! Cannot save informations!") end end addEventHandler("onPlayerLogout",getRootElement(),saveonlogout) i cant get source source gives boolean why? Link to comment
ALw7sH Posted November 7, 2014 Share Posted November 7, 2014 function saveonlogout(prevA) local player = getAccountPlayer(prevA) local money = getPlayerMoney( player ) local occupation = getElementData( player, "Occupation") local team = getPlayerTeam( player ) local teamname = getTeamName( team ) local x,y,z = getElementPosition( player ) local dimension = getElementDimension( player ) local interior = getElementInterior( player ) local skin = getElementModel( player ) outputChatBox("You are logged out") if money and occupation and team and x and y and z and dimension and interior and skin and teamname then local savelocation = mysql_query(moduledb, "UPDATE 'playerlocations' SET x = '"..x.."', y = '"..y.."', z = '"..z.."' WHERE accountname = '"..prevA.."'") local saveothers = mysql_query(moduledb, "UPDATE 'playerinfo' SET money = '"..money.."', occupation = '"..occupation.."', team = '"..teamname.."', dimension = '"..dimension.."', interior = '"..interior.."', skin = '"..skin.."' WHERE accountname = '"..prevA.."'") --mysql_free_result(savelocation) --mysql_free_result(saveothers) else outputChatBox("Error! Cannot save informations!") end end addEventHandler("onPlayerLogout",getRootElement(),saveonlogout) Link to comment
SkatCh Posted November 7, 2014 Share Posted November 7, 2014 (edited) function Save () if not ( isGuestAccount(getPlayerAccount( source ) ) ) then local money = getPlayerMoney( source ) local occupation = getElementData( source, "Occupation") local team = getPlayerTeam( source ) local teamname = getTeamName( team ) local x,y,z = getElementPosition( source ) local dimension = getElementDimension( source ) local interior = getElementInterior( source ) local skin = getElementModel( source ) local account = getPlayerAccount( source ) local accountname = getAccountName( account ) local save = mysql_query(moduledb,"UPDATE playerinfo SET money=?, occupation=?, team=?, wanted=?, x=?, y=?, z=?, interior=?, dimension=?, skin=?, account=?, accountName=?" ,money ,occupation ,team ,wanted ,x ,y ,z ,interior ,dimension ,skin ,account ,accountname ) end end addEventHandler ( "onPlayerQuit", root, Save ) Edited November 8, 2014 by Guest Link to comment
ahmedo01 Posted November 8, 2014 Author Share Posted November 8, 2014 i need help waiting... bump. Link to comment
Bilal135 Posted November 8, 2014 Share Posted November 8, 2014 function saveonlogout(prevA) local player = getAccountPlayer(prevA) local money = getPlayerMoney(prevA) local occupation = getElementData(prevA, "Occupation") local team = getPlayerTeam(prevA) local teamname = getTeamName(prevA) local x,y,z = getElementPosition(prevA) local dimension = getElementDimension(prevA) local interior = getElementInterior(prevA) local skin = getElementModel(prevA) local account = getPlayerAccount(prevA) local accountname = getAccountName(prevA) outputChatBox("You are logged out", prevA) if money and occupation and team and x and y and z and dimension and interior and skin and teamname then local savelocation = mysql_query(moduledb, "UPDATE 'playerlocations' SET x = '"..x.."', y = '"..y.."', z = '"..z.."' WHERE accountname = '"..accountname.."'") local saveothers = mysql_query(moduledb, "UPDATE 'playerinfo' SET money = '"..money.."', occupation = '"..occupation.."', team = '"..teamname.."', dimension = '"..dimension.."', interior = '"..interior.."', skin = '"..skin.."' WHERE accountname = '"..accountname.."'") --mysql_free_result(savelocation) --mysql_free_result(saveothers) else outputChatBox("Error! Cannot save informations!", prevA) end end addEventHandler("onPlayerLogout",getRootElement(),saveonlogout) Link to comment
Anubhav Posted November 9, 2014 Share Posted November 9, 2014 (edited) What's that? prevA give's the account name lmfao. And Bilal you are getting it's account name? function saveonlogout(prevA) local player = source local money = getPlayerMoney(player) local occupation = getElementData(player, "Occupation") local team = getPlayerTeam(player) local teamname = getTeamName(player) local x,y,z = getElementPosition(player) local dimension = getElementDimension(player) local interior = getElementInterior(player) local skin = getElementModel(player) local account = getAccount(prevA) local accountname = getAccountName(account) outputChatBox("You are logged out", player) if money and occupation and team and x and y and z and dimension and interior and skin and teamname then local savelocation = mysql_query(moduledb, "UPDATE 'playerlocations' SET x = '"..x.."', y = '"..y.."', z = '"..z.."' WHERE accountname = '"..accountname.."'") local saveothers = mysql_query(moduledb, "UPDATE 'playerinfo' SET money = '"..money.."', occupation = '"..occupation.."', team = '"..teamname.."', dimension = '"..dimension.."', interior = '"..interior.."', skin = '"..skin.."' WHERE accountname = '"..accountname.."'") --mysql_free_result(savelocation) --mysql_free_result(saveothers) else outputChatBox("Error! Cannot save informations!", player) end end addEventHandler("onPlayerLogout",getRootElement(),saveonlogout) Edited November 11, 2014 by Guest Link to comment
Moderators IIYAMA Posted November 11, 2014 Moderators Share Posted November 11, 2014 Player must be defined as source. and the first argument(of the function) is the last account he was in. 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