Jump to content

help with object and colshapes


MAB

Recommended Posts

i am trying to make a resource like that one

here is my codes.. not working and there is nothing in the debug..

note : i tried the startx,starty,startz

client :

function throw (weapon,ammo,hitx,hity,hitz,hitelement,startx,starty,startz) 
    if ( weapon == 4 ) then 
        local sx,sy,sz = getPedWeaponMuzzlePosition(source) 
        knife = createObject (335,sx,sy,sz,90,0,0,"OutQuad") 
        col = createColCuboid (sx,sy,sz) 
        attachElements (col,knife) 
        moveObject(knife,2000,hitx,hity,hitz) 
        triggerServerEvent ("take",localPlayer) 
        addEventHandler("onColShapeHit",col,damage) 
        setTimer(destroy,2000,1,col) 
        setTimer(destroy,2000,1,knife) 
    end 
end 
addEventHandler ("onClientPlayerWeaponFire",getLocalPlayer(),throw) 
  
function damage (hit) 
    if ( getElementType(hit) == "player" ) then 
        setPedAnimation(hit,"KNIFE","KILL_Knife_Ped_Die") 
        setTimer(setPedAnimation,2500,1,hit,nil,nil) 
        setTimer(setElementHealth,2500,1,hit,0) 
    end 
    if ( getElementType(hit) == "vehicle" ) then 
       local health = getElementHealth(hit) 
       setElementHealth(hit,health-10) 
    end 
    if isElement(knife) then 
      destroyElement(knife) 
    elseif isElement(source) then 
      destroyElement(source) 
    end 
end 
  
function destroy (element) 
    if isElement(element) then 
       destroyElement(element) 
    end 
end 

server :

addEvent("take",true) 
addEventHandler("take",root,function() 
takeWeapon(source,4) 
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...