Jump to content

[Check] Bug Prevention Script


BieHDC

Recommended Posts

hello,

i dedcted a bug in a login panel which saves money too.

So if player log out then the money is also there and he can buy something and then login again and have lost no money!

So i wrote small script for setting money to 0 on logout but i am not sure if works:

function money() 
    setPlayerMoney( getRootElement(), 0 ) 
end 
addEventHandler("onPlayerLogout",getRootElement(),money) 

and can you tell me sure that the money will set back on login?

Link to post
function money() 
    setPlayerMoney( source, 0 ) 
end 
addEventHandler("onPlayerLogout",getRootElement(),money) 

and can you tell me sure that the money will set back on login?

Well, that depend of your script that save the money, normally yes.

Edited by Guest
Link to post

This is script for save and load

can i add there script?

function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local playermoney = getPlayerMoney ( source )  
            local playerpoints = getElementData(source,"Points") 
            local playertime = getElementData(source,"Playtime") 
            local playerwins = getElementData(source,"Wins") 
            local playerdeaths = getElementData(source,"Deaths") 
            local playerhunters = getElementData(source,"Hunters") 
            setAccountData ( playeraccount, "money", playermoney ) 
            setAccountData ( playeraccount, "points", playerpoints ) 
            setAccountData ( playeraccount, "playtime", playertime ) 
            setAccountData ( playeraccount, "wins", playerwins ) 
            setAccountData ( playeraccount, "deaths", playerdeaths ) 
            setAccountData ( playeraccount, "hunters", playerhunters ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local playermoney = getAccountData ( playeraccount, "money" ) 
        local playerpoints = getAccountData ( playeraccount, "points" ) 
        local playertime = getAccountData ( playeraccount, "playtime" ) 
        local playerwins = getAccountData ( playeraccount, "wins" ) 
        local playerdeaths = getAccountData ( playeraccount, "deaths" ) 
        local playerhunters = getAccountData ( playeraccount, "hunters" ) 
        setPlayerMoney ( source, playermoney ) 
        setElementData(source,"Points",playerpoints or 0) 
        setElementData(source,"Playtime",playertime or 0) 
        setElementData(source,"Wins",playerwins or 0) 
        setElementData(source,"Deaths",playerdeaths or 0) 
        setElementData(source,"Hunters",playerhunters or 0) 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 

Link to post

doesnt fixed bug sucessfully

he loose money on logout, but if he first bought in acc then logout and then login money resettet -.-

and if i make onPlayerQuit with onPlayerLogout incl the extra script?

Link to post

has no output

situation:

Client -1000 money because of buy something > logout > login > money not lost

here script therewhile

function onPlayerLogout ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local playermoney = getPlayerMoney ( source )  
            local playerpoints = getElementData(source,"Points") 
            local playertime = getElementData(source,"Playtime") 
            local playerwins = getElementData(source,"Wins") 
            local playerdeaths = getElementData(source,"Deaths") 
            local playerhunters = getElementData(source,"Hunters") 
            setAccountData ( playeraccount, "money", playermoney ) 
            setAccountData ( playeraccount, "points", playerpoints ) 
            setAccountData ( playeraccount, "playtime", playertime ) 
            setAccountData ( playeraccount, "wins", playerwins ) 
            setAccountData ( playeraccount, "deaths", playerdeaths ) 
            setAccountData ( playeraccount, "hunters", playerhunters ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local playermoney = getAccountData ( playeraccount, "money" ) 
        local playerpoints = getAccountData ( playeraccount, "points" ) 
        local playertime = getAccountData ( playeraccount, "playtime" ) 
        local playerwins = getAccountData ( playeraccount, "wins" ) 
        local playerdeaths = getAccountData ( playeraccount, "deaths" ) 
        local playerhunters = getAccountData ( playeraccount, "hunters" ) 
        setPlayerMoney ( source, playermoney ) 
        setElementData(source,"Points",playerpoints or 0) 
        setElementData(source,"Playtime",playertime or 0) 
        setElementData(source,"Wins",playerwins or 0) 
        setElementData(source,"Deaths",playerdeaths or 0) 
        setElementData(source,"Hunters",playerhunters or 0) 
    end 
end 
addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 
  
function money() 
    setPlayerMoney( source, 0 ) 
end 
addEventHandler("onPlayerLogout",getRootElement(),money) 

Link to post
function onPlayerLogout ( playeraccount ) 
            local playermoney = getPlayerMoney ( source )  
            local playerpoints = getElementData(source,"Points") 
            local playertime = getElementData(source,"Playtime") 
            local playerwins = getElementData(source,"Wins") 
            local playerdeaths = getElementData(source,"Deaths") 
            local playerhunters = getElementData(source,"Hunters") 
            setAccountData ( playeraccount, "money", playermoney ) 
            setAccountData ( playeraccount, "points", playerpoints ) 
            setAccountData ( playeraccount, "playtime", playertime ) 
            setAccountData ( playeraccount, "wins", playerwins ) 
            setAccountData ( playeraccount, "deaths", playerdeaths ) 
            setAccountData ( playeraccount, "hunters", playerhunters ) 
            setPlayerMoney( source, 0  ) 
    end 
  
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local playermoney = getAccountData ( playeraccount, "money" ) 
        local playerpoints = getAccountData ( playeraccount, "points" ) 
        local playertime = getAccountData ( playeraccount, "playtime" ) 
        local playerwins = getAccountData ( playeraccount, "wins" ) 
        local playerdeaths = getAccountData ( playeraccount, "deaths" ) 
        local playerhunters = getAccountData ( playeraccount, "hunters" ) 
        setPlayerMoney ( source, playermoney or 0 ) 
        setElementData(source,"Points",playerpoints or 0) 
        setElementData(source,"Playtime",playertime or 0) 
        setElementData(source,"Wins",playerwins or 0) 
        setElementData(source,"Deaths",playerdeaths or 0) 
        setElementData(source,"Hunters",playerhunters or 0) 
    end 
end 
addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 
  
  

Try this O_o !

Link to post

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