Jump to content

help with createobject


FelipeMallmann

Recommended Posts

Hello guys, can someone help me?

my doubt is how to make this command just work one time, I mean, when the object is already created it should be impossible to create another, but when it explode you should be able to create again

function createBarrier(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    barrierObject = createObject(1225, x-1, y, z-0.6) 
    if (isPedInVehicle(thePlayer)) then 
  
    end 
end 
addCommandHandler("explosivo", createBarrier) 
  
function deleteBarrier(thePlayer) 
    if (isElement(barrierObject)) then 
        destroyElement(barrierObject) 
    else 
        outputChatBox("Nao existe nenhum explosivo criado!", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("removerexplosivo", deleteBarrier) 

Link to comment
local blockCreate = false 
  
function createBarrier(thePlayer) 
    if (blockCreate ~= true) then 
        local x, y, z = getElementPosition(thePlayer) 
        barrierObject = createObject(1225, x-1, y, z-0.6) 
        if (barrierObject ~= false) then 
            blockCreate = true 
        end 
        if (isPedInVehicle(thePlayer)) then 
      
        end 
    else 
        outputChatBox("Creating barrier blocked, delete your existing one first.") 
    end 
end 
addCommandHandler("explosivo", createBarrier) 
  
function deleteBarrier(thePlayer) 
    if (isElement(barrierObject)) then 
        destroyElement(barrierObject) 
        blockCreate = false 
    else 
        outputChatBox("Nao existe nenhum explosivo criado!", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("removerexplosivo", deleteBarrier) 

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