Jump to content

Moeny saving


bartje01

Recommended Posts

Easy o,O

function onLoginSetCash ( ) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
        if getAccountData ( account, "data.cash" ) then 
            givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) 
            outputChatBox ( "You're cash is transfered back!", source ) 
        else 
         setAccountData( account, "data.cash", 0 ) 
            outputChatBox ( "You're new and your cash will now be saved." ) 
        end 
    end 
end 
  
function onWastedSetCash ( ) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then 
        local getPlayerCash = getElementData ( source, "data.cash" ) 
        setElementData ( source, "data.cash", getPlayerCash + 100 ) 
        outputChatBox ( "You got 100$ for your death.", source ) 
    end 
end 
  
function onQuitSaveCash() 
if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
    setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onQuitSaveCash ) 
  
function onLogoutSaveCash() 
if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
    setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) 
    setPlayerMoney(source,0) 
    end 
end 
addEventHandler ( "onPlayerLogout", root, onLogoutSaveCash ) 
  
addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) 
addEventHandler ( "onPlayerWasted", root, onWastedSetCash ) 
  
  
function myCash ( thePlayer ) 
     if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
     account = getPlayerAccount(thePlayer) 
     local cash = getAccountData ( account, "data.cash" ) 
     outputChatBox ( "Your cash is: " .. tostring ( cash ), thePlayer ) 
    end 
end 
addCommandHandler ( "cash", myCash ) 

Try if it works (not tested)

Edited by Guest
Link to comment

WHere is the easy part of that :P

Didn't worked btw:(

In my console no errors or warnings

In my script editor there are errors:

')'Expected (to close '(' at line 45) near 'end'

'' expected near 'end'

')' expected (to close '(' at line 53) near 'setPlayerMoney'

Btw. Why setPlayerMoney?:P

I didn't need that with element date cash right?

Link to comment

This should work, I tested it..

function onLoginSetCash ( ) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
        if getAccountData ( account, "data.cash" ) then 
            givePlayerMoney(source, tonumber(getAccountData(account,"data.cash"))) 
            outputChatBox ( "You're cash is transfered back!", source ) 
        else 
         setAccountData( account, "data.cash", 0 ) 
            outputChatBox ( "You're new and your cash will now be saved." ) 
        end 
    end 
end 
  
function onWastedSetCash ( ) 
    if not isGuestAccount ( getPlayerAccount ( source ) ) then 
        local getPlayerCash = getAccountData ( account, "data.cash" ) 
        setAccountData ( account, "data.cash", tonumber(getPlayerCash) + 100 ) 
        outputChatBox ( "You got 100$ for your death.", source ) 
    end 
end 
  
function onQuitSaveCash() 
if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
    setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) 
    end 
end 
addEventHandler ( "onPlayerQuit", root, onQuitSaveCash ) 
  
function onLogoutSaveCash() 
if not isGuestAccount ( getPlayerAccount ( source ) ) then 
    account = getPlayerAccount(source) 
    setAccountData(account,"data.cash",tonumber(getAccountData(account,"data.cash"))+tonumber(getPlayerMoney(source))) 
    setPlayerMoney(source,0) 
    end 
end 
addEventHandler ( "onPlayerLogout", root, onLogoutSaveCash ) 
  
addEventHandler ( "onPlayerLogin", root, onLoginSetCash ) 
addEventHandler ( "onPlayerWasted", root, onWastedSetCash ) 
  
  
function myCash ( thePlayer ) 
     if not isGuestAccount ( getPlayerAccount ( thePlayer ) ) then 
     account = getPlayerAccount(thePlayer) 
     local cash = getAccountData ( account, "data.cash" ) 
     outputChatBox ( "Your cash is: " .. tostring ( cash ) .. " $ ", thePlayer ) 
    end 
end 
addCommandHandler ( "cash", myCash ) 
  

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