Jump to content

Server side/Client side


megaman54

Recommended Posts

Nevermind. Another thing: why this wont work:

function onPlayerQuit ( )
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playermoney = getPlayerMoney ( source )
           setAccountData ( playeraccount, "mtafreeroam.money", playermoney )
     end
end
 
function onPlayerJoin ( )
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playermoney = getAccountData ( playeraccount, "mtafreeroam.money" )
           if ( playermoney ) then
                 setPlayerMoney ( source, playermoney )
           end
     end
end
 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin )
--
function onPlayerQuit ( )
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playerposition = getElementPosition ( source )
           setAccountData ( playeraccount, "mtafreeroam.position", playerposition )
     end
end
 
function onPlayerJoin ( )
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playerposition = getAccountData ( playeraccount, "mtafreeroam.position" )
           if ( playerposition ) then
                 setElementPosition ( source, playerposition )
           end
     end
end
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoin )

it saves everything i want bu it wont load anything. Whats wrong :|

Link to comment

I may be mistaken but I think you can't have 2 functions named the same

Either have everything in onPlayerJoin and onPlayerQuit or name the functions different

Example for naming the functions different:

function onPlayerQuitSaveMoney ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playermoney = getPlayerMoney ( source )
setAccountData ( playeraccount, "mtafreeroam.money", playermoney )
end
end
 
function onPlayerJoinLoadMoney ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playermoney = getAccountData ( playeraccount, "mtafreeroam.money" )
if ( playermoney ) then
setPlayerMoney ( source, playermoney )
end
end
end
 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuitSaveMoney )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoinLoadMoney )
--
function onPlayerQuitSavePosition ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playerposition = getElementPosition ( source )
setAccountData ( playeraccount, "mtafreeroam.position", playerposition )
end
end
 
function onPlayerJoinLoadPosition ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playerposition = getAccountData ( playeraccount, "mtafreeroam.position" )
if ( playerposition ) then
setElementPosition ( source, playerposition )
end
end
end
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuitSavePosition )
addEventHandler ( "onPlayerJoin", getRootElement ( ), onPlayerJoinLoadPosition

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