PaulDK Posted April 15, 2014 Share Posted April 15, 2014 Hello brothers i want a little help in my Pirate Script i want if i leave in the Cuboid give money to players will stop. Thanks please Help me Thanks in Advance This is the Script : Cuboid1 = createColCuboid(1995.8243408203, 1517.3013916016, 13.53852558136, 100, 14, 100) Blip = createBlip(2003, 1533, 35, 19, 2, 0, 0, 0, 255, 0, 500, getRootElement()) addEventHandler('onColShapeHit', Cuboid1, function( player ) outputChatBox("#FFFFFFYou Entered in Pirate Boat REWARD:#00FF00You will get Random Money", player, 0, 0, 0, true) setTimer(function() givePlayerMoney(player,math.random(50, 500)) end, 2000, 0 ) end ) addEventHandler('onColShapeLeave', Cuboid1, function( player ) outputChatBox("#FFFFFFYou Leaved in Pirate Boat", player, 0, 0, 0, true) return cancelEvent() end ) Link to comment
manve1 Posted April 15, 2014 Share Posted April 15, 2014 (edited) When you hit the col shape, you need to apply a timer to get if the player is in the col shape every so often and if it returns true, you give him the money, if it returns false, destroy the timer or if he leaves the col shape, destroy the timer. EDIT: You basically done that, but try this: Cuboid1 = createColCuboid(1995.8243408203, 1517.3013916016, 13.53852558136, 100, 14, 100) Blip = createBlip(2003, 1533, 35, 19, 2, 0, 0, 0, 255, 0, 500, getRootElement()) addEventHandler('onColShapeHit', Cuboid1, function( player ) outputChatBox("#FFFFFFYou Entered in Pirate Boat REWARD:#00FF00You will get Random Money", player, 0, 0, 0, true) theMoneyTimer = setTimer(function() if isElementWithinColShape(p,Cuboid1) then givePlayerMoney(p,math.random(50, 500)) elseif isTimer(theMoneyTimer) then destroyTimer(theMoneyTimer) end end, 2000, 0 ) end ) addEventHandler('onColShapeLeave', Cuboid1, function( player ) outputChatBox("#FFFFFFYou Leaved in Pirate Boat", player, 0, 0, 0, true) if isTimer(theMoneyTimer) then destroyTimer(theMoneyTimer) end end ) Edited April 15, 2014 by Guest Link to comment
PaulDK Posted April 15, 2014 Author Share Posted April 15, 2014 oh Dude Thanks to your help i Fix it 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