OrbTanT Posted January 24, 2015 Share Posted January 24, 2015 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 ) Link to comment
DNL291 Posted January 24, 2015 Share Posted January 24, 2015 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 Link to comment
OrbTanT Posted January 24, 2015 Author Share Posted January 24, 2015 Nothing happens. And without errors in debug. Link to comment
Moderators Citizen Posted January 24, 2015 Moderators Share Posted January 24, 2015 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. Link to comment
DNL291 Posted January 24, 2015 Share Posted January 24, 2015 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. Link to comment
OrbTanT Posted January 24, 2015 Author Share Posted January 24, 2015 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 Link to comment
Moderators Citizen Posted January 24, 2015 Moderators Share Posted January 24, 2015 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. 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