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

Wysłany: 2014-09-14, 15:51


Dixers

No-Life






Wiek: 26
Na forum: 4453 dni
Posty: 549
Nick w MP: Dixers

Piwa: 412

Respekt: 56,8

Witam serdecznie. Mam wielki problem. Pr?bowa?em sam si? z nim upora?, ale moja wiedza jest zbyt ma?a :( . Chodzi o to, ?e w pracy autobus, gdy jaki? gracz na serwerze wejdzie do autobusu ka?demu wy?wietli si? info na czacie "Zacz??e? prace kierowcy autobusu (...)" A gdy kilka os?b wejdzie do autobusu, to jeden b?dzie m?g? "kra??" przystanki drugiemu. Jak zrobi? ?eby praca by?a tak jakby dla jednego gracza. Tutaj kod:

C-side:

local client = getLocalPlayer( )
local rootElement = getRootElement()
local marker = nil
local blip = nil

addEvent("otobus_durak_loc",true)
addEventHandler("otobus_durak_loc",rootElement,
function (x, y, z)
marker = createMarker(tostring(x), tostring(y), tostring(z)-1, "cylinder", 3.5, 0, 255, 119, 170)
blip = createBlipAttachedTo( marker, 0, 2, 0, 255, 119, 255 )
addEventHandler("onClientMarkerHit",marker,onBusStopHit)
end)

function onBusStopHit(hitPlayer)
if not hitPlayer == client then return end
triggerServerEvent("gorev_bitir",client,client)
if isElement(blip) then destroyElement(blip) end
if isElement(marker) then
removeEventHandler("onClientMarkerHit",marker,onBusStopHit)
destroyElement(marker) 
  end
end

addEventHandler("onClientVehicleExit",rootElement,
function ()
if isElement(marker) then
removeEventHandler("onClientMarkerHit",marker,onBusStopHit)
destroyElement(marker) 
end
if isElement(blip) then destroyElement(blip) end
end)


S-side:

local rootElement = getRootElement()

local busses = {[437] = true}

local Duraklar = {
[1]={-2000.1877441406, 195.46136474609, 27.5390625},
[2]={-1996.1949462891, 338.1559753418, 34.458801269531},
[3]={-1819.6047363281, 371.0954284668, 16.494701385498},
[4]={-1658.0651855469, 386.40524291992, 6.4748606681824},
[5]={-1553.6131591797, 661.59149169922, 6.4819502830505},
[6]={-1530.9566650391, 964.94720458984, 6.4844288825989},
[7]={-1635.7996826172, 1257.1275634766, 6.4874968528748},
[8]={-1988.2543945313, 1314.4470214844, 6.4815640449524},
[9]={-2326.4782714844, 1374.0675048828, 6.4832334518433},
[10]={-2625.263671875, 1314.5977783203, 6.485456943512},
[11]={-2826.7387695313, 876.99084472656, 43.349967956543},
[12]={-2844.07421875, 511.33483886719, 4.1004056930542},
[13]={-2812.3327636719, 205.65841674805, 6.4744448661804},
[14]={-2748.7412109375, -213.97444152832, 6.4776849746704},
[15]={-2452.6572265625, -213.55686950684, 32.926258087158},
[16]={-2396.435546875, -73.812614440918, 34.608352661133},
[17]={-2237.5100097656, -73.677185058594, 34.61568069458},
[18]={-2033.1370849609, -73.505355834961, 34.616176605225},
[19]={-2002.8745117188, 94.33309173584, 26.984334945679},
[20]={-1988.1975097656, 165.10362243652, 26.983469009399},
}

function yeniDurak(thePlayer, ID)
local x, y, z = Duraklar[ID][1], Duraklar[ID][2], Duraklar[ID][3]
triggerClientEvent(thePlayer,"otobus_durak_loc",thePlayer,x,y,z)
end

function onVehicleEnter(thePlayer)
if not busses[getElementModel(source)] then return end
outputChatBox ("Zacz??e? prace kierowcy autobusu. Na ka?dym przystanku zatrzymaj si? na 8sek. Pami?taj, aby nie opuszcza? pojazdu.")
local x, y, z = yeniDurak(thePlayer, 1)
setElementData(thePlayer,"Data",1)
  end
addEventHandler("onVehicleEnter",rootElement,onVehicleEnter)

addEvent("gorev_bitir",true)
addEventHandler("gorev_bitir",rootElement,
function (client)
if not isPedInVehicle(client) then return end
if not busses[getElementModel(getPedOccupiedVehicle(client))] then return end
givePlayerMoney(client, 3)
if #Duraklar == tonumber(getElementData(client,"Data")) then
setElementData(client,"Data",1)
else
setElementData(client,"Data",tonumber(getElementData(client,"Data"))+1)
end
yeniDurak(client, tonumber(getElementData(client,"Data")))
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 15:57


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

Dixers, sprawdz kto prowadzi i temu daje :D ??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 16:02


Dixers

No-Life






Wiek: 26
Na forum: 4453 dni
Posty: 549
Nick w MP: Dixers

Piwa: 412

Respekt: 56,8

luki123luki123, tak, dok?adnie. Pomo?esz? Oferuj? kilka piw i reputacje +10 :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 16:07


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

Dixers, przy pomocy if'a
 if seat == 0 then 


[ Dodano: 2014-09-14, 16:10 ]
@Upade:

Więcej informacji znajdziesz w Wikipedii MTA:

getVehicleOccupant


[ Dodano: 2014-09-14, 16:12 ]
local driver == getVehicleOccupant ( Pojazd.., 0 )
if getPlayerName ( driver ) then
--//Kwoj kod
end


[ Dodano: 2014-09-14, 16:56 ]
Gdzie moje Piwka i RESP ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 17:52


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

luki123luki123, nie b?d? nachalny i nie pro? si? o piwa i reputacje, bo to ?wiadczy o braku kultury.

Mo?esz zrobi? tak?e sposobem moim, czyli po tworzeniu markera nadaje mu setElementDate z nickiem gracza intergowanego. Nast?pnie p?tla na markery i if bla == nick gracza to tworzy funckj? kolejn?.

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 18:00


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

Shuffle, po co nadawa? kolejne warto?ci gracowi lepiej to zrobi? pro?ciej i l?ej dla serwera.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 20:30


MeeShuffle

Programista/Grafik






Wiek: 33
Na forum: 4536 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

Respekt: 535,3
Respekt: 535,3

Graczowi? Warto?? jest nadawana dla markera, kt?ry i tak jest usuwany.

Podpis

https://shufflecode.pl
Static Codes and Graphics - Join our discord!
Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-14, 21:12


Dixers

No-Life






Wiek: 26
Na forum: 4453 dni
Posty: 549
Nick w MP: Dixers

Piwa: 412

Respekt: 56,8

luki123luki123, po pierwsze mnie nie by?o, wi?c nie mog?em ci da? piwa i repu. I czy m?g?by? mi to wsadzi? w m?j kod? By?bym wdzi?czny, otrzymasz 5 piw :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-15, 16:06


luki123luki123

Place Game






Wiek: 28
Na forum: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

Respekt: 611
Respekt: 611Respekt: 611

Dixers,
local rootElement = getRootElement()

local busses = {[437] = true}

local Duraklar = {
[1]={-2000.1877441406, 195.46136474609, 27.5390625},
[2]={-1996.1949462891, 338.1559753418, 34.458801269531},
[3]={-1819.6047363281, 371.0954284668, 16.494701385498},
[4]={-1658.0651855469, 386.40524291992, 6.4748606681824},
[5]={-1553.6131591797, 661.59149169922, 6.4819502830505},
[6]={-1530.9566650391, 964.94720458984, 6.4844288825989},
[7]={-1635.7996826172, 1257.1275634766, 6.4874968528748},
[8]={-1988.2543945313, 1314.4470214844, 6.4815640449524},
[9]={-2326.4782714844, 1374.0675048828, 6.4832334518433},
[10]={-2625.263671875, 1314.5977783203, 6.485456943512},
[11]={-2826.7387695313, 876.99084472656, 43.349967956543},
[12]={-2844.07421875, 511.33483886719, 4.1004056930542},
[13]={-2812.3327636719, 205.65841674805, 6.4744448661804},
[14]={-2748.7412109375, -213.97444152832, 6.4776849746704},
[15]={-2452.6572265625, -213.55686950684, 32.926258087158},
[16]={-2396.435546875, -73.812614440918, 34.608352661133},
[17]={-2237.5100097656, -73.677185058594, 34.61568069458},
[18]={-2033.1370849609, -73.505355834961, 34.616176605225},
[19]={-2002.8745117188, 94.33309173584, 26.984334945679},
[20]={-1988.1975097656, 165.10362243652, 26.983469009399},
}

function yeniDurak(thePlayer, ID)
local x, y, z = Duraklar[ID][1], Duraklar[ID][2], Duraklar[ID][3]
triggerClientEvent(thePlayer,"otobus_durak_loc",thePlayer,x,y,z)
end

function onVehicleEnter(thePlayer)
if not busses[getElementModel(source)] then return end
outputChatBox ("Zacz??e? prace kierowcy autobusu. Na ka?dym przystanku zatrzymaj si? na 8sek. Pami?taj, aby nie opuszcza? pojazdu.")
local x, y, z = yeniDurak(thePlayer, 1)
setElementData(thePlayer,"Data",1)
  end
addEventHandler("onVehicleEnter",rootElement,onVehicleEnter)

addEvent("gorev_bitir",true)
addEventHandler("gorev_bitir",rootElement,
function (client)
    if not isPedInVehicle(client) then return end
        if not busses[getElementModel(getPedOccupiedVehicle(client))] then return end
        local driver == getVehicleOccupant ( getPedOccupiedVehicle(client), 0 )
            if driver then
            givePlayerMoney(client, 3)
                if #Duraklar == tonumber(getElementData(client,"Data")) then
                setElementData(client,"Data",1)
                else
                setElementData(client,"Data",tonumber(getElementData(client,"Data"))+1)
                end
            yeniDurak(client, tonumber(getElementData(client,"Data")))
            end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-09-15, 19:25


Dixers

No-Life






Wiek: 26
Na forum: 4453 dni
Posty: 549
Nick w MP: Dixers

Piwa: 412

Respekt: 56,8

luki123luki123, dzi?ki luki. Jeste? super. Leci kolejne :piwo:

Postaw piwo autorowi tego posta
 

 
Tagi: praca :: jeden :: gracz
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