Jump to content

this thing in the pic.....


Deepu

Recommended Posts

the script I used to test yours is like this

thePlayer = getLocalPlayer () 
local x,y,z = getElementPosition(thePlayer) 
  
local aa = createMarker(x + 5,y,z - 1, "cylinder", 2, 255, 2, 0, 255) 
  
function mainFunction (hitElement) 
     
   function ZeroSeeds() 
        dxDrawText("Seeds : 0", 697, 580, 842, 652, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 0", 697, 578, 842, 650, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 0", 695, 580, 840, 652, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 0", 695, 578, 840, 650, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 0", 696, 579, 841, 651, tocolor(248, 245, 14, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
   end 
  
   function MoreSeeds() 
        dxDrawText("Seeds : 50", 697, 580, 842, 652, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 50", 697, 578, 842, 650, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 50", 695, 580, 840, 652, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 50", 695, 578, 840, 650, tocolor(0, 0, 0, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
        dxDrawText("Seeds : 50", 696, 579, 841, 651, tocolor(248, 245, 14, 255), 1.00, "default-bold", "left", "top", true, true, true, true, false) 
   end 
  
   function open() 
      opened = not opened 
      if opened == true then 
      addEventHandler("onClientRender", getRootElement(), ZeroSeeds) 
      else 
      removeEventHandler("onClientRender", getRootElement(), ZeroSeeds) 
      addEventHandler("onClientRender", getRootElement(), MoreSeeds) 
      end 
   end 
end 
addEventHandler("onClientMarkerHit", aa, mainFunction) 

mhmm.... no errors but doesnt work :(

Link to comment

Fine, since neither of you can script anything.

Client-side

function drawSeeds( ) 
    dxDrawText( "Seeds: " .. getElementData( localPlayer, "job:seeds" ), 0, 0, 100, 60, tocolor( 255, 255, 255, 255 ), 1.0, "default-bold", "left", "top", true, false, true, false, false ) 
end 
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function( ) 
        addEventHandler( "onClientRender", root, drawSeeds ) 
    end 
) 

Server-side

local seedMarker = createMarker( 0, 0, 3, "cylinder", 1.5, 220, 160, 20, 180 ) 
local maxSeedAmount = 50 
  
function getSeedAmount( player ) 
    if ( not player ) or ( not getElementType( player ) ~= "player" ) then return end 
    return ( getElementData( player, "job:seeds" ) and tonumber( getElementData( player, "job:seeds" ) ) or 0 ) 
end 
  
function setSeedAmount( player, amount ) 
    local amount = tonumber( amount ) 
    if ( not player ) or ( not getElementType( player ) ~= "player" ) or ( not amount ) or ( amount and amount < 0 ) then return end 
    setElementData( player, "job:seeds", math.min( maxSeedAmount, amount ), true ) 
    return true 
end 
  
addEventHandler( "onMarkerHit", seedMarker, 
    function( hitElement, matchingDimension ) 
        if ( getElementType( hitElement ) ~= "player" ) or ( not matchingDimension ) then return end 
        setSeedAmount( hitElement, getSeedAmount( hitElement ) + 1 ) 
        outputChatBox( "You picked up one seed.", hitElement, 20, 245, 20, false ) 
    end 
) 

Edited by Guest
Link to comment

Feel free to learn scripting by reading the following sources.

https://wiki.multitheftauto.com/wiki/Server_Manual

https://wiki.multitheftauto.com/wiki/Resources

https://wiki.multitheftauto.com/wiki/Sc ... troduction

viewtopic.php?f=148&t=40809

If you can't get it to work, I would give up hope if I was you, sorry. Scripting isn't for everybody and it seems it's hard for you to understand what a variable is and how you can use it even though I have given you three links to the variable manual that is very easy to catch and learn. Same goes to element data, which I am using in the code I posted above. Again, if you don't understand the way it works, I'd stop and read the manuals above.

Please stop asking and make them yourself.

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