Jump to content

zone and position problem


Wei

Recommended Posts

Posted
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

Diet with russian vodka, lose 3 days in one week !

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

Developer @ MYVAL

Posted

@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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Surely localPlayer will always exist, thus both the position and zone name will never return false.

Retired

Posted
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 ?

Diet with russian vodka, lose 3 days in one week !

Guest Guest4401
Posted
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 

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