Wysłany: 2015-07-15, 14:44
Given
Wiek: 31 Na forum: 4158 dni Posty: 31
Nick w MP: Given
Piwa : 1
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? ?
Wysłany: 2015-07-15, 14:49
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
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 ( plr , veh )
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
Wysłany: 2015-07-15, 14:57
pomaza
Wiek: 39 Na forum: 3982 dni Posty: 79
Piwa : 2
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.
Wysłany: 2015-07-15, 15:02
piotr172
Wiek: 26 Na forum: 4417 dni Posty: 130
Piwa : 2329
Doda?em tutaj funkcje w tym kodzie.
warpPedIntoVehicle ( plr , veh )
Ale dzia?a ona tylko wtedy gdy do spwnu/stworzenia gracza u?yto funkcji spwanPlayer.
Wysłany: 2015-07-15, 15:17
pomaza
Wiek: 39 Na forum: 3982 dni Posty: 79
Piwa : 2
A ja mam jeszcze jedno pytanie wiem ze to nie m?j temat ale jak dodac funkcje repair na dany id auta ?
Wysłany: 2015-07-15, 15:18
Maximerr
Programmer PHP, LUA
Wiek: 25 Na forum: 4427 dni Posty: 548
Piwa : 1051
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>
Ostatnio zmieniony przez Maximerr 2015-07-15, 15:21, w całości zmieniany 1 raz
Wysłany: 2015-07-15, 15:21
pomaza
Wiek: 39 Na forum: 3982 dni Posty: 79
Piwa : 2
Maximerrr tepa juz tylko moje pytanie wiem ze t onie moj temat ale :
jak dodac funkcje repair na dany id auta ?
Wysłany: 2015-07-15, 15:22
Maximerr
Programmer PHP, LUA
Wiek: 25 Na forum: 4427 dni Posty: 548
Piwa : 1051
pomaza , no, da?em!
Wysłany: 2015-07-15, 15:26
pomaza
Wiek: 39 Na forum: 3982 dni Posty: 79
Piwa : 2
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
Wysłany: 2015-07-15, 15:27
Maximerr
Programmer PHP, LUA
Wiek: 25 Na forum: 4427 dni Posty: 548
Piwa : 1051
Wysłany: 2015-07-15, 15:30
pomaza
Wiek: 39 Na forum: 3982 dni Posty: 79
Piwa : 2
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
Tagi: tp_auto
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: