Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. function weaponReplace(previousWeaponID,currentWeaponID)
  2. local weapon1 = getElementData(source,"currentweapon_1")
  3. local weapon2 = getElementData(source,"currentweapon_2")
  4. if not weapon1 and not weapon2 then return end
  5. local ammoData1,weapID1 = getWeaponAmmoType(weapon1)
  6. local ammoData2,weapID2 = getWeaponAmmoType(weapon2)
  7. local x,y,z = getElementPosition(source)
  8. local rx,ry,rz = getElementRotation(source)
  9. if elementWeaponRaplace[source] then
  10. destroyElement(elementWeaponRaplace[source])
  11. elementWeaponRaplace[source] = false
  12. end
  13. local model = changeWeapons[weapon1]
  14. if currentWeaponID == weapID2 then
  15. model = changeWeapons[weapon2]
  16. setElementData(source,"selectedWeapon",weapon2)
  17. elseif currentWeaponID == weapID1 then
  18. setElementData(source,"selectedWeapon",weapon1)
  19. end
  20. if currentWeaponID == weapID1 or currentWeaponID == weapID2 then
  21. if model then
  22. elementWeaponRaplace[source] = createObject(model,x,y,z +15)
  23. if attachPositions[weapon] then
  24. local tbl = attachPositions[weapon].attach
  25. attachElementToBone(elementWeaponRaplace[source],source,tbl[1],tbl[2],tbl[3],tbl[4],tbl[5],tbl[6],tbl[7])
  26. end
  27. end
  28. end
  29. end
  30. addEventHandler("onPlayerWeaponSwitch",getRootElement(),weaponReplace)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement