Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-01-05, 15:45


VVrongVVay







Wiek: 37
Na forum: 4486 dni
Posty: 47
Nick w MP: VVrongVVay

Piwa: 1

Respekt: 50

Ostrzeżeń: 40%
Co w tym kodzie jest nie tak?
Ca?y czas w debugu wyskakuj? mi b??dy z linijk? 76, 78 i 117..


Kod:



attached_ped = {}
attached_bone = {}
attached_x = {}
attached_y = {}
attached_z = {}
attached_rx = {}
attached_ry = {}
attached_rz = {}

function attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz)
if not (isElement(element) and isElement(ped)) then return false end
if getElementType(ped) ~= "ped" and getElementType(ped) ~= "player" then return false end
bone = tonumber(bone)
if not bone or bone < 1 or bone > 20 then return false end
x,y,z,rx,ry,rz = tonumber(x) or 0,tonumber(y) or 0,tonumber(z) or 0,tonumber(rx) or 0,tonumber(ry) or 0,tonumber(rz) or 0
attached_ped[element] = ped
attached_bone[element] = bone
attached_x[element] = x
attached_y[element] = y
attached_z[element] = z
attached_rx[element] = rx
attached_ry[element] = ry
attached_rz[element] = rz
if setElementCollisionsEnabled then
setElementCollisionsEnabled(element,false)
end
if script_serverside then
triggerClientEvent("boneAttach_attach",root,element,ped,bone,x,y,z,rx,ry,rz)
end
return true
end

function detachElementFromBone(element)
if not element then return false end
if not attached_ped[element] then return false end
clearAttachmentData(element)
if setElementCollisionsEnabled then
setElementCollisionsEnabled(element,true)
end
if script_serverside then
triggerClientEvent("boneAttach_detach",root,element)
end
return true
end

function isElementAttachedToBone(element)
if not element then return false end
return isElement(attached_ped[element])
end

function getElementBoneAttachmentDetails(element)
if not isElementAttachedToBone(element) then return false end
return attached_ped[element],attached_bone[element],
attached_x[element],attached_y[element],attached_z[element],
attached_rx[element],attached_ry[element],attached_rz[element]
end

function setElementBonePositionOffset(element,x,y,z)
local ped,bone,ox,oy,oz,rx,ry,rz = getElementBoneAttachmentDetails(element)
if not ped then return false end
return attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz)
end

function setElementBoneRotationOffset(element,rx,ry,rz)
local ped,bone,x,y,z,ox,oy,oz = getElementBoneAttachmentDetails(element)
if not ped then return false end
return attachElementToBone(element,ped,bone,x,y,z,rx,ry,rz)
end

if not script_serverside then
function getBonePositionAndRotation(ped,bone)
bone = tonumber(bone)
if not bone or bone < 1 or bone > 20 then return false end
if not isElement(ped) then return false end
if getElementType(ped) ~= "player" and getElementType(ped) ~= "ped" then return false end
if not isElementStreamedIn(ped) then return false end
local x,y,z = getPedBonePosition(ped,bone_0[bone])
local rx,ry,rz = getEulerAnglesFromMatrix(getBoneMatrix(ped,bone))
return x,y,z,rx,ry,rz
end
end

------------------------------------

function clearAttachmentData(element)
attached_ped[element] = nil
attached_bone[element] = nil
attached_x[element] = nil
attached_y[element] = nil
attached_z[element] = nil
attached_rx[element] = nil
attached_ry[element] = nil
attached_rz[element] = nil
end

function forgetDestroyedElements()
if not attached_ped[source] then return end
clearAttachmentData(source)
end
addEventHandler(script_serverside and "onElementDestroy" or "onClientElementDestroy",root,forgetDestroyedElements)

function forgetNonExistingPeds()
local checkedcount = 0
while true do
for element,ped in pairs(attached_ped) do
if not isElement(ped) then clearAttachmentData(element) end
checkedcount = checkedcount+1
if checkedcount >= 1000 then
coroutine.yield()
checkedcount = 0
end
end
coroutine.yield()
end
end
clearing_nonexisting_peds = coroutine.create(forgetNonExistingPeds)
setTimer(function() coroutine.resume(clearing_nonexisting_peds) end,1000,0)


Komentarz NotPaladyn dodany 2020-01-08, 14:39 Przywrócono stan sprzed usunięcia treści po otrzymaniu pomocy
Ostatnio zmieniony przez NotPaladyn 2020-01-08, 14:39, w całości zmieniany 2 razy  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-05, 15:52


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Wklej oddzielnie te linijki. B?dzie ?atwiej. No i poka? tre???tych b??d?w...

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-06, 01:36


VVrongVVay







Wiek: 37
Na forum: 4486 dni
Posty: 47
Nick w MP: VVrongVVay

Piwa: 1

Respekt: 50

Ostrzeżeń: 40%
"Wilq" napisał/a:

Wklej oddzielnie te linijki. B?dzie ?atwiej. No i poka? tre???tych b??d?w...


https://i.imgur.com/LAxwCLb.png

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-01-06, 22:59


Machin







Wiek: 27
Na forum: 3568 dni
Posty: 8
Nick w MP: Machin

Piwa: 1

Respekt: 70

Zaktualizuj sobie Bone attachments do 1.3 bo u?ywasz 1.2 z 2k11 roku xDDD

Postaw piwo autorowi tego posta
 

 
Tagi: zamknąć
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zamknąć Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku