Deepu Posted February 24, 2014 Share Posted February 24, 2014 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
Castillo Posted February 24, 2014 Share Posted February 24, 2014 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 ) Link to comment
Deepu Posted February 24, 2014 Author Share Posted February 24, 2014 hmmm but castillo, it outputs in the screen in a dxdrawtext as "nil" its written nil in screen Link to comment
Moderators Citizen Posted February 24, 2014 Moderators Share Posted February 24, 2014 Use /drugs and it won't be nil anymore Link to comment
Deepu Posted February 24, 2014 Author Share Posted February 24, 2014 when I do /drugs it says false Link to comment
Deepu Posted February 24, 2014 Author Share Posted February 24, 2014 http://imgur.com/vjebYRF http://imgur.com/oi7wGRM Link to comment
Moderators Citizen Posted February 24, 2014 Moderators Share Posted February 24, 2014 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
Deepu Posted February 24, 2014 Author Share Posted February 24, 2014 what does that mean? the ones u showed Link to comment
Deepu Posted February 24, 2014 Author Share Posted February 24, 2014 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? Link to comment
WhoAmI Posted February 24, 2014 Share Posted February 24, 2014 setElementData(localPlayer, "drugs", getElementData(localPlayer, "drugs") + 1) Link to comment
Moderators Citizen Posted February 24, 2014 Moderators Share Posted February 24, 2014 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
Deepu Posted February 25, 2014 Author Share Posted February 25, 2014 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? Link to comment
Karuzo Posted February 25, 2014 Share Posted February 25, 2014 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. Link to comment
Anubhav Posted February 25, 2014 Share Posted February 25, 2014 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) Link to comment
Deepu Posted February 25, 2014 Author Share Posted February 25, 2014 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
myonlake Posted February 25, 2014 Share Posted February 25, 2014 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
Deepu Posted February 25, 2014 Author Share Posted February 25, 2014 how to show that if the text in edit box is a number then set the number ? Link to comment
myonlake Posted February 25, 2014 Share Posted February 25, 2014 Use tonumber( ) like I did above. Link to comment
Saml1er Posted February 25, 2014 Share Posted February 25, 2014 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 Link to comment
Deepu Posted February 25, 2014 Author Share Posted February 25, 2014 k thanks I will check if it no work i ask Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now