Jump to content

money park


OrbTanT

Recommended Posts

Posted

I am trying to make a place where, if the players are within the ColRectangle he iram win every 1 second money, can someone tell me why it is not working, or the error, not errors in debugscript.

local ColMoney = createColRectangle ( 2057.1384277344, -1258.0145263672, -185, 110 ) 
  
function moneyzone ( thePlayer, matchingDimension  )  
        local detection = isElementWithinColShape ( thePlayer, ColMoney ) 
        if ( detection ) then 
            givePlayerMoney( thePlayer, 3 ) 
        end 
end 
  
function timer ( thePlayer ) 
    setTimer( moneyzone, 1000, 1 ) 
  
end 
addEventHandler ( "onColShapeHit", getRootElement(), moneyzone ) 

Posted

Try this:

local ColMoney = createColRectangle ( 2057.1384277344, -1258.0145263672, -185, 110 ) 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
        setTimer(colShapeMoney, 1000, 0) 
    end 
) 
  
function colShapeMoney() 
    local players = getElementsWithinColShape(ColMoney, "player") 
    for k,player in ipairs(players) do   
        givePlayerMoney(player, 3) 
    end 
end 
  

  • Moderators
Posted
Nothing happens. And without errors in debug.

Make sure the script file is in your meta.xml, and that it's a server sided script.

Don't forget to restart the resource aswell.

If everything is fine then you are NOT IN the colshape.

Try this code and see the outputs to make sure everything is working and that you are actually inside that colshape:

local ColMoney = createColRectangle ( 2057.1384277344, -1258.0145263672, -185, 110 ) 
  
addEventHandler("onColShapeHit", ColMoney, function(elem) 
    outputChatBox("A "..getElementType(elem).." entered in the money colshape !") 
end) 
  
addEventHandler("onColShapeLeave", ColMoney, function(elem) 
    outputChatBox("A "..getElementType(elem).." left in the money colshape !") 
end) 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
        setTimer(colShapeMoney, 1000, 0) 
        outputChatBox("Resource started, timer is ticking ...") 
    end 
) 
  
function colShapeMoney() 
    local players = getElementsWithinColShape(ColMoney, "player") 
    outputChatBox(#players.." player(s) inside the colshape ...") 
    for k, player in ipairs(players) do   
        givePlayerMoney(player, 3) 
        outputChatBox("Gave $3 to "..getPlayerName(player)) 
    end 
end 

If the code doesn't say you entered in the colshape then there is no chance for you to get the money.

Posted

Shinigami, I did a test and it should be because the colshape is wrong (I saw it using setDevelopmentMode + showcol).

But it works. So you should to fix the colshape size.

Posted

Appears on the screen that the player is not in colRectangle, the more no can check if the player has entered or exited the colRectangle

local ColMoney = createColRectangle ( 2057.1384277344, -1258.0145263672, -185, 110 ) 
  
addEventHandler("onColShapeHit", ColMoney, function(elem) 
    outputChatBox("A "..getElementType(elem).." entered in the money colshape !") 
end) 
  
addEventHandler("onColShapeLeave", ColMoney, function(elem) 
    outputChatBox("A "..getElementType(elem).." left in the money colshape !") 
end) 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
        setTimer(colShapeMoney, 1000, 0) 
        outputChatBox("Resource started, timer is ticking ...") 
    end 
) 
  
function colShapeMoney() 
    local players = getElementsWithinColShape(ColMoney, "player") 
    outputChatBox(#players.." player(s) inside the colshape ...") 
    for k, player in ipairs(players) do   
        givePlayerMoney(player, 3) 
        outputChatBox("Gave $3 to "..getPlayerName(player)) 
    end 
end 

  • Moderators
Posted

As DNL291 said, you need to fix the colshape:

local ColMoney = createColRectangle ( 2057.1384277344, -1258.0145263672, -185, 110 ) 

It's actually not where you think it is.

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