Jump to content

i need getElementData new prob


Deepu

Recommended Posts

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)

Link to comment
  • Moderators

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 

Link to comment
  • Moderators
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) 

Link to comment

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 ) 

Link to comment

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 
) 

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