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

Wysłany: 2016-04-03, 12:21


Patrix100

Amator LUA.






Wiek: 26
Na forum: 4028 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 953

Respekt: 40,5

Lock

Ostatnio zmieniony przez Patrix100 2016-04-06, 17:24, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 12:24


AteX







Wiek: 27
Na forum: 4157 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3


Więcej informacji znajdziesz w Wikipedii MTA:

getDistanceBetweenPoints3D


Albo tworzysz na pojazdach colshape lub marker.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 12:29


Patrix100

Amator LUA.






Wiek: 26
Na forum: 4028 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 953

Respekt: 40,5

"AteX" napisał/a:


Więcej informacji znajdziesz w Wikipedii MTA:

getDistanceBetweenPoints3D


Albo tworzysz na pojazdach colshape lub marker.

Jakis przyklad czy co?? Bo nie ogarniam :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 12:36


AteX







Wiek: 27
Na forum: 4157 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

addCommandHandler("kuppojazd",function(plr,cmd)
 local x,y,z = getElementPosition(plr)
 for i,v in pairs(getElementsByType("vehicle",resourceRoot)) do
  if getElementData(v,"vehicle.selling") then
   local x1,y1,z1 = getElementPosition(v)
   if getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) < 5 then
    -- tu umiesc kupowanie pojazdu
   return end
  end
 end
end)


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 13:17


Patrix100

Amator LUA.






Wiek: 26
Na forum: 4028 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 953

Respekt: 40,5

"AteX" napisał/a:

addCommandHandler("kuppojazd",function(plr,cmd)
 local x,y,z = getElementPosition(plr)
 for i,v in pairs(getElementsByType("vehicle",resourceRoot)) do
  if getElementData(v,"vehicle.selling") then
   local x1,y1,z1 = getElementPosition(v)
   if getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) < 5 then
    -- tu umiesc kupowanie pojazdu
   return end
  end
 end
end)

A to nie bedzie przypadkiem tak ze jak wejdzie w marker to bedzie kupowac wszystkie auta?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 13:24


AteX







Wiek: 27
Na forum: 4157 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Tu nie ma markera, to sprawdza tylko odleg?o?? pojazdu. Tak poza tym bez test?w si? nie dowiesz.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 17:31


Patrix100

Amator LUA.






Wiek: 26
Na forum: 4028 dni
Posty: 182
Nick w MP: .:Patrix:.

Piwa: 953

Respekt: 40,5

Zrobi?em tak i nie dzia?a. Trzeba wej?? do auta ?eby kupi?.
local positionVehicles = {
    -- nazwa, model, przebieg, cena, x,y,z,rx,ry,rz, sprzeda?
    -- salon 
    --{'Manana', 410, 0, 5000, 2220.04175, -123.38932, 28.46326, 359.2, 360.0, 129.9},
    {'Ocenic', 467, 0, 8563, -1957.03, 299.64, 35.21, 359.6, 360.0, 140.1},
    {'Premier', 426, 0, 16139, -1948.72, 268.60, 35.22, 360.0, 359.9, 43.6},
    {'Tahoma', 566, 0, 11431, -1951.49, 260.42, 35.25, 0.4, 0.1, 40.7},
    {'Vincent', 540, 0, 13794, -1955.89, 258.11, 40.91, 359.7, 360.0, 1.1},
    {'Clover', 542, 0, 8853, -1946.46, 261.48, 40.83, 360.0, 360.0, 48.9},
    {'Blista Compact', 496, 0, 21237, -1948.25, 270.74, 40.77, 0.0, 360.0, 53.0},
    {'Tampa', 549, 0, 7653, -1955.07, 300.77, 40.74, 360.0, 360.0, 181.7},
    

}

for i,v in pairs(positionVehicles) do
    local veh=createVehicle(v[2], v[5], v[6], v[7], v[8], v[9], v[10], v[11])
    setElementData(veh,'pojazd_opis','Model: '..v[1]..'\nCena: '..v[4]..' Eur\nPrzebieg: '..v[3]..' km\nAby kupi? pojazd wsi?dz na miejsce kierowcy i wpisz /kuppojazd')
    setVehicleOverrideLights(veh, 1)
    setElementFrozen(veh,true)
    setVehicleDamageProof(veh, true)
    setElementData(veh,'vehicle.selling', true)
    setVehicleLocked(veh, true)
    setVehicleColor(veh, 0, 112, 141)


    veh:setData('vehsell:info', {
        ['cost']=v[4],
        ['model']=v[2],
        ['mileage']=v[3],
        ['selling']=v[12]
    }, false)
end

addEventHandler('onVehicleEnter', resourceRoot, function(plr, seat, jacked)
    if seat~=0 then return end
    if source:getData('vehsell:info') and source:getData('vehsell:info').selling==1 then
        plr:outputChat('* Pojazd nie jest dost?pny w sprzeda?y.', 255, 0, 0)
        return
    end

    local data=source:getData('vehsell:info')
    if not data then return end

    plr:setData('vehsell:info', {
        ['cost']=data.cost,
        ['model']=data.model,
        ['mileage']=data.mileage,
    }, false)

    plr:outputChat('* Aby zakupi? ten pojazd wpisz /kuppojazd',0,128,255)
end)

addEventHandler('onVehicleExit', resourceRoot, function(plr, seat, jacked, m)
    if seat~=0 then return end

    local data=plr:getData('vehsell:info')
    if not data then return end

    plr:removeData('vehsell:info')
end)

    Timer(function() 
        destroyElement(blip) 
    end, 60000*2, 1)

addCommandHandler("kuppojazd",function(plr,cmd)
 local x,y,z = getElementPosition(plr)
 for i,v in pairs(getElementsByType("vehicle",resourceRoot)) do
  if getElementData(v,"vehicle.selling") then
   local x1,y1,z1 = getElementPosition(v)
   if getDistanceBetweenPoints3D(x,y,z,x1,y1,z1) < 5 then
    local data=plr:getData('vehsell:info')
    if not data then return end

    if getPlayerMoney(plr) < data.cost then
        outputChatBox('* Nie posiadasz wystarczaj?cej ilo?ci PLN.', plr, 255, 0, 0)
        return
    end

    local vehicle=plr:getOccupiedVehicle()
    if vehicle then
        removePedFromVehicle(vehicle)
    end

    local cost=data.cost
    local model=data.model
    local mileage=data.mileage
    local uid=getElementData(plr,'player:uid') or 0
    takePlayerMoney(plr, cost)
    
    exports['db']:dbGet('INSERT INTO ogrpg_vehicles (model, frozen, ownedPlayer, parking, fuel) VALUES (?, ?, ?, ?, ?)', model, 0, getElementData(plr,'player:uid'), 1, 15)
    outputChatBox('* Zakupi?e? sw?j pojazd, id? do przechowalni (Dyskietka na mapie), i odbierz go.', plr,0,175,0,true)
   return end
  end
 end
end)


Podpis
Pomogłem? Wystarczy że podziękujesz albo dasz respekt :D
Wole respekt niz piwka :P
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-03, 17:33


AteX







Wiek: 27
Na forum: 4157 dni
Posty: 925
Nick w MP: #AteX

Piwa: 8366

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

To nie wystarczy kopiuj wklej, skoro to by?o robione pod wsiadanie to trzeba to jeszcze edytowa?.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Tagi: lock
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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