Jump to content

Help with outputChatBox


roaddog

Recommended Posts

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

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