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

Wysłany: 2015-01-07, 20:54


michal982010







Wiek: 30
Na forum: 4586 dni
Posty: 69

Piwa: 1

Respekt: 50

Witam, wkleje tu urywek kodu, chcia?bym ?eby ped m?g? zosta? zabity , lecz strzelam a on nie ginie, brakuje tu czego? mo?e ?, je?li trzeba b?dzie da? ca?y kod to piszcie ;)
Za pomoc daje :piwo:

function createSniperPed(x, y, z)
    local ped = createPed(285, x, y, z)
    setTimer(
        function()
            if isElement(ped) then
                giveWeapon(ped, 34, 10000, true)
                setElementHealth (test, 1000)
                setPedWeaponSlot(ped, 6)
                setElementData(ped, "type", "ped.sniper.npc")
                setElementFrozen(ped, true)
            end
        end
    , 5000, 1)
    return ped
end




*skrypty wstawiamy w [lua] ~ Shuffle

Ostatnio zmieniony przez MeeShuffle 2015-01-07, 21:03, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-07, 21:25


Piorun







Wiek: 33
Na forum: 6853 dni
Posty: 1837
Nick w MP: Piorun

Piwa: 516

Respekt: 480,7
Respekt: 480,7

Nada?e? mu 1000 HP to jak si? spodziewasz go zabi? :shock: ?

Podpis
Możesz mnie znaleźć na: Facebook
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-07, 21:43


michal982010







Wiek: 30
Na forum: 4586 dni
Posty: 69

Piwa: 1

Respekt: 50

Czyli zmniejszyc hp czy ca?kowicie usun?? linijke setElementHealth ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-07, 22:27


Fanciak

BOT






Wiek: 26
Na forum: 4587 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

michal982010, najlepiej ca?kowicie,

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-08, 16:33


michal982010







Wiek: 30
Na forum: 4586 dni
Posty: 69

Piwa: 1

Respekt: 50

Wie kto? mo?e dlaczego ich si? nie da zabi? anie nie otrzymujemy od nich obra?e? na gamemod Dayz ?


Serwer
addEvent("sniperTakeDecision", true)
addCommandHandler("sniper",
    function(thePlayer, command)
        local x, y, z = getElementPosition(thePlayer)
        local int = getElementInterior(thePlayer)
        local ped = createSniperPed(x, y, z)
        setElementInterior(ped, int)
    end
)

function createSniperPed(x, y, z)
    local ped = createPed(285, x, y, z)
    setTimer(
        function()
            if isElement(ped) then
                giveWeapon(ped, 34, 10000, true)
                setPedWeaponSlot(ped, 6)
                setElementData(ped, "type", "ped.sniper.npc")
                setElementFrozen(ped, true)
            end
        end
    , 5000, 1)
    return ped
end
addEventHandler("sniperTakeDecision", getRootElement(),
    function(sniperPedID, aimPlayer)
        setElementData(sniperPedID, "target", aimPlayer)
        triggerClientEvent("sniperTakeDecisionClient", getRootElement(), sniperPedID, aimPlayer)
    end
)


client
function isMyPingTheLowest()
    local players = getElementsByType("player")
    local yes = true
    for i, player in ipairs(players) do
        if getPlayerPing(getLocalPlayer()) > getPlayerPing(player) then
            yes = false
        end
    end
    if yes == true then
        return true
    else
        return false
    end
end
function findRotation(x1,y1,x2,y2)
    local t = -math.deg(math.atan2(x2-x1,y2-y1))
    if t < 0 then t = t + 360 end
    return t
end
addEventHandler("onClientPedDamage", getRootElement(),
    function(attacker)
        if getElementData(source, "type") == "ped.sniper.npc" and getElementData(attacker, "type") == "ped.sniper.npc" then
            cancelEvent()
        end
    end
)
setTimer(
    function()
        if isMyPingTheLowest() then
            for i, peds in ipairs(getElementsByType("ped")) do
                if getElementData(peds, "type") == "ped.sniper.npc" then
                    local x, y, z = getElementPosition(peds)
                    local lowest = nil
                    local player = nil
                    for i, players in ipairs(getElementsByType("player")) do
                        local px, py, pz = getElementPosition(players)
                        if getDistanceBetweenPoints3D(x, y, z, px, py, pz) < 100 then
                            if lowest == nil then
                                lowest = getDistanceBetweenPoints3D(x, y, z, px, py, pz)
                                player = players
                            else
                                if getDistanceBetweenPoints3D(x, y, z, px, py, pz) < lowest then
                                    lowest = getDistanceBetweenPoints3D(x, y, z, px, py, pz)
                                    player = players
                                end
                            end
                        end
                    end
                    if isElement(player) then
                        triggerServerEvent("sniperTakeDecision", getRootElement(), peds, player)
                    end
                end
            end
        end
    end
, 1500, 0)
addEvent("sniperTakeDecisionClient", true)
addEventHandler("sniperTakeDecisionClient", getRootElement(),
    function(sniperPedID, aimPlayer)
        local x, y, z = getElementPosition(sniperPedID)
        local px, py, pz = getElementPosition(aimPlayer)
        setPedAimTarget(sniperPedID, px, py, pz)
        local rotZ = findRotation(x, y, px, py)
        setPedRotation(sniperPedID, rotZ)
        setPedControlState(sniperPedID, "aim_weapon", true)
        setPedControlState(sniperPedID, "fire", true)
        setTimer(
            function()
                if isElement(sniperPedID) then
                    setPedControlState(sniperPedID, "fire", false)
                    setPedControlState(sniperPedID, "aim_weapon", false)
                end
            end
        , 500, 1)
    end
) 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-01-09, 09:25


markob0







Wiek: 28
Na forum: 4389 dni
Posty: 151
Nick w MP: Markob

Piwa: 939

Respekt: 98,2

Masz linijk? z
setElementHealth (test, 1000)
. Zmie? to na
setElementHealth (test, 100)
, albo
setElementHealth (test, 50)
bo jak napiszesz
setElementHealth (test, 0)
, to ca?kiem ci si? zbuguje.

Podpis
Postaw piwo autorowi tego posta
 

 
Tagi: ped
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Ped 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