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

Wysłany: 2016-03-26, 09:27


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Witam. Tak jak w temacie jakich funkcji u?y? po kolei , wyt?umaczcie co mam zrobi?. Chce zrobi? skrypt na kolczatk? .

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 10:29


FaydenFX.







Wiek: 27
Na forum: 4197 dni
Posty: 246
Nick w MP: faydn

Piwa: 11

Respekt: 45,3


Więcej informacji znajdziesz w Wikipedii MTA:

getPlayerRotation


Więcej informacji znajdziesz w Wikipedii MTA:

getElementPosition


Więcej informacji znajdziesz w Wikipedii MTA:

getPlayerOccupiedVehicle


Więcej informacji znajdziesz w Wikipedii MTA:

getElementType


Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleRotation


Więcej informacji znajdziesz w Wikipedii MTA:

destroyElement


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 14:32


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Nie wiem jak zrobic ?eby kolczatka sie usuwa?a :D
Pomo?ecie ?

local thePlayer = getLocalPlayer()
local theKolczatka = {}
local kolec = {}
function kladz()
    if( isPedInVehicle( thePlayer ) ) then -- is the player in a car?
        if( isElement( theKolczatka[ thePlayer ] ) ) then 
            destroyElement( theKolczatka[ thePlayer ] )
            destroyElement( kolec[ thePlayer ] )
        end
        local theVehicle = getPedOccupiedVehicle( thePlayer )
        local rx, ry, rz = getElementRotation( theVehicle )
        local x, y, z = getElementPosition( theVehicle )
        local a = getPedRotation( thePlayer )
        x = x + math.sin( math.rad(a) ) * 4
        y = y - math.cos( math.rad(a) ) * 4
        rz = rz + 90
        local ziemiaZ = getGroundPosition( x, y, z )
        if( ziemiaZ ~= z ) then z = ziemiaZ + 0.2 end 
        theKolczatka[ thePlayer ] = createObject( 2899, x, y, z, 0, 0, rz )
        kolec[ thePlayer ] = createColRectangle( (x - 2.0), (y - 2.0), 4.0, 4.0 )
        setElementData( kolec[ thePlayer ], "kolce", "abc" )
        outputChatBox( "Rozԯ࠹ԥܠkolczatkꡢ, thePlayer, 255, 0, 0, true )
    else 
        outputChatBox( "Musisz by桷 aucie ࠥby poԯ࠹c kolczatkꡢ, thePlayer, 255, 0, 0, true ) 
    end
end

function kolabum( theElement, matchingDimension )
if( getElementType( theElement ) == "vehicle" and getElementData( source, "kolce" ) == "abc" ) then 
        setVehicleWheelStates( theElement, 2, 2, 2, 2 ) 
    end
end

addEventHandler( "onClientColShapeHit", getRootElement(), kolabum )
addCommandHandler("x", kladz)


Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-26, 18:40


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

Respekt: 1436,8
Respekt: 1436,8

spr?buj

function sprzatnij()
 if getElementData( kolec[thePlayer], "kolce", "abc" ) then
 destroyElement(theKolczatka[thePlayer] )
 outputChatBox("Usun??e? kolczatke")
 end
 end
 addCommandHandler("usun",sprzatnij)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-27, 17:28


sasik12







Wiek: 27
Na forum: 3904 dni
Posty: 182

Piwa: 7

Respekt: 60

Nic sie niedzieje :(

Podpis
Uczeń LUA . Mapper MTA.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-28, 11:58


#404







Wiek: 27
Na forum: 4912 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
Na co wy to robicie po stronie client'a? ?eby zaraz by?o, ?e widzi tylko jeden gracz? Powinno lata?, tylko tamt? ostatni? funkcj? i bindKey daj po stronie client'a, reszt? po stronie serwera.


kolczatki = {}

function UsunKol(kolczatka)
if not kolczatka then return end
    local att = getAttachedElements(kolczatka)
        if #att > 1 then
            for k,v in ipairs(att) do
            destroyElement(v)
            end
        elseif #att == 1 then
            destroyElement(kolczatka)
        end
end

function rozloz(gracz,cmd)
if not isPedInVehicle(gracz) then return end
    
    
    if isElement(kolczatki[gracz]) then
        usunKol(kolczatki[gracz])
        kolczatki[gracz] = false
    end
    
    local veh = getPedOccupiedVehicle(gracz)
    local rx, ry, rz = getElementRotation( veh )
    local x, y, z = getElementPosition( veh )
    local a = getPedRotation( gracz )
     x = x + math.sin( math.rad(a) ) * 4
     y = y - math.cos( math.rad(a) ) * 4
     rz = rz + 90
     local ziemiaZ = getElementData(gracz, "gleba") or z
     if( ziemiaZ ~= z ) then z = ziemiaZ + 0.2 end 
     kolczatki[gracz] = createObject( 2899, x, y, z, 0, 0, rz )
     local col = createColRectangle( 0,0, 4.0, 4.0 )
     attachElements(col, kolczatki[gracz])
     outputChatBox( "Roz?o?ono kolczatk?", gracz, 255, 0, 0, true )
end
addCommandHandler("x", rozloz)


function kolabum( theElement, matchingDimension )
    if getElementType( theElement ) == "vehicle" then 
      setVehicleWheelStates( theElement, 2, 2, 2, 2 ) 
    end
end
addEventHandler( "onColShapeHit", resourceRoot, kolabum )

--to ni?ej do client'a
bindKey("x", "down", "x")
addEventHandler("onClientRender", root, function()
    local x,y,z = getElementPosition(localPlayer)
    local gleba = getGroundPosition(x,y,z)
        if gleba then
        setElementData(localPlayer, "gleba", gleba)
        end
end)


Postaw piwo autorowi tego posta
 

 
Tagi: jakich :: funkcji :: uźyć?
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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