Escobar
Wiek: 26 Na forum: 2020 dni Posty: 5
Nick w MP: Escobar
Siemka posiadam skrypt torby R1 problem polega na tym ze po wyci?gnieciu jej z karetki torba zostaje w miejscu zamiast przyklei? si? do gracza w skrypcie jest bone_attach ale co? jest nie tak a ?e skrypt nie jest m?j nie rozumiem co. dodam jeszcze ?e w swoj? przygod? z lua dopiero zaczynam i je?li mo?na prosi? bym o do?? ?opatologiczne wyja?nienie problemu
serwer
local tbl ={}
-- [ 1878 ]= "torbaz" ,
-- [ 1877 ]= "torbao" ,
local isPR =(
function( plr )
if ( getElementData ( plr , "PR:ranga" ) and ( getElementData ( plr , "frakcja" )== "PR" ) and getElementData ( plr , "PR:sluzba" )) or ( getElementData ( plr , "PSP:ranga" ) and getElementData ( plr , "PSP:sluzba" )) or ( getElementData ( plr , "OSP:ranga" ) and getElementData ( plr , "OSP:sluzba" )) then
return true
end
return false
end
)
addEvent ( "ev" , true )
addEventHandler ( "ev" , resourceRoot ,
function( ev , arg1 )
if ( ev == "wez_torbe" ) then
local ma_torbe = false
if ( #tbl==0) then
ma_torbe = false
else
for i , v in ipairs ( tbl ) do
if ( v . plr == client ) then
ma_torbe = v
end
end
end
if ma_torbe then
if not ma_torbe . polozona then
if ma_torbe . torba and isElement ( ma_torbe . torba ) then
destroyElement ( ma_torbe . torba )
end
for i , v in ipairs ( tbl ) do
if ( v . plr == client ) then
table . remove ( tbl , i )
break
end
end
return
else
exports [ "es-komunikaty" ]: komunikat ( "Najpierw podnie? torb? z ziemi." , client )
return
end
end
local x , y , z = getElementPosition ( client )
local torba = createObject ( 1878 , x , y , z + 3 )
exports . bone_attach : attachElementToBone ( torba , client , 11 , 0 , 0 , 0.3 , 180 , 0 , 0 )
table . insert ( tbl ,{ plr = client , torba = torba })
elseif ( ev == "podnies_torbe" ) then
local torba = arg1
local z_t = nil
for i , v in ipairs ( tbl ) do
if ( v . plr == client ) then
if ( v . torba == torba ) then
z_t = v
end
end
end
if not z_t then
exports [ "es-komunikaty" ]: komunikat ( "To nie Twoja torba." , client )
return
end
if z_t . kladzenie then
return
end
setPedAnimation ( client , "BOMBER" , "BOM_Plant" ,- 1 , false , true , true , false )
z_t . kladzenie = true
setTimer (function( client )
if z_t . torba and isElement ( z_t . torba ) then
setElementModel ( z_t . torba , 1878 )
setTimer (function( client )
if z_t . torba and isElement ( z_t . torba ) then
exports . bone_attach : attachElementToBone ( z_t . torba , client , 11 , 0 , 0 , 0.3 , 180 , 0 , 0 )
z_t . kladzenie = false
z_t . polozona = false
end
end , 500 , 1 , client )
end
end , 500 , 1 , client )
end
end
)
local podnies_poloz =(
function( plr )
if not getElementData ( plr , "dbid" ) then
exports [ "es-komunikaty" ]: komunikat ( "Najpierw si? zaloguj." , plr )
return
end
if not isPR ( plr ) then
return
end
if isPedInVehicle ( plr ) then
exports [ "es-komunikaty" ]: komunikat ( "Najpierw wyjd? z pojazdu." , plr )
return
end
local z_t = nil
for i , v in ipairs ( tbl ) do
if ( v . plr == plr ) then
z_t = v
break
end
end
if not z_t then
exports [ "es-komunikaty" ]: komunikat ( "Nie posiadasz torby." , plr )
return
end
if z_t . kladzenie then
return
end
if z_t . torba and isElement ( z_t . torba ) then
if not z_t . polozona then
local x , y , z = getElementPosition ( plr )
local _ , _ , rz = getElementRotation ( plr )
local rrz = math . rad ( rz + 180 )
local px = x - ( 0.6 * math . sin (- rrz ))
local py = y - ( 0.6 * math . cos (- rrz ))
setPedAnimation ( plr , "BOMBER" , "BOM_Plant" ,- 1 , false , true , true , false )
z_t . kladzenie = true
setTimer (function()
if z_t . torba and isElement ( z_t . torba ) then
exports . bone_attach : detachElementFromBone ( z_t . torba )
setElementPosition ( z_t . torba , px , py , z - 0.8 )
setElementRotation ( z_t . torba , 0 , 0 , rz + 180 )
setTimer (function()
if z_t . torba and isElement ( z_t . torba ) then
setElementModel ( z_t . torba , 1877 )
z_t . polozona = true
z_t . kladzenie = false
end
end , 500 , 1 )
end
end , 500 , 1 )
else
triggerClientEvent ( plr , "evc" , resourceRoot , "podnies_torbe" )
end
end
end
)
addCommandHandler ( "podniesr1" , podnies_poloz )
addCommandHandler ( "polozr1" , podnies_poloz )
local pum =(
function()
local z_t = nil
for i , v in ipairs ( tbl ) do
if ( v . plr == source ) then
z_t = v
break
end
end
if not z_t then
return
end
if z_t . torba and isElement ( z_t . torba ) then
destroyElement ( z_t . torba )
end
for i , v in ipairs ( tbl ) do
if ( v . plr == source ) then
table . remove ( tbl , i )
break
end
end
end
)
addEventHandler ( "onPlayerWasted" , root , pum )
addEventHandler ( "onPlayerQuit" , root , pum )
-- local qwe =(
-- function( plr )
-- createObject ( 1878 ,- 2439.57 , 716.44 , 35.17 - 0.8 )
-- end
--)
-- qwe ()
client
function getPositionFromElementOffset ( element , offX , offY , offZ )
local m = getElementMatrix ( element ) -- Get the matrix
local x = offX * m [ 1 ][ 1 ] + offY * m [ 2 ][ 1 ] + offZ * m [ 3 ][ 1 ] + m [ 4 ][ 1 ] -- Apply transform
local y = offX * m [ 1 ][ 2 ] + offY * m [ 2 ][ 2 ] + offZ * m [ 3 ][ 2 ] + m [ 4 ][ 2 ]
local z = offX * m [ 1 ][ 3 ] + offY * m [ 2 ][ 3 ] + offZ * m [ 3 ][ 3 ] + m [ 4 ][ 3 ]
return x , y , z -- Return the transformed point
end
local isPR =(
function( plr )
if ( getElementData ( plr , "PR:ranga" ) and ( getElementData ( plr , "frakcja" )== "PR" ) and getElementData ( plr , "PR:sluzba" )) or ( getElementData ( plr , "PSP:ranga" ) and getElementData ( plr , "PSP:sluzba" )) or ( getElementData ( plr , "OSP:ranga" ) and getElementData ( plr , "OSP:sluzba" )) then
return true
end
return false
end
)
--[[
addEventHandler ( "onClientRender" , root ,
function()
local x , y , z = getElementPosition ( localPlayer )
z = z - 0.5
local offx , offy , offz = getPositionFromElementOffset ( localPlayer , 0 , 0.8 ,- 1 )
if isLineOfSightClear ( x , y , z , offx , offy , offz , false , false , false , true , false ) then
dxDrawLine3D ( x , y , z , offx , offy , offz , tocolor ( 255 , 0 , 0 , 255 ), 1 )
else
dxDrawLine3D ( x , y , z , offx , offy , offz , tocolor ( 0 , 255 , 0 , 255 ), 1 )
end
end
)]]--
--[[
addCommandHandler ( "r1" ,
function()
if not isPR ( localPlayer ) then
return
end
local x , y , z = getElementPosition ( localPlayer )
local offx , offy , offz = getPositionFromElementOffset ( localPlayer , 0 , 1.1 , 0 )
if isLineOfSightClear ( x , y , z , offx , offy , offz , false , true , false , false , false ) then
-- exports [ "es-komunikaty" ]: komunikat ( "Sta? twarz? do pojazdu lub podejd? bli?ej." )
return
end
local hit , _ , _ , _ , veh = processLineOfSight ( x , y , z , offx , offy , offz , false , true , false , false , false )
if not hit then
return
end
if ( getElementType ( veh )~= "vehicle" ) then
return
end
if veh and isElement ( veh ) then
if ( getElementModel ( veh )== 407 ) or ( getElementModel ( veh )== 416 ) then
triggerServerEvent ( "ev" , resourceRoot , "wez_torbe" )
end
end
end
)]]--
wezTorbe =(
function()
triggerServerEvent ( "ev" , resourceRoot , "wez_torbe" )
end
)
addEvent ( "evc" , true )
addEventHandler ( "evc" , resourceRoot ,
function( ev , arg1 )
if ( ev == "podnies_torbe" ) then
local x , y , z = getElementPosition ( localPlayer )
z = z - 0.5
local offx , offy , offz = getPositionFromElementOffset ( localPlayer , 0 , 0.8 ,- 1 )
if isLineOfSightClear ( x , y , z , offx , offy , offz , false , false , false , true , false ) then
exports [ "es-komunikaty" ]: komunikat ( "Sta? bli?ej skierowany(a) twarz? do torby." )
return
end
local hit , _ , _ , _ , torba = processLineOfSight ( x , y , z , offx , offy , offz , false , false , false , true , false )
if not hit then
return
end
if ( getElementType ( torba )~= "object" ) then
return
end
if torba and isElement ( torba ) then
if ( getElementModel ( torba )== 1877 ) or ( getElementModel ( torba )== 1878 ) then
triggerServerEvent ( "ev" , resourceRoot , "podnies_torbe" , torba )
end
end
end
end
)
--[[
addCommandHandler ( "qwe" ,
function()
local x , y , z = getElementPosition ( localPlayer )
local offx , offy , offz = getPositionFromElementOffset ( localPlayer , 0 , 1.1 , 0 )
--if isLineOfSightClear ( x , y , z , offx , offy , offz , false , true , false , false , false ) then
-- -- exports [ "es-komunikaty" ]: komunikat ( "Sta? twarz? do pojazdu lub podejd? bli?ej." )
-- return
-- end
local hit , hx , hy , hz , veh , normalX , normalY , normalZ , _ , _ , _ , worldModelID , worldModelPositionX , worldModelPositionY , worldModelPositionZ = processLineOfSight ( x , y , z , offx , offy , offz , false , true , false , false , false )
if not hit then
return
end
outputChatBox ( string . format ( "NORMALE: %.2f,%.2f,%.2f" , normalX , normalY , normalZ ))
outputChatBox ( "WORLDMODELID: " .. tostring ( worldModelID ))
outputChatBox ( string . format ( "HIT: %.2f,%.2f,%.2f" , hx , hy , hz ))
end
)
addCommandHandler ( "e" ,
function()
setElementPosition ( localPlayer ,- 2439.37 - 2.52 , 712.94 + 1.35 , 35.28 )
end
)]]--
--- 2439.37 , 712.94 , 35.28
--- 2441.89 , 711.59 , 35.01
--- 2.52 , 1.35 , 35.01
meta
< meta >
< script src = "r1432216.lua" type = "server" />
< script src = "r1_c342321.lua" type = "client" cache = "false" />
< export function= "wezTorbe" type = "client" />
</ meta >