Sign in to follow this  
NastaseValy

function WeaponReplace

Recommended Posts

Can you help me??

elementWeaponRaplace = {}  
 function weaponReplace ( previousWeaponID, currentWeaponID )  
 --local source = getRootElement()  
 local weapon1 = getElementData(source,"currentweapon_1")  
 if not weapon1 then return end  
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1)  
 local x,y,z = getElementPosition(source)  
 local rx,ry,rz = getElementRotation(source)  
          if currentWeaponID == weapID1 then  
           if elementWeaponRaplace[source] then  
            detachElementFromBone(elementWeaponRaplace[source])  
            destroyElement(elementWeaponRaplace[source])  
            elementWeaponRaplace[source] = false  
           end  
           if weapon1 == "DMR" then  
           elementWeaponRaplace[source] = createObject(1671,x,y,z)  
           elseif weapon1 == "SVD Camo" then  
           elementWeaponRaplace[source] = createObject(1755,x,y,z)  
           end  
           if elementBackpack[source] then  
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180)  
           else  
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180)  
           end  
          elseif previousWeaponID == weapID1 then  
           detachElementFromBone(elementWeaponRaplace[source])  
           destroyElement(elementWeaponRaplace[source])  
           elementWeaponRaplace[source] = false  
          end  
 end  
 addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponReplace ) 
  
  
 function removeBackWeaponOnDrop() 
 if elementWeaponRaplace[source] then  
           detachElementFromBone(elementWeaponRaplace[source])  
           destroyElement(elementWeaponRaplace[source])           
           elementWeaponRaplace[source] = false  
          end 
           
           
           
           
function removeAttachedOnDeath() 
if elementWeaponRaplace[source] then  
            detachElementFromBone(elementWeaponRaplace[source])  
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false  
           end 
            
            
            
function backpackRemoveQuit() 
if  elementWeaponRaplace[source] then  
            detachElementFromBone(elementWeaponRaplace[source])  
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false  
           end 
            
            
            
 local weapon = getElementData(source,"currentweapon_1")  
  if weapon then  
    local ammoData,weapID = getWeaponAmmoType (weapon)  
    giveWeapon(source,weapID,getElementData(source,ammoData), false )  
  end 
   
   
   
   
   
   
  function weaponSwitchBack ( previousWeaponID, currentWeaponID )  
 local weapon1 = getElementData(source,"currentweapon_1")  
 if not weapon1 then return end  
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1)  
 local x,y,z = getElementPosition(source)  
 local rx,ry,rz = getElementRotation(source)  
          if previousWeaponID == weapID1 then  
           if elementWeaponBack[source] then  
            detachElementFromBone(elementWeaponBack[source])  
            destroyElement(elementWeaponBack[source])  
            elementWeaponBack[source] = false  
           end  
           if weapon1 == "DMR" then  
           elementWeaponBack[source] = createObject(1671,x,y,z)  
           setObjectScale(elementWeaponBack[source],0.875)  
           elseif weapon1 == "SVD" then  
           elementWeaponBack[source] = createObject(1755,x,y,z)  
           setObjectScale(elementWeaponBack[source],0.875)  
           else  
           elementWeaponBack[source] = createObject(getWeaponObjectID(weapID1),x,y,z)  
           setObjectScale(elementWeaponBack[source],0.875)  
           end  
           if elementBackpack[source] then  
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.31,-0.1,0,270,-90)  
           else  
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.11,-0.1,0,270,10)  
           end  
          elseif currentWeaponID == weapID1 then  
           detachElementFromBone(elementWeaponBack[source])  
           destroyElement(elementWeaponBack[source])  
           elementWeaponBack[source] = false  
          end  
 end 
  

ERROR: Loading script failed: dayz/final.lua:106:'end' expected (to close 'function' at line 53) near ''

Share this post


Link to post

try this it means there is one missing end.

elementWeaponRaplace = {} 
 function weaponReplace ( previousWeaponID, currentWeaponID ) 
 --local source = getRootElement() 
 local weapon1 = getElementData(source,"currentweapon_1") 
 if not weapon1 then return end 
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1) 
 local x,y,z = getElementPosition(source) 
 local rx,ry,rz = getElementRotation(source) 
          if currentWeaponID == weapID1 then 
           if elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source]) 
            elementWeaponRaplace[source] = false 
           end 
           if weapon1 == "DMR" then 
           elementWeaponRaplace[source] = createObject(1671,x,y,z) 
           elseif weapon1 == "SVD Camo" then 
           elementWeaponRaplace[source] = createObject(1755,x,y,z) 
           end 
           if elementBackpack[source] then 
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180) 
           else 
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180) 
           end 
          elseif previousWeaponID == weapID1 then 
           detachElementFromBone(elementWeaponRaplace[source]) 
           destroyElement(elementWeaponRaplace[source]) 
           elementWeaponRaplace[source] = false 
          end 
 end 
 addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponReplace ) 
  
  
 function removeBackWeaponOnDrop() 
 if elementWeaponRaplace[source] then 
           detachElementFromBone(elementWeaponRaplace[source]) 
           destroyElement(elementWeaponRaplace[source])           
           elementWeaponRaplace[source] = false 
          end 
          
          
          
