Jump to content

Money Trasfer


#Paper

Recommended Posts

The script can't retrieve the player: "

-----------SERVER SIDE 
function trasferMoney(theReicivitor, theInviator, amount) 
local target = tostring(theReicivitor) 
        local account = getPlayerAccount(theInviator) 
            if not (isGuestAccount(account)) then 
                if (target) then 
                    if (amount) then 
                        local targetPlayer = getPlayerFromName(tostring(target)) 
                        local amount = math.floor(tonumber(amount)) 
                        if (targetPlayer) then 
                            local targetAccount = getPlayerAccount(targetPlayer) 
                            if not (isGuestAccount(targetAccount)) then 
                                if not (source == targetPlayer) then 
                                    if (amount > 0) then 
                                        local sourceCash = getAccountData(account, "cash") 
                                        if (tonumber(sourceCash) > amount) then 
                                            setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).. " #FFB200donated " ..tostring(amount).. "$ to #FFFFFF"..getPlayerName(targetPlayer).."#FFB200!", getRootElement(), unpack(scriptcol[1])) 
                                            addStat(account, "cash", -amount) 
                                            addStat(targetAccount, "cash", amount) 
                                        else 
                                            outputChatBox("* Sorry but you don't that much money that you want to donate!", source, unpack(scriptcol[2])) 
                                        end 
                                    else 
                                        outputChatBox("* Invalid number! Please enter a number > 0!", source, unpack(scriptcol[2]))                      
                                    end 
                                else 
                                    outputChatBox("* Your can't donate money to yourself!", source, unpack(scriptcol[2]))                            
                                end 
                            else 
                                outputChatBox(targetError, source, unpack(scriptcol[2]))                             
                            end 
                        else 
                            outputChatBox("* Could not find player!", source, unpack(scriptcol[2]))                          
                        end 
                    else 
                        outputChatBox("* Error: Please enter an amount! SYNTAX: !donate ", source, unpack(scriptcol[2]))                        
                    end 
                else 
                    outputChatBox("* Error: Please enter a player name! SYNTAX: !donate ", source, unpack(scriptcol[2]))                    
                end 
            else 
                outputChatBox(registerError, source, unpack(scriptcol[2]))               
            end                      
    end 
addEvent("onMoneyTrasf", true) 
addEventHandler("onMoneyTrasf", getRootElement(), trasferMoney) 
----------------------CLIENT SIDE 
function trasfMoney() 
if source == GUIEditor_Button[2] then 
local theRei = guiGridListGetItemText ( GUIEditor_Grid[2], guiGridListGetSelectedItem ( GUIEditor_Grid[2]), 1 ) 
local amount = guiGetText(GUIEditor_Edit[1]) 
triggerServerEvent("onMoneyTrasf", getLocalPlayer(), theRei, getLocalPlayer(), amount) 
end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor_Button[2], trasfMoney) 

P.S: In the gridlist there are the fully names whit the codes, so idk why the script can't get the player...

Link to comment
-----------SERVER SIDE 
function trasferMoney(theReicivitor, theInviator, amount) 
local target = tostring(theReicivitor) 
        local account = getPlayerAccount(theInviator) 
            if not (isGuestAccount(account)) then 
                if (target) then 
                    if (amount) then 
                        local targetPlayer = getPlayerFromName(target) 
                        local amount = math.floor(tonumber(amount)) 
                        if (targetPlayer) then 
                            local targetAccount = getPlayerAccount(targetPlayer) 
                            if not (isGuestAccount(targetAccount)) then 
                                if not (source == targetPlayer) then 
                                    if (amount > 0) then 
                                        local sourceCash = getAccountData(account, "cash") 
                                        if (tonumber(sourceCash) > amount) then 
                                            setTimer(outputChatBox,50,1,"* #FFFFFF"..getPlayerName(source).. " #FFB200donated " ..tostring(amount).. "$ to #FFFFFF"..getPlayerName(targetPlayer).."#FFB200!", getRootElement(), unpack(scriptcol[1])) 
                                            addStat(account, "cash", -amount) 
                                            addStat(targetAccount, "cash", amount) 
                                        else 
                                            outputChatBox("* Sorry but you don't that much money that you want to donate!", source, unpack(scriptcol[2])) 
                                        end 
                                    else 
                                        outputChatBox("* Invalid number! Please enter a number > 0!", source, unpack(scriptcol[2]))                     
                                    end 
                                else 
                                    outputChatBox("* Your can't donate money to yourself!", source, unpack(scriptcol[2]))                           
                                end 
                            else 
                                outputChatBox(targetError, source, unpack(scriptcol[2]))                            
                            end 
                        else 
                            outputChatBox("* Could not find player!", source, unpack(scriptcol[2]))                         
                        end 
                    else 
                        outputChatBox("* Error: Please enter an amount! SYNTAX: !donate ", source, unpack(scriptcol[2]))                       
                    end 
                else 
                    outputChatBox("* Error: Please enter a player name! SYNTAX: !donate ", source, unpack(scriptcol[2]))                   
                end 
            else 
                outputChatBox(registerError, source, unpack(scriptcol[2]))              
            end                     
    end 
addEvent("onMoneyTrasf", true) 
addEventHandler("onMoneyTrasf", getRootElement(), trasferMoney) 

Btw, post your whole client side script.

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