Jump to content

i need getElementData new prob


Deepu

Recommended Posts

Posted
local marker = createMarker(2483.900390625, -1666.7001953125, 13.3, "cylinder", 1, 255, 2, 0) 
  
function theThing () 
   pro = getElementData(localPlayer, "Drugs") 
   if pro == 0 then 
   noob = setElementData(localPlayer, "Drugs", 1) + pro 
   padappa() 
   end 
end 
addCommandHandler("drugs", theThing) 
  
    function padappa () 
        dxDrawText(""..pro.."", 507, 466, 786, 569, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false) 
    end 
   addEventHandler("onClientRender", root, padappa) 

it says attempt to concatenate pro( a boolean value)

Posted
function padappa ( ) 
    dxDrawText ( tostring ( pro ), 507, 466, 786, 569, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false ) 
end 
addEventHandler ( "onClientRender", root, padappa ) 

  • Moderators
Posted

First wrong reply

It's your fault, replace

if pro == 0 then 

by

if not pro then 

EDIT: Ok wait, what /drugs should do ? I don't really understand what you tried to do.

I think I got it:

replace this:

pro = getElementData(localPlayer, "Drugs") 

by this:

pro = getElementData(localPlayer, "Drugs") or 0 

Posted

how can I tell that :

if pro == 1 or more then

setElementData(localPlayer, "drugs", pro + 1 more)

how do I do that in lua code?

  • Moderators
Posted
how can I tell that :

if pro == 1 or more then

setElementData(localPlayer, "drugs", pro + 1 more)

how do I do that in lua code?

local currentDrugs = getElementData(localPlayer, "drugs") or 0 
setElementData(localPlayer, "drugs", currentDrugs + 1) 

Posted

hmmm..... it works but uh how can I like in a marker if a player stands then he gets the amount of drugs that he enters in the gui edit box. I don't know if its 1 or 5 or 8. depends on the number he writes in gui's edit box

any answers citizen?

Posted

Use guiGetTex for it.

  
local currentDrugs = getElementData(localPlayer, "drugs") or 0  
editbox = guiCreateEditBox(.....) 
drugss = guiGetTex(editbox) 
setElementData(localPlayer, "drugs", currentDrugs+drugss) 
  
  

Wrote this on the phone.

Posted

KRZO I know you wrote on phone.

I will correct it.

  
  
local currentDrugs = getElementData(localPlayer, "drugs") or 0 
editbox = guiCreateEdit(.....) 
drugss = guiGetText(editbox) 
setElementData(localPlayer, "drugs", currentDrugs+drugss) 
  
  
  

Posted

yeah I made it it worked but uh... I have to do /drugs amount and /drugs again to make it to the number

local marker = createMarker(2483.900390625, -1666.7001953125, 13.3, "cylinder", 1, 255, 2, 0) 
  
function theThing (cmd, Number) 
   currentDrugs = getElementData(localPlayer, "drugs") or 0 
   noob = setElementData(localPlayer, "drugs", currentDrugs + Number) 
end 
addCommandHandler("drugs", theThing) 
  
function padappa ( ) 
    dxDrawText ( tostring ( currentDrugs ), 507, 466, 786, 569, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, true, false, false ) 
end 
addEventHandler ( "onClientRender", root, padappa ) 

Posted

Use tonumber( ) to make it a number value.

local marker = createMarker( 2483.900390625, -1666.7001953125, 13.3, "cylinder", 1, 255, 2, 0 ) 
local drugCount = 0 
  
addCommandHandler( "drugs", 
    function( cmd, amount ) 
        local amount = tonumber( amount ) 
        if ( amount ) and ( amount > 0 ) then 
            local currentDrugs = tonumber( getElementData( localPlayer, "drugs" ) ) or 0 
            drugCount = currentDrugs + amount 
            setElementData( localPlayer, "drugs", drugCount ) 
        else 
            outputChatBox( "SYNTAX: /" .. cmd .. " [amount]", 220, 185, 20, false ) 
        end 
    end 
) 
  
addEventHandler( "onClientRender", root, 
    function( ) 
        dxDrawText( tostring( drugCount ), 507, 466, 786, 569, tocolor( 255, 255, 255, 255 ), 1.00, "default", "left", "top", false, false, true, false, false ) 
    end 
) 

Posted

If you want to get numbers from édit box then use:

drugss = tonumber ( guiGetText(editbox) ) 

This will convert "" into number for example, "10" into 10

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