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

Wysłany: 2015-07-15, 14:44


Given







Wiek: 31
Na forum: 4158 dni
Posty: 31
Nick w MP: Given

Piwa: 1

Respekt: 50

Ostrzeżeń: 100%
Witam mam o to kod :
Kod:


addCommandHandler("warp",function(plr,cmd,id)
if id then
id=tonumber(id)
local veh=getVehicle(id)
if veh then
local x,y,z=getElementPosition(plr)
local int=getElementInterior(plr)
local dim=getElementDimension(plr)
setElementPosition(veh,x,y,z)
setElementPosition(plr,x,y,z+2)
setElementDimension(veh,dim)
setElementInterior(veh,int)
outputChatBox("Przenios?e? do Siebie "..getVehicleName(veh).." ( ID : "..getElementData(veh,"car_id").." )",plr,255,255,255)
end
end

end)

I on dzia?a ale jak zrobi? ?eby nie tepa?o auta do mnie tylko jak tepnie auto to ?ebym odrazu w nim siedzia? ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 14:49


piotr172







Wiek: 26
Na forum: 4417 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Nie dzia?a bo potrzebna jeszcze jest jedna funkcja kt?ry wyszukuje id.


local function getVehicle(id)
    if id then
        id=tonumber(id)
        for _,v in ipairs(getElementsByType("vehicle"))do
            if getElementData(v,"car_id"then
                if getElementData(v,"car_id")==id then
                    return v
                end
            end
        end
    end
    return false
end


addCommandHandler("warp",function(plr,cmd,id)
        if id then
                id=tonumber(id)
                local veh=getVehicle(id)
                if veh then
                    local x,y,z=getElementPosition(plr)
                    local int=getElementInterior(plr)
                    local dim=getElementDimension(plr)
                    setElementPosition(veh,x,y,z)
                    setElementPosition(plr,x,y,z+2)
                    setElementDimension(veh,dim)
                    setElementInterior(veh,int)
                    warpPedIntoVehicle(plrveh)
                    outputChatBox("Przenios?e? do Siebie "..getVehicleName(veh).." ( ID : "..getElementData(veh,"car_id").." )",plr,255,255,255)
                end
            end

end)




Uzupe?nij tylko elemnet date id jaka jest nadawana pojazdu. Tutaj: (car_id podmien)


            if getElementData(v,"car_id"then
                if getElementData(v,"car_id")==id then


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 14:57


pomaza







Wiek: 39
Na forum: 3982 dni
Posty: 79

Piwa: 2

Respekt: 50

Piotrze
I on dzia?a ale jak zrobi? ?eby nie tepa?o auta do mnie tylko jak tepnie auto to ?ebym odrazu w nim siedzia? ?
on chcia? ?eby auto si? nie tepa?o kolo niego tylko ?eby on w nim odrazu po tepnieciu w nim siedzia?.
I tez kieruje te pytanie poniewasz te? mi to jest bardzo potrzebne. :mrgreen:

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:02


piotr172







Wiek: 26
Na forum: 4417 dni
Posty: 130

Piwa: 2329

Respekt: 105,3
Respekt: 105,3

Doda?em tutaj funkcje w tym kodzie.

warpPedIntoVehicle(plrveh)


Ale dzia?a ona tylko wtedy gdy do spwnu/stworzenia gracza u?yto funkcji spwanPlayer.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:17


pomaza







Wiek: 39
Na forum: 3982 dni
Posty: 79

Piwa: 2

Respekt: 50

A ja mam jeszcze jedno pytanie wiem ze to nie m?j temat ale jak dodac funkcje repair na dany id auta ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:18


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

pomaza, piotr172, aby funkcja warpPedIntoVehicle zadzia?a?a, musisz spawnowa? graczy funkcj?:

Więcej informacji znajdziesz w Wikipedii MTA:

spawnPlayer

Je?li Ci? nie tepa do pojazdu, znaczy, ?e pozalogowaniu spawnujesz graczy inn? funkcj? ni? spawnPlayer ;)

[ Dodano: 2015-07-15, 15:20 ]
local function getVehicle(id)
    if id then
        id=tonumber(id)
        for _,v in ipairs(getElementsByType("vehicle"))do
            if getElementData(v,"car_id"then
                if getElementData(v,"car_id")==id then
                    return v
                end
            end
        end
    end
    return false
end


addCommandHandler("fix",function(plr,cmd,id)
        if id then
                id=tonumber(id)
                local veh=getVehicle(id)
                if veh then
                      fixVehicle(veh)
                end
            end

end)

teraz masz napraw? pod komend? /fix <id auta> :eye:

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

 
Wysłany: 2015-07-15, 15:21


pomaza







Wiek: 39
Na forum: 3982 dni
Posty: 79

Piwa: 2

Respekt: 50

Maximerrr tepa juz :) tylko moje pytanie wiem ze t onie moj temat ale :
jak dodac funkcje repair na dany id auta ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:22


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

pomaza, no, da?em! lol

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:26


pomaza







Wiek: 39
Na forum: 3982 dni
Posty: 79

Piwa: 2

Respekt: 50

o sora nie od?wierzy?em :) thx !
ale nie co? zjad?e? chyba na ko?cu ")" co nie ?

[ Dodano: 2015-07-15, 15:27 ]
i end jedno

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:27


Maximerr

Programmer PHP, LUA






Wiek: 25
Na forum: 4427 dni
Posty: 548

Piwa: 1051

Respekt: 365,3
Respekt: 365,3Respekt: 365,3Respekt: 365,3Respekt: 365,3

pomaza, niee.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-07-15, 15:30


pomaza







Wiek: 39
Na forum: 3982 dni
Posty: 79

Piwa: 2

Respekt: 50

ale nie dzia?a?o a jak dodalem jedno end ) to dzia?a

[ Dodano: 2015-07-15, 15:30 ]
bo tak to w debugu b??dy by?y

[ Dodano: 2015-07-15, 15:32 ]
Mam jeszcze jedna spraw? ale to napisze w innym temacie :)

Postaw piwo autorowi tego posta
 

 
Tagi: tp_auto
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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