roaddog Posted April 19, 2014 Share Posted April 19, 2014 Hello MTA Im here to ask some help with my script. Okay, let me explain what the problem is, the problem is when I type /maze after the pack generated, ChatBox will say that the Maze is available because the pack is generated, but after I take the pack, It will be destroyed. I type /maze again and ChatBox says The same msg that Maze is available. the chatbox should say that There's no pack atm. function createBag() local random = math.random ( #mbag ) local x, y, z = mbag[random][1], mbag[random][2], mbag[random][3] bag = createPickup( x, y, z, 3, 1274 ) setElementCollisionsEnabled( bag, false ) outputChatBox( "A Maze-pack is available!, Search it! at Maze ", root, 101, 250, 0 ) end addEventHandler("onResourceStart", resourceRoot,createBag) addEventHandler("onPickupHit",root, function ( player ) if ( source ~= bag ) then return end if ( isPedInVehicle( player ) ) then return end destroyElement( bag ) destroyElement( bl ) randomMoney = math.random ( 3000, 5000 ) randomArmor = math.random( 10, 20 ) name = getPlayerName(player) givePlayerMoney(player,randomMoney) setPedArmor ( player, getPedArmor(player) + randomArmor ) outputChatBox(name.." found the packs, got $" .. tostring(randomMoney) .." and ".. tostring(randomArmor) .."% Armor", root, 101, 250, 0) outputChatBox("New Maze-pack will be available after 10 mins", root, 200, 250, 0) setTimer( createBag, 240000, 1 ) end) ---------here's the problem ------------ function mazeCommand(player, maze) if createBag then outputChatBox("*Maze is availabe now!",player,255,255,0) elseif not createBag then outputChatBox("There's no package available now!",player,50,255,25) end end addCommandHandler("maze", mazeCommand) That's it, I hope you get my point. sorry for my bad english Link to comment
Saml1er Posted April 19, 2014 Share Posted April 19, 2014 function createBag() local random = math.random ( #mbag ) local x, y, z = mbag[random][1], mbag[random][2], mbag[random][3] bag = createPickup( x, y, z, 3, 1274 ) if bag then createdBag = true setElementCollisionsEnabled( bag, false ) outputChatBox( "A Maze-pack is available!, Search it! at Maze ", root, 101, 250, 0 ) end return true end addEventHandler("onResourceStart", resourceRoot,createBag) addEventHandler("onPickupHit",root, function ( player ) if ( source ~= bag ) then return end if ( isPedInVehicle( player ) ) then return end createdBag = nil destroyElement( bag ) destroyElement( bl ) randomMoney = math.random ( 3000, 5000 ) randomArmor = math.random( 10, 20 ) name = getPlayerName(player) givePlayerMoney(player,randomMoney) setPedArmor ( player, getPedArmor(player) + randomArmor ) outputChatBox(name.." found the packs, got $" .. tostring(randomMoney) .." and ".. tostring(randomArmor) .."% Armor", root, 101, 250, 0) outputChatBox("New Maze-pack will be available after 10 mins", root, 200, 250, 0) setTimer( function () createBag () end, 240000, 1 ) end) function mazeCommand(player, cmd) if createdBag then outputChatBox("*Maze is availabe now!",player,255,255,0) elseif not createdBag then outputChatBox("There's no package available now!",player,50,255,25) end end addCommandHandler("maze", mazeCommand) Link to comment
roaddog Posted April 19, 2014 Author Share Posted April 19, 2014 Still not working same problem, now the pack is available, but I type /maze the chatbox says its not available, Thanks anyway Link to comment
Saml1er Posted April 19, 2014 Share Posted April 19, 2014 Just add this line at the top of the code local createdBag = true Its not even needed but maybe this variable doesn't exist as global. 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