DaVeCS
Mapper
Wiek: 31 Na forum: 3386 dni Posty: 193
Nick w MP: DaVe
Piwa : 59
Witam, m?g?by mi kto? pom?c? mam skrypt na kolczatk?, wszystko ?adnie dzia?a tylko nie idzie jej usuwa?.
Skrypt po stronie Client:
--[[
Author : AteX < atexprogramming @ gmail . com >
]]--
local ox , oy
addEvent ( "znajdzmiejsce" , true )
addEventHandler ( "znajdzmiejsce" , root ,function()
local veh = getPedOccupiedVehicle ( localPlayer )
local x , y , z = getVehicleComponentPosition ( veh , "bump_rear_dummy" , "world" )
local rx , ry , rz = getVehicleComponentRotation ( veh , "bump_rear_dummy" , "world" )
triggerServerEvent ( "postaw" , localPlayer , x , y , z , rx , ry , rz )
end )
function sprawdzaj ()
local veh = getPedOccupiedVehicle ( localPlayer )
if veh then
local x1 , y1 , _ = getVehicleComponentPosition ( veh , "wheel_lf_dummy" , "world" )
local x2 , y2 , _ = getVehicleComponentPosition ( veh , "wheel_lb_dummy" , "world" )
local x3 , y3 , _ = getVehicleComponentPosition ( veh , "wheel_rf_dummy" , "world" )
local x4 , y4 , _ = getVehicleComponentPosition ( veh , "wheel_rb_dummy" , "world" )
local s1 , s2 , s3 , s4 = getVehicleWheelStates ( veh )
local distance1 = getDistanceBetweenPoints2D ( x1 , y1 , ox , oy )
local distance2 = getDistanceBetweenPoints2D ( x2 , y2 , ox , oy )
local distance3 = getDistanceBetweenPoints2D ( x3 , y3 , ox , oy )
local distance4 = getDistanceBetweenPoints2D ( x4 , y4 , ox , oy )
if distance1 < 2 then
if s1 ~= 1 then
triggerServerEvent ( "przebijopone" , localPlayer , 1 )
end
end
if distance2 < 2 then
if s2 ~= 1 then
triggerServerEvent ( "przebijopone" , localPlayer , 2 )
end
end
if distance3 < 2 then
if s3 ~= 1 then
triggerServerEvent ( "przebijopone" , localPlayer , 3 )
end
end
if distance4 < 2 then
if s4 ~= 1 then
triggerServerEvent ( "przebijopone" , localPlayer , 4 )
end
end
end
end
addEvent ( "sprawdzajopony" , true )
addEventHandler ( "sprawdzajopony" , root ,function( x , y )
ox , oy = x , y
addEventHandler ( "onClientRender" , root , sprawdzaj )
end )
addEvent ( "przestansprawdzacopony" , true )
addEventHandler ( "przestansprawdzacopony" , root ,function()
removeEventHandler ( "onClientRender" , root , sprawdzaj )
end )
Skrypt po stronie Server:
--[[
Author : AteX < atexprogramming @ gmail . com >
]]--
local kolczatki = {}
local cuboidy = {}
local pojazdy = {[ 598 ]= true ,[ 411 ]= true ,[ 597 ]= true ,[ 451 ]= true , [ 560 ]= true ,}
local odporny = {}
addEventHandler ( "onPlayerLogin" , root ,function( prevAcc , currAcc , auto )
local accName = getAccountName ( currAcc )
if getElementData ( source , 'player:duty' ) and getElementData ( source , 'player:duty' )== 'SAPD' then
bindKey ( getAccountPlayer ( currAcc ), "x" , "down" , postawkolczatke )
bindKey ( getAccountPlayer ( currAcc ), "c" , "down" , usunkolczatke )
end
end )
function postawkolczatke ( plr , key , keyState )
local veh = getPedOccupiedVehicle ( plr )
if pojazdy [ getElementModel ( veh )] then
setElementData ( plr , "odporny" , true )
triggerClientEvent ( plr , "znajdzmiejsce" , plr )
if odporny [ plr ] then
killTimer ( odporny [ plr ])
end
odporny [ plr ] = setTimer (function()
setElementData ( plr , "odporny" , false )
odporny [ plr ] = nil
end , 1000 , 1 )
end
end
addEvent ( "postaw" , true )
addEventHandler ( "postaw" , root ,function( x , y , z , rx , ry , rz )
if kolczatki [ source ] then
destroyElement ( kolczatki [ source ])
kolczatki [ source ] = nil
destroyElement ( cuboidy [ source ])
cuboidy [ source ] = nil
end
local kolczatka = createObject ( 2899 , x , y , z - 0.3 , rx , ry , rz + 90 ) -- 2899 , 2892
local cuboid = createColSphere ( x , y , z - 0.3 , 2.5 )
cuboidy [ source ] = cuboid
kolczatki [ source ] = kolczatka
end )
function usunkolczatke ( plr , key , keyState )
if source then
plr = source
end
if kolczatki [ plr ] then
destroyElement ( kolczatki [ plr ])
kolczatki [ plr ] = nil
destroyElement ( cuboidy [ plr ])
cuboidy [ plr ] = nil
if odporny [ plr ] then
killTimer ( odporny [ plr ])
odporny [ plr ] = nil
end
end
end
addEventHandler ( "onPlayerQuit" , root , usunkolczatke )
addEventHandler ( "onColShapeHit" , resourceRoot ,function( el , md )
if getElementType ( el ) ~= "player" or not md then return end
if getElementData ( el , "odporny" ) then return end
local veh = getPedOccupiedVehicle ( el )
if veh then
local x , y , z = getElementPosition ( source )
triggerClientEvent ( el , "sprawdzajopony" , el , x , y )
end
end )
addEventHandler ( "onColShapeLeave" , resourceRoot ,function( el , md )
if getElementType ( el ) ~= "player" or not md then return end
if getElementData ( el , "odporny" ) then return end
local veh = getPedOccupiedVehicle ( el )
if veh then
triggerClientEvent ( el , "przestansprawdzacopony" , el )
end
end )
addEvent ( "przebijopone" , true )
addEventHandler ( "przebijopone" , root ,function( opona )
local veh = getPedOccupiedVehicle ( source )
if opona == 1 then
setVehicleWheelStates ( veh , 1 )
elseif opona == 2 then
setVehicleWheelStates ( veh ,- 1 , 1 )
elseif opona == 3 then
setVehicleWheelStates ( veh ,- 1 ,- 1 , 1 )
elseif opona == 4 then
setVehicleWheelStates ( veh ,- 1 ,- 1 ,- 1 , 1 )
end
end )
Prosze o pomoc