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

Wysłany: 2017-09-16, 17:44


DaVeCS

Mapper






Wiek: 31
Na forum: 3386 dni
Posty: 193
Nick w MP: DaVe

Piwa: 59

Respekt: 70,5

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:

--[[
    AuthorAteX<atexprogramming@gmail.com>
]]--

local ox,oy

addEvent("znajdzmiejsce",true)
addEventHandler("znajdzmiejsce",root,function()
    local veh getPedOccupiedVehicle(localPlayer)
    local x,y,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:

--[[
    AuthorAteX<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[plrthen
            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[sourcethen
        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[plrthen
        destroyElement(kolczatki[plr])
        kolczatki[plr] = nil
        destroyElement(cuboidy[plr])
        cuboidy[plr] = nil
        if odporny[plrthen
            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,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

Postaw piwo autorowi tego posta
 

 
Tagi: kolczatka
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Kolczatka Odpowiedz do tematu

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