Jump to content

Getting a number


Tete omar

Recommended Posts

Posted

Hello there i've got a little question , and it's about , how do i get a number into " string.format " and put it on an empty label

guiSetText(TEST,string.format("[ %d ]=TEST",10,"")) 
theEmptyLabel = guiCreateLabel(..,..,..,..,"",false,test) 

"TEST" is defined as a label.

now number nine should be inside "theEmptyLabel" but not with the string, just the number alone.

Posted

What you are saying doesn't really make much sense.

Your code will only set the label text to that string, won't set the number apart.

Maybe you should use element data instead, or a table.

Posted
What you are saying doesn't really make much sense.

Your code will only set the label text to that string, won't set the number apart.

Maybe you should use element data instead, or a table.

isn't possible to use

tonumber 

or something else ... ?

cuz that number wouldn't be only and always 10, it'll be changed by the player on a different ways.

Posted
What you are saying doesn't really make much sense.

Your code will only set the label text to that string, won't set the number apart.

Maybe you should use element data instead, or a table.

isn't possible to use

tonumber 

or something else ... ?

cuz that number wouldn't be only and always 10, it'll be changed by the player on a different ways.

Can you explain better everything?

Posted
What you are saying doesn't really make much sense.

Your code will only set the label text to that string, won't set the number apart.

Maybe you should use element data instead, or a table.

isn't possible to use

tonumber 

or something else ... ?

cuz that number wouldn't be only and always 10, it'll be changed by the player on a different ways.

Can you explain better everything?

I'm just wanna get that number without that string which mixed with it ,

look

guiSetText(TEST,string.format("[ %d ]=TEST",10,"")) 
> [10]=TEST 

if i wanna get or change or do math calculations or something else with that number , what should i do ?

Posted
guiSetText(varLabel, string.format('[%d] = TEST', 10)) 

What is the problem?

It's too hard to explain ... , i'll do wat castillo told me.

Just explain how you know.

Posted

server

function onLogin(_,account) 
    local acc = getAccountData(account,"1_Time") 
        if acc == "1" then return end 
        triggerClientEvent(source,"forEveryNewPerson",source) 
end 
addEventHandler("onPlayerLogin",root,onLogin) 
function saveData(thePlayer,theAccount) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        local data = getElementData(thePlayer,"1_Time") 
        if data then 
            setAccountData(theAccount,"1_Time",tostring(data)) 
        end 
    end 
end 
addEventHandler("onPlayerQuit",root,function()saveData(source,getPlayerAccount(source))end) 
addEventHandler("onPlayerLogout",root,function(prev)saveData(source,prev)end) 

client

http://pastebin.com/GT5HMuxZ -- sorry the client side is confused with the website smiles.

gs is defined as guiSetText

metals = labels

This is a project of metals script , i mean , everyone whose joins the server then give him 10 for each metal, the player can sell and buy, so if that player bought .. e.g , 5 golds , and here goes the math calculation, then provide 5 on 10 = 15 ofc , did you understand one word from wat i said lol ?.

Posted
guiSetText(varLabel, string.format('[%d] = TEST', 10)) 

What is the problem?

He wants to have that '10' as a number and the rest as a string, but such thing is not possible.

Posted
The options c, d, E, e, f, g, G, i, o, u, X, and x all expect a number as argument, whereas q and s expect a string.

From wiki Lua.

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