Jump to content

help me with send cash


UAEpro

Recommended Posts

hello .. i dont know what is wrong

cside

  
        Playernamelabel = guiCreateLabel(222,18,132,16,"Player Name :",false,tab3) 
guiLabelSetColor(Playernamelabel,255,255,255) 
guiLabelSetVerticalAlign(Playernamelabel,"top") 
guiLabelSetHorizontalAlign(Playernamelabel,"left",false) 
        playernameedit = guiCreateEdit(174,38,227,32,"",false,tab3) 
        Amountlabel = guiCreateLabel(222,80,132,16,"Amount :",false,tab3) 
guiLabelSetColor(Amountlabel,255,255,255) 
guiLabelSetVerticalAlign(Amountlabel,"top") 
guiLabelSetHorizontalAlign(Amountlabel,"left",false) 
        AmountEdit = guiCreateEdit(174,101,227,32,"",false,tab3) 
        sendMoneyButton = guiCreateButton(189,155,200,44,"Send",false,tab3) 
        playerGridList = guiCreateGridList(9,18,142,183,false,tab3) 
----------------------- 
    playerGridList = guiCreateGridList(9,18,142,183,false,tab3) 
    playersColumn = guiGridListAddColumn(playerGridList,"Players",0.85) 
    guiGridListSetSelectionMode(playerGridList,2) 
    for id, plaItem in ipairs(getElementsByType("player")) do 
    row = guiGridListAddRow ( playerGridList ) 
    guiGridListSetItemText ( playerGridList, row, playersColumn, getPlayerName ( plaItem ), false, false ) 
    end 
    addEventHandler( "onClientGUIClick", playerGridList, setGUI ) 
    end 
function setGUI ( ) 
selectedRow, selectedCol = guiGridListGetSelectedItem( playerGridList ) 
gridPlayerName = guiGridListGetItemText( playerGridList, selectedRow, selectedCol ) 
guiSetText ( playernameedit, gridPlayerName ) 
end 
  

sside

  
  
function giveThem ( playerNick,amount ) 
local cash = getPlayerMoney(source) 
if (cash > tonumber(amount)) then  
moneyToGive = getPlayerFromName(playerNick)  
if (moneyToGive ~= false) then -- if there player exist 
givePlayerMoney(moneyToGive,amount)  
name = getPlayerName(source) 
takePlayerMoney(source,amount) 
outputChatBox("You've given money amount of: " .. amount .. "$ for: " .. playerNick,source,255,255,0)  
outputChatBox(name .. " has given you money amount of: " .. amount .. "$!",moneyToGive,255,255,0)  
else 
outputChatBox("Player did not exist",source,255,0,0)  
end 
else 
outputChatBox("You are trying to send amount of money that you even dont have?",source,255,0,0) -- if the sender does not have the amount of money he wants to send 
  end 
end 
addEvent( "Sendcaash", true ) 
addEventHandler( "Sendcaash", getRootElement(), giveThem ) 
  
  

but it give me error

attempt to compare number with nil

with this line

if (cash > tonumber(amount)) then

and how i can add money column to scoreboard

i tryied to make like this

sside

  
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function () 
local localPlayer = getLocalPlayer() 
    exports.scoreboard:addScoreboardColumn("Money") 
    setElementData(localPlayer,"Money",0) 
end 
 ) 
  

but it not working ,, the money column is therer but its always 0

Edited by Guest
Link to comment

You could say in which line there is that error.

And if you have two separate problems - make two topic.

For money send GUI check out Resources - there's two such scripts, one is mine ^^.

For scoreboard - you did setElementData with value 0, and thinking why it's zero?

you have to setTimer(1 sec, or even 5 sec is enough, no need to spam server with changing values for 50ms) and every that 1 or 5 sec get player money and set result to element data.

Link to comment

ok ^^

for money

i want to use mine cus i want to do complete script and this is a small part of the script

the problem

when i click send

i got in debugscript

error server.lua:221:attempt to compare Number with nil

line 221 = line 5

5# if (cash > tonumber(amount)) then

Link to comment

How to solve such problems

  
function giveThem ( playerNick,amount ) 
outputDebugString("source player: "..getPlayerName(source)) 
local cash = getPlayerMoney(source) 
outputDebugString("cash: "..tostring(cash)) 
outputDebugString("amount: "..tostring(amount)) 
if (cash > tonumber(amount)) then 
  

either cash or amount is nil (i dont remember what is the result of tonumber(nil)) [nil = not set]

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