Jump to content

zone and position problem


Wei

Recommended Posts

function refreshData() 
    local x, y, z = getElementPosition( localPlayer ) or "N/A" 
    local location = getZoneName ( x, y, z ) or "N/A" 
    guiSetText( perDataLabel[5], "Position : "..x..","..y..","..z ) 
    guiSetText( perDataLabel[6], "Location : "..location ) 
end 

Error that x is a nil value

and for location is the error expected number at argument 2 got nil

Link to comment
function refreshData() 
    local x,y,z = getElementPosition( localPlayer ) or "N/A" 
    local location = getZoneName ( x,y,z ) or "N/A" 
    guiSetText( perDataLabel[5], "Position : "..x..","..y..","..z ) 
    guiSetText( perDataLabel[6], "Location : "..location ) 
end 

you use spaces in x, y, z....

Link to comment

@Alexs_Steel: The spaces between variable names has nothing to do with his problem, they make no difference.

@blazy: The only problem I see is that you set "or N/A", but the function should return 3 arguments, so with one it'll cause that error.

function refreshData ( ) 
    local x, y, z = getElementPosition ( localPlayer ) 
    local location = getZoneName ( x, y, z ) or "N/A" 
    guiSetText ( perDataLabel[5], "Position : ".. tostring ( x ) ..",".. tostring ( y ) ..",".. tostring ( z ) ) 
    guiSetText ( perDataLabel[6], "Location : ".. tostring ( location ) ) 
end 

Link to comment
function sendMoney( sPlayer, sMoney ) 
    if ( getPlayerMoney(source) >= tonumber(sMoney) ) then 
    givePlayerMoney( sPlayer, sMoney ) 
    takePlayerMoney( source, sMoney ) 
    else 
    outputChatBox("You don't have enought money", source) 
    end 
end 

how can I make here if the sMoney is not number then will return end instead of error ?

Link to comment
Guest Guest4401
function sendMoney(sPlayer,sMoney) 
    local sMoney = tonumber(sMoney) 
    if sMoney then 
        if getPlayerMoney(source) >= sMoney then 
            givePlayerMoney(sPlayer, sMoney) 
            takePlayerMoney(sPlayer, sMoney) 
        else 
            outputChatBox("You don't have enough money",source) 
        end 
    end 
end 

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