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

Wysłany: 2017-11-06, 19:04


Bolt







Wiek: 24
Na forum: 3206 dni
Posty: 9
Nick w MP: Bolt

Piwa: 1

Respekt: 50

Cze??! Mam skrypt na prace kierowcy autobusu przerobilem markery by tworzyly sie w LS ale niestety skrypt nieposiada linijki ktora odpowiada za usuniecie pojazdu kiedy sie z niego wyjdzie. Napisa? by mi kto? t? linijeczke? I czy moge wkleic j? w byle jakie miejsce w skrypcie czy musze da? je w jakim? szczeg?lnym miejscu?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-06, 19:13


Qbiszon

Map editor






Wiek: 25
Na forum: 4176 dni
Posty: 29
Nick w MP: Qbi

Piwa: 2

Respekt: 50


Więcej informacji znajdziesz w Wikipedii MTA:

OnVehicleExit


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-06, 19:15


iNev.







Wiek: 24
Na forum: 3951 dni
Posty: 94
Nick w MP: iNev

Piwa: 953

Respekt: 180
Respekt: 180Respekt: 180

addEventHandler("onVehicleExit"root, function(playerseat)
    if seat ~= or not getElementData(source"ELEMENTDATA"then return end
    
    destroyElement(source)
end)


Mo?esz umie?ci? gdziekolwiek.
W elementdacie wpisz elementdate autobusu, kt?ra jest ustawiana w skrypcie. Dzi?ki temu znika? b?d? tylko autobusy, nie ka?de auto.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Bolt
Wysłany: 2017-11-06, 19:42


Bolt







Wiek: 24
Na forum: 3206 dni
Posty: 9
Nick w MP: Bolt

Piwa: 1

Respekt: 50

iNev., W sensie co to elementdata bo dopiero zacz??em co? pisa? w LUA.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-06, 19:47


Atroth







Wiek: 23
Na forum: 3677 dni
Posty: 1089
Nick w MP: Atroth

Piwa: 4808

Respekt: 540
Respekt: 540

Bolt, ElementData to data "przyczepiona" do elementu m?wi?c ?opatologicznie.


Więcej informacji znajdziesz w Wikipedii MTA:

setElementData


Nie za bardzo wiem jak Ci to wyt?umaczy?. Musisz zrozumie? to w praktyce.

Podpis

Użytkownik - 10-05-2016
Support Team - 17.06.2017
Moderator - 25.11.2017
Mod-Team - 02.07.2018

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Bolt
Wysłany: 2017-11-06, 19:59


Bolt







Wiek: 24
Na forum: 3206 dni
Posty: 9
Nick w MP: Bolt

Piwa: 1

Respekt: 50

iNev., I mam pytanie co w tym skrypcie odpowiada za to by gracz ktory wzial ta prace nie mogl wsiasc do innego auta tylko do autobusu.
local bsMarker = createMarker(1990.7332763672,-2064.591796875,13.369647026062,"cylinder",1.5,252,0,255,50)
createBlipAttachedTo(bsMarker,59)

local bsLocations = {
{1968.0670166016,-1903.6304931641,13.546875},
{2092.0737304688,-1779.2563476563,13.546875},
{2087.9284667969,-1377.0284423828,23.996141433716},
{2022.4432373047,-1060.8319091797,24.675029754639},
{1840.0643310547,-1321.818359375,13.552955627441},
{1815.3453369141,-1778.5655517578,13.546875},
{1955.1846923828,-2019.7178955078,13.546875},
{1926.1563720703,-2172.9853515625,13.546875},
{2249.2333984375,-2225.4128417969,13.546875},
{2720.7609863281,-2076.0356445313,12.201910018921}}






local bsNumber = {}

addEventHandler("onMarkerHit",bsMarker,
function(hitElement,_)
if (hitElement and getElementType(hitElement) == "player" and not isPedInVehicle(hitElement)) then
if not (getElementData(hitElement,"AGJob") == "busdriver") then -- we use this to check if the player did not take the job before
triggerClientEvent("showbsGui", hitElement, hitElement)
else
outputChatBox("Your job already started. Get back to your vehicle and continue to work!", hitElement,229,250,2)

end
end
end)


local bsVehicle = {}
local bsVehicleBlip = {}
local bsJobMarker = {}
local bsJobBlip = {}


function startbsJob(thePlayer)
setElementData(thePlayer,"AGJob","busdriver")
bsVehicle[thePlayer] = createVehicle(420,1981.2021484375,-2062.1665039063,13.382161140442)
bsVehicleBlip[thePlayer] = createBlipAttachedTo(bsVehicle[thePlayer],51)


setElementVisibleTo(bsVehicleBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsVehicleBlip[thePlayer],thePlayer,true)

setElementData(bsVehicle[thePlayer],"JobOwner", getPlayerName(thePlayer))
setElementData(bsVehicle[thePlayer],"AGJob","taxi")
warpPedIntoVehicle(thePlayer,bsVehicle[thePlayer])

showDaBusMarker(thePlayer)
end
addEvent("givebsJob",true)
addEventHandler("givebsJob", root,startbsJob)

function showDaBusMarker(thePlayer)
if bsNumber[thePlayer] then
--outputChatBox("bsnumber")
if bsNumber[thePlayer] == 1 then
bsNumber[thePlayer] = bsNumber[thePlayer] + 1
--outputChatBox("bsnumber == 1, so + 1")
elseif bsNumber[thePlayer] == 10 then
bsNumber[thePlayer] = bsNumber[thePlayer] - math.random(1,8)
--outputChatBox("bsnumber - ")
else
bsNumber[thePlayer] = bsNumber[thePlayer] + 1
--outputChatBox("bsnumber + 1")
end


bsJobMarker[thePlayer] = createMarker(bsLocations[bsNumber[thePlayer]][1],bsLocations[bsNumber[thePlayer]][2],bsLocations[bsNumber[thePlayer]][3],"cylinder",2,100,100,0,200)
bsJobBlip[thePlayer] = createBlipAttachedTo(bsJobMarker[thePlayer],56)

setElementData(bsJobMarker[thePlayer],"JobOwner",getPlayerName(thePlayer))


setElementVisibleTo(bsJobMarker[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobMarker[thePlayer],thePlayer,true)
setElementVisibleTo(bsJobBlip[thePlayer],thePlayer,true)
addEventHandler("onMarkerHit", bsJobMarker[thePlayer], givebsPay)

else
bsNumber[thePlayer] = math.random(1,10)
--outputChatBox("no bsnumber")
--outputChatBox(bsNumber[thePlayer])
bsJobMarker[thePlayer] = createMarker(bsLocations[bsNumber[thePlayer]][1],bsLocations[bsNumber[thePlayer]][2],bsLocations[bsNumber[thePlayer]][3],"cylinder",2,100,100,0,200)

setElementData(bsJobMarker[thePlayer],"JobOwner",getPlayerName(thePlayer))

bsJobBlip[thePlayer] = createBlipAttachedTo(bsJobMarker[thePlayer],56)
setElementVisibleTo(bsJobMarker[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobBlip[thePlayer],getRootElement(),false)
setElementVisibleTo(bsJobMarker[thePlayer],thePlayer,true)
setElementVisibleTo(bsJobBlip[thePlayer],thePlayer,true)
addEventHandler("onMarkerHit", bsJobMarker[thePlayer], givebsPay)

end
end
addEventHandler("onVehicleExit", root, function(player, seat)
if seat ~= 0 or not getElementData(source, "busdriver") then return end

destroyElement(source)
end)

function givebsPay(hitElement,_)
if (getElementType(hitElement) == "player" and getElementData(hitElement,"AGJob")== "busdriver" and isPedInVehicle(hitElement)) then
--outputChatBox("first step")
if (getElementData(source,"JobOwner") == getPlayerName(hitElement)) then
--outputChatBox("second step")
local vehicle = getPedOccupiedVehicle(hitElement)

if (getElementData(vehicle,"JobOwner") == getElementData(source,"JobOwner" )) then
setElementFrozen(vehicle,true)
setElementFrozen(hitElement,true)
outputChatBox("The passengers are getting down",hitElement,252,0,255)
destroyElement(bsJobMarker[hitElement])
destroyElement(bsJobBlip[hitElement])
setTimer(givebsPayNow,3000,1,hitElement)
else
outputChatBox("Get back to your job vehicle!!!",hitElement,0,246,255)
end
end
end
end

function givebsPayNow(thePlayer)
setElementFrozen(thePlayer,false)
setElementFrozen(bsVehicle[thePlayer],false)
givePlayerMoney(thePlayer,1000)
showDaBusMarker(thePlayer)
end


function destroybs()
if getElementData(source,"AGJob") == "busdriver" then
if isElement(bsVehicle[source]) then
destroyElement(bsVehicle[source])
end
if isElement(bsVehicleBlip[source]) then
destroyElement(bsVehicleBlip[source])
end
if isElement(bsJobMarker[source]) then
destroyElement(bsJobMarker[source])
end
if isElement(bsJobBlip[source]) then
destroyElement(bsJobBlip[source])
end
bsNumber[source] = nil
end
end
addEventHandler("onPlayerQuit",getRootElement(), destroybs)

addEventHandler("onVehicleExplode", getRootElement(),
function()
if getElementData(source,"AGJob") == "busdriver" then
local player = getPlayerFromName(getElementData(source,"JobOwner"))
if isElement(bsVehicle[player]) then
destroyElement(bsVehicle[player])
end
if isElement(bsVehicleBlip[player]) then
destroyElement(bsVehicleBlip[player])
end
if isElement(bsJobMarker[player]) then
destroyElement(bsJobMarker[player])
end
if isElement(bsJobBlip[player]) then
destroyElement(bsJobBlip[player])
end
bsNumber[player] = nil
setElementData(player,"AGJob",nil)
end
end)

addEventHandler("onVehicleStartEnter",getRootElement(),
function(player,seat,jacked,door)
if (getElementData(source,"AGJob") and getElementData(source,"AGJob")=="busdriver") then
if (getElementData(source,"JobOwner") ~= getPlayerName(player)) then
cancelEvent(true)
outputChatBox("This is not your vehicle!",player,200,0,50)
end
end
end)

addEventHandler("onElementDataChange",getRootElement(),
function(dataName,oldValue)
if getElementType(source) == "player" then
if dataName == "AGJob" then
if oldValue == "busdriver" then
if isElement(bsVehicle[source]) then
destroyElement(bsVehicle[source])
end
if isElement(bsVehicleBlip[source]) then
destroyElement(bsVehicleBlip[source])
end
if isElement(bsJobMarker[source]) then
destroyElement(bsJobMarker[source])
end
if isElement(bsJobBlip[source]) then
destroyElement(bsJobBlip[source])
end
bsNumber[source] = nil
end
end
end
end)

[ Dodano: 2017-11-06, 20:00 ]
_Mike, Tak to juz ogarnalem tylko wlasnie to co przed chwila wyslalem jest dla mnie nie zrozumiale. Patrzylem na caly skrypt i nie moglem znalezc zadnej linijki ktora by za to odpowiadala.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-11-06, 21:59


iNev.







Wiek: 24
Na forum: 3951 dni
Posty: 94
Nick w MP: iNev

Piwa: 953

Respekt: 180
Respekt: 180Respekt: 180

Ten kod za to odpowiada:
addEventHandler("onVehicleStartEnter",getRootElement(), 
function(player,seat,jacked,door) 
if (getElementData(source,"AGJob") and getElementData(source,"AGJob")=="busdriver"then 
if (getElementData(source,"JobOwner") ~= getPlayerName(player)) then 
cancelEvent(trueoutputChatBox("This is not your vehicle!",player,200,0,50end 
end 
end)


Nastepnym razem wklejaj skrypt LUA w tag [lua][/lua]

Postaw piwo autorowi tego posta
 

 
Tagi: usuniecie :: pojazdu :: kiedy :: gracz :: niego :: wyjdzie
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