function removeAttachedOnDeath() 
if elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false 
           end 
            
            
            
function backpackRemoveQuit() 
if  elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false 
           end 
            
            
            
 local weapon = getElementData(source,"currentweapon_1") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  end 
  
  
  
  
  
  
  function weaponSwitchBack ( previousWeaponID, currentWeaponID ) 
 local weapon1 = getElementData(source,"currentweapon_1") 
 if not weapon1 then return end 
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1) 
 local x,y,z = getElementPosition(source) 
 local rx,ry,rz = getElementRotation(source) 
          if previousWeaponID == weapID1 then 
           if elementWeaponBack[source] then 
            detachElementFromBone(elementWeaponBack[source]) 
            destroyElement(elementWeaponBack[source]) 
            elementWeaponBack[source] = false 
           end 
           if weapon1 == "DMR" then 
           elementWeaponBack[source] = createObject(1671,x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           elseif weapon1 == "SVD" then 
           elementWeaponBack[source] = createObject(1755,x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           else 
           elementWeaponBack[source] = createObject(getWeaponObjectID(weapID1),x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           end 
           if elementBackpack[source] then 
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.31,-0.1,0,270,-90) 
           else 
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.11,-0.1,0,270,10) 
           end 
          elseif currentWeaponID == weapID1 then 
           detachElementFromBone(elementWeaponBack[source]) 
           destroyElement(elementWeaponBack[source]) 
           elementWeaponBack[source] = false 
          end 
 end 
end 

Share this post


Link to post
elementWeaponRaplace = {} 
 function weaponReplace ( previousWeaponID, currentWeaponID ) 
 --local source = getRootElement() 
 local weapon1 = getElementData(source,"currentweapon_1") 
 if not weapon1 then return end 
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1) 
 local x,y,z = getElementPosition(source) 
 local rx,ry,rz = getElementRotation(source) 
          if currentWeaponID == weapID1 then 
           if elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source]) 
            elementWeaponRaplace[source] = false 
           end 
           if weapon1 == "DMR" then 
           elementWeaponRaplace[source] = createObject(1671,x,y,z) 
           elseif weapon1 == "SVD Camo" then 
           elementWeaponRaplace[source] = createObject(1755,x,y,z) 
           end 
           if elementBackpack[source] then 
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180) 
           else 
            attachElementToBone(elementWeaponRaplace[source],source,12,0,0,0,180,90,180) 
           end 
          elseif previousWeaponID == weapID1 then 
           detachElementFromBone(elementWeaponRaplace[source]) 
           destroyElement(elementWeaponRaplace[source]) 
           elementWeaponRaplace[source] = false 
          end 
 end 
 addEventHandler ( "onPlayerWeaponSwitch", getRootElement(), weaponReplace ) 
  
  
 function removeBackWeaponOnDrop() 
 if elementWeaponRaplace[source] then 
           detachElementFromBone(elementWeaponRaplace[source]) 
           destroyElement(elementWeaponRaplace[source])           
           elementWeaponRaplace[source] = false 
          end 
          
          
          
function removeAttachedOnDeath() 
if elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false 
           end 
            
            
            
function backpackRemoveQuit() 
if  elementWeaponRaplace[source] then 
            detachElementFromBone(elementWeaponRaplace[source]) 
            destroyElement(elementWeaponRaplace[source])           
            elementWeaponRaplace[source] = false 
           end 
            
            
            
 local weapon = getElementData(source,"currentweapon_1") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  end 
  
  
  
  
  
  
  function weaponSwitchBack ( previousWeaponID, currentWeaponID ) 
 local weapon1 = getElementData(source,"currentweapon_1") 
 if not weapon1 then return end 
 local ammoData1,weapID1 = getWeaponAmmoType(weapon1) 
 local x,y,z = getElementPosition(source) 
 local rx,ry,rz = getElementRotation(source) 
          if previousWeaponID == weapID1 then 
           if elementWeaponBack[source] then 
            detachElementFromBone(elementWeaponBack[source]) 
            destroyElement(elementWeaponBack[source]) 
            elementWeaponBack[source] = false 
           end 
           if weapon1 == "DMR" then 
           elementWeaponBack[source] = createObject(1671,x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           elseif weapon1 == "SVD" then 
           elementWeaponBack[source] = createObject(1755,x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           else 
           elementWeaponBack[source] = createObject(getWeaponObjectID(weapID1),x,y,z) 
           setObjectScale(elementWeaponBack[source],0.875) 
           end 
           if elementBackpack[source] then 
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.31,-0.1,0,270,-90) 
           else 
            attachElementToBone(elementWeaponBack[source],source,3,0.19,-0.11,-0.1,0,270,10) 
           end 
          elseif currentWeaponID == weapID1 then 
           detachElementFromBone(elementWeaponBack[source]) 
           destroyElement(elementWeaponBack[source]) 
           elementWeaponBack[source] = false 
          end 
 end 
end 

ERROR: Loading script failed: dayz/final.lua:105:'end' expected (to close 'function' at line 43) near '' :|:|

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.