local torby = {}
addCommandHandler("torbar1",function(plr,cmd)
if torby[plr] then return end
if not getElementData(plr,"player:faction") then outputChatBox("Aby u?y? tej torby musisz by? aktywny w jakiejkolwiek frakcji",plr,255,0,0) return end
local x,y,z = getElementPosition(plr)
local torba = createObject(1550,x,y,z)
torby[plr] = torba
outputChatBox("**Wyci?gn??e? torb?r1 z karetki!",plr,255,0,0)
setElementCollisionsEnabled (torba, false)
exports["bone_attach"]:attachElementToBone(torba,plr,12,-0.05,0.1,0.28,0,170,0)
end)
function stworztorbe(plr)
if not plr then return end
local x,y,z = getElementPosition(plr)
local torba = createObject(1550,x,y,z)
torby[plr] = torba
setElementCollisionsEnabled (torba, false)
exports["bone_attach"]:attachElementToBone(torba,plr,12,0,-0.09,0.3,0,180,0)
setObjectScale(torba,5)
end
function usuntorbe(plr)
if not plr then return end
local torba = torby[plr]
if torba then
if isElement(torba) then
if exports["bone_attach"]:isElementAttachedToBone(torba) then exports["bone_attach"]:detachElementFromBone(torba) end
destroyElement(torba)
end
torby[plr] = nil
end
end
addEventHandler ( "onPlayerQuit", root, function()
local torba = torby[source]
if torba then
if isElement(torba) then
if exports["bone_attach"]:isElementAttachedToBone(torba) then exports["bone_attach"]:detachElementFromBone(torba) end
destroyElement(torba)
end
torby[source] = nil
end
end )
addCommandHandler("podniesr1",function(plr,cmd)
--if not getElementData(plr,"Dylek") then outputChatBox("*****W trakcie test?w :D",plr) return end
if not getElementData(plr,"player:faction") then outputChatBox("*****Brak uprawnien",plr,255,0,0) return end
if torby[plr] then
usuntorbe(plr)
outputChatBox("**Torb? odda?e? do karetki",plr,255,0,0)
return end
end)
addCommandHandler("postawr1",function(plr,cmd)
--if not getElementData(plr,"Dylek") then outputChatBox("*****W trakcie test?w :D",plr) return end
if not getElementData(plr,"player:faction") then outputChatBox("*****Brak uprawnien",plr,255,0,0) return end
local veh = getPedOccupiedVehicle(plr)
if veh then return end
local torba = torby[plr]
if not torba then outputChatBox("**Nie posiadasz torbyr1 przy sobie!",plr,255,0,0) return end
if not isElement(torba) then outputChatBox("**Nie posiadasz torby",plr,255,0,0) return end
if exports["bone_attach"]:isElementAttachedToBone(torba) then
exports["bone_attach"]:detachElementFromBone(torba)
setElementCollisionsEnabled (torba, false)
local x,y,z = getElementPosition(plr)
setElementPosition(torba,x,y,z-0.82)
local rz = getElementRotation(torba)
setElementRotation(torba,0,0,rz)
else
local x,y,z = getElementPosition(plr)
local x2,y2,z2 = getElementPosition(torba)
local distance = getDistanceBetweenPoints3D(x,y,z,x2,y2,z2)
if distance > 5 then outputChatBox("** Za daleki dystans nie siegniesz po torbe",plr,255,0,0) return end
exports["bone_attach"]:attachElementToBone(torba,plr,12,0,-0.09,0.3,0,180,0)
end
end)