Jump to content

Money Trasfer


#Paper

Recommended Posts

When i press the btn nothing happen...

-------------------SERVER SIDE 
addEvent("onMoneyTrasfer", true) 
function gotPlayerFromName(theSender, theReiciver, theMoney) 
local getSenderCash = getElementData(theSender, "Money") 
local getReiciverCash = getElementData(theReiciver, "Money") 
if not theMoney <= getSenderCash then 
setElementData(theSender, "Money", getSenderMoney - theMoney) 
setElementData(theReiciver, "Money", getReiciverCash + theMoney) 
outputChatBox( "#ccf7fcMoney Trasfer: #ffffff"..getPlayerName(theSender).." #9ACD32gave you #43CD80$"..tonumber(money).."#9ACD32!", thePlayer, 255,255,255,true) 
else 
outputChatBox( "#ccf7fcShop: #9ACD32You have not enough money!", thePlayer, 255,255,255,true) 
end 
end 
addEventHandler("onMoneyTrasfer", getRootElement(), gotPlayerFromName) 
------------------------CLIENT SIDE 
if not getMoney == "" then 
local getMoney = guiGetText(GUIEditor_Edit[3]) 
local selectedPlayer = guiGridListGetItemText(GUIEditor_Grid[3], guiGridListGetSelectedItem(GUIEditor_Grid[3]), 1) 
triggerServerEvent("onMoneyTrasfer", getLocalPlayer(), getLocalPlayer(), getPlayerFromName(selectedPlayer), getMoney) 
else 
outputChatBox( "#ccf7fcYou must insert an import!", getLocalPlayer(), 255,255,255,true) 
end 

Link to comment
  • Moderators

At the moment I can see just one error here:

if not getMoney == "" then 
local getMoney = guiGetText(GUIEditor_Edit[3]) 

you use the getMoney variable before their declaration; so:

local getMoney = guiGetText(GUIEditor_Edit[3]) 
if not getMoney == "" then 
    local selectedPlayer = guiGridListGetItemText(GUIEditor_Grid[3], guiGridListGetSelectedItem(GUIEditor_Grid[3]), 1) 
    triggerServerEvent("onMoneyTrasfer", getLocalPlayer(), getLocalPlayer(), getPlayerFromName(selectedPlayer), getMoney) 
else 
    outputChatBox( "#ccf7fcYou must insert an import!", getLocalPlayer(), 255,255,255,true) 
end 

And here make some tonumber ( just for security ^^ ):

addEvent("onMoneyTrasfer", true) 
function gotPlayerFromName(theSender, theReiciver, theMoney) 
    local getSenderCash = tonumber( getElementData(theSender, "Money") ) 
    local getReiciverCash = tonumber( getElementData(theReiciver, "Money") ) 
    theMoney = tonumber( theMoney ) 
    if ( theMoney <= getSenderCash  ) then 
        setElementData(theSender, "Money", getSenderMoney - theMoney) 
        setElementData(theReiciver, "Money", getReiciverCash + theMoney) 
        outputChatBox( "#ccf7fcMoney Trasfer: #ffffff"..getPlayerName(theSender).." #9ACD32gave you #43CD80$"..tonumber(money).."#9ACD32!", theSender, 255,255,255,true) 
    else 
        outputChatBox( "#ccf7fcShop: #9ACD32You have not enough money!", theSender, 255,255,255,true) 
    end 
end 
addEventHandler("onMoneyTrasfer", getRootElement(), gotPlayerFromName) 

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