Jump to content

Claymore Mines


Try

Recommended Posts

Hello Forum! (again),

I see the createExplosion at the wiki and say u can make claymore i tryed the code but nothing,

Can you help me make one or can u explain me the code like how to create the claymore,

Thanks,

Maria.

Link to comment
function createClaymore ( x,y,z, creator ) 
    local x,y,z = getElementPosition ( creator ) 
    local claymoreObject = createObject ( 1945, x, y, z - 1, 0, 0, 90 ) --create an object which looks like a claymore 
    local claymoreCol = createColSphere ( x, y, z, 1 ) --create a col sphere with radius 1 
    setElementData ( claymoreCol , "type", "claymore" ) --store the type of colshape so it can be retrieved 
    setElementData ( claymoreCol, "object", claymoreObject ) --store the object of the claymore 
    setElementData ( claymoreCol, "creatorPlayer", creator ) --store the person who created it 
end 
  
function claymoreHit ( player, matchingDimension ) 
    if getElementData ( source, "type" ) == "claymore" then --ensure its a claymore 
        --retrieve the object associated to the claymore, and who created it 
        local claymoreObject = getElementData ( source, "object" ) 
        local claymoreCreator = getElementData ( source, "creatorPlayer" ) 
        --get the position of the claymore 
        local x,y,z = getElementPosition ( source ) 
        createExplosion ( x,y,z, 12, claymoreCreator ) --create an explosion, associated to the creator, of a small size at the col's position 
        --destroy the claymore object, and the col shape so it doesnt trigger again. 
        destroyElement ( claymoreObject ) 
        destroyElement ( source ) 
    end 
end 
addEventHandler ( "onColShapeHit", getRootElement(), claymoreHit ) 
  
addCommandHandler("claymore", function(player) --adds a commandhandler to create a claymore 
    local x, y, z = getElementPosition(player) --gets player's position 
    createClaymore(x, y, z, player) --creates the claymore 
end) 
  

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