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

Wysłany: 2016-09-02, 12:01


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

jak zrobi? zeby dzia?a?o jak ktos ma skin id 50
co i gdzie doda?


skrypt
vehInCol = {}
tuningTable = {}

strefa createColSphere(2172.07,-2160.24,12.934)
local marker createMarker2177.87,-2164.94,13.03"cylinder"1.5015010080)

function sprawdzStrefeTuningu(hitElement)
    if getElementType(hitElement) == "player" then
    local acc getPlayerAccount(hitElement)
        if acc then
        local login getAccountName(acc)    
            if isObjectInACLGroup ("user."..loginaclGetGroup ("Everyone")) then
            local veh getPedOccupiedVehicle(hitElement)
                if not veh then
                local elements getElementsWithinColShape (strefa"vehicle")
                    if #elements == 1 then
                        if not tuningTable[hitElementthen
                        local veh elements[1]
                        local aktualnyTuning getVehicleUpgrades(veh)
                    
                        tuningTable[hitElement] = {vehaktualnyTuning}
                        triggerClientEvent(hitElement"pokazGUITuningu"rootvehupgradesVeh)
                        setElementData(hitElement"warsztat"true)
                        
                        vehInCol = {}
                        vehInCol[veh] = hitElement
                        end
                    else
                        if #elements == 0 then
                        outputChatBox("W strefie tuningu nie ma pojazdu."hitElement255255255true)
                        else
                        outputChatBox("W strefie tuningu jest wi?cej ni? jeden pojazd."hitElement255255255true)
                        end
                    end
                end
            end
        end
    end
end
addEventHandler("onMarkerHit"markersprawdzStrefeTuningu)

function onColLeave(hitElement)
    if getElementType (hitElement) == "pojazd" then
    local player vehInCol[hitElement]
        if player then
            if isElement(playerthen
            removeUpgradeOnClose(player)
            addUpgradeOnClose(player)
            clearData(player)
            triggerClientEvent(player"zamknijGUITuninguTune"root)
            end
        end
    vehInCol[hitElement] = nil
   end
end
addEventHandler("onColShapeLeave"strefaonColLeave)

addEvent("zabierzPieniadzeZaTuning"true)
addEventHandler("zabierzPieniadzeZaTuning"getRootElement(),
function(cena)
takePlayerMoney(sourcetonumber(cena))
outputChatBox("Zainstalowa?e? nowe cze?ci w poje?dzie, cena "..cena.." PLN."source255255255true)
end)

--[[
dodaje czesc do pojazdu
--]]
function addUpgrade(czesc)
local veh tuningTable[source][1]

    if not isElement(vehthen
    return false
    end
    
addVehicleUpgrade(vehczesc)
end
addEvent("addUpgrade"true)
addEventHandler("addUpgrade"getRootElement(), addUpgrade)

--[[
usuwa dana czesc z pojazdu
--]]
function removeUpgrade(czesc)
local veh tuningTable[source][1]

    if not isElement(vehthen
    return false
    end

removeVehicleUpgrade(vehczesc)
end
addEvent("removeUpgrade"true)
addEventHandler("removeUpgrade"getRootElement(), removeUpgrade)

--[[
usuwa wszystkie zainstalowane przy tym tuningu czesci
--]]
function removeUpgradeOnClose(player)
local source player or source
    if getElementData(source"warsztat"then
    local veh tuningTable[source][1]
    local upgrades getVehicleUpgrades(veh)
        for k,v in ipairs (upgrades) do
        removeVehicleUpgrade(vehv)
        end
    end
end
addEvent("removeUpgradeOnClose"true)
addEventHandler("removeUpgradeOnClose"getRootElement(), removeUpgradeOnClose)

--[[
dodaje stare czesci do pojazdu
--]]
function addUpgradeOnClose(player)
local source player or source
    if getElementData(source"warsztat"then
    local veh tuningTable[source][1]
    local tuning tuningTable[source][2]
        for i,v in pairs(tuning) do
        addVehicleUpgrade(vehv)
        end
    end
end
addEvent("addUpgradeOnClose"true)
addEventHandler("addUpgradeOnClose"getRootElement(), addUpgradeOnClose)

--[[
usuwa daneprzywraca tuning przy wyjsciu z serwera wyjsciu z gui
--]]
function clearData(player)
local player source or player
tuningTable[player] = nil
removeElementData(player"warsztat")
end
addEvent("clearDataTuning"true)
addEventHandler("clearDataTuning"getRootElement(), clearData)

function przywrocDane()
removeUpgradeOnClose(source)
addUpgradeOnClose(source)
clearData(source)
resetLight(source)
end
addEventHandler("onPlayerQuit"getRootElement(), przywrocDane)


--laduje itemy do tablicy po stronie serwerapotem to przenosze do klienta
upgradesVeh = {}

function loadItems()
local file_root xmlLoadFile("moditems.xml")
local sub_node xmlFindChild(file_root"item"0)
0
    while sub_node do
    item xmlNodeGetAttribute(sub_node"itemid")
    name xmlNodeGetAttribute(sub_node"name")
    price xmlNodeGetAttribute(sub_node"price")
    upgradesVeh[i] = {itemnameprice}
    
    1
    sub_node xmlFindChild(file_root"item"i)
    end
i nil
sub_node nil
end
addEventHandler("onResourceStart"getResourceRootElement(getThisResource()), loadItems)
--Blip

createBlip ( -84.92,1130.82,19.8427 )


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 12:43


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8


Więcej informacji znajdziesz w Wikipedii MTA:

getElementModel


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 13:07


luki123luki123

Place Game






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

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

marcin778, czytanie ze zrozumieniem si? k?ania.
Cytat:

co i gdzie doda?


Aidis, funckje t? co poda? wy?ej gracz i w taki spos?b:
if getElementModel(hitElement) == 50 then

A w miejsce mo?esz da? w te je?eli ma by? tylko na model sprawdzanie:
   if isObjectInACLGroup ("user."..loginaclGetGroup ("Everyone")) then

oraz mo?esz usun?? szybsze linijki nad tym if'em poniewa? s? one nie potrzebne. Ale je?eli usuniesz je to musisz te? usun?? endy kt?re by?y odpowiedzialne za tamte if'y

A je?eli ma by? na Sprawdzanie grupy + model to daj pod if'em wy?ej ten kod:
if getElementModel(hitElement) ~= 50 then return end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 20:12


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

nie dzia?a

ddEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
    if getElementModel(hitElement) == 50 then
    if not cs then return end
    if job ~= ljob then
        outputChatBox(" Nie jeste?› zatrudniony w tym warsztacie."25500)
        return
    end
    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("Na stanowisku monta??u nie ma ??adnego pojazdu."25500)
        return
    end
    if #vehicles > 1 then
        outputChatBox(" Na stanowisku monta??u jest zbyt du??o pojazd??w."25500)
        return
    end
    if getElementHealth(vehicles[1]) < 900 then
        outputChatBox(" Pojazd jest zbyt uszkodzony aby zamontowa?&#8225; ?&#8250;wiat?&#8218;a."25500)
        return
    end
    isVehicles=vehicles[1]
    showCursor(true,false)
    guiGridListClear(wn.grid)
    guiSetVisible(wn.windowtrue)
    for i,v in ipairs(isCzesci) do
        local row=guiGridListAddRow(wn.grid)
        guiGridListSetItemText(wn.gridrow1v[1].."("..v[2]..")"falsefalse)
        guiGridListSetItemData(wn.gridrow1v[2], falsefalse)
        guiGridListSetItemText(wn.gridrow2v[3].." PLN"falsefalse)
        guiGridListSetItemData(wn.gridrow2v[3], falsefalse)
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 20:15


luki123luki123

Place Game






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

Piwa: 6101

Respekt: 611
Respekt: 611Respekt: 611

Aidis, co nie dzia?a bo?e jasnowidzami jeste?my ?
Jakie? b??dy w debugscipt 3 ? Lub mo?e ?askawie powiedz co nie dzia?a .

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 21:14


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

b??d?w brak.
mam skina cj i mog? korzysta?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 21:54


marcin778

Krytyk serwerów MTA






Wiek: 24
Na forum: 4149 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4662

Respekt: 1436,8
Respekt: 1436,8

Jak to mo?e dzia?a? ?
ddEventHandler("onClientMarkerHit"resourceRoot, function(el,md)


addEventHandler("onClientMarkerHit"resourceRoot, function(el,md)
    if not md or el~=localPlayer then return end
    if getElementModel(el) == 50 then
    if not cs then return end
    if job ~= ljob then
        outputChatBox(" Nie jeste?&#8250; zatrudniony w tym warsztacie."25500)
        return
    end
    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("Na stanowisku monta??u nie ma ??adnego pojazdu."25500)
        return
    end
    if #vehicles > 1 then
        outputChatBox(" Na stanowisku monta??u jest zbyt du??o pojazd??w."25500)
        return
    end
    if getElementHealth(vehicles[1]) < 900 then
        outputChatBox(" Pojazd jest zbyt uszkodzony aby zamontowa?&#8225; ?&#8250;wiat?&#8218;a."25500)
        return
    end
    isVehicles=vehicles[1]
    showCursor(true,false)
    guiGridListClear(wn.grid)
    guiSetVisible(wn.windowtrue)
    for i,v in ipairs(isCzesci) do
        local row=guiGridListAddRow(wn.grid)
        guiGridListSetItemText(wn.gridrow1v[1].."("..v[2]..")"falsefalse)
        guiGridListSetItemData(wn.gridrow1v[2], falsefalse)
        guiGridListSetItemText(wn.gridrow2v[3].." PLN"falsefalse)
        guiGridListSetItemData(wn.gridrow2v[3], falsefalse)
    end
end)


Podpis
Moje prace: https://www.youtube.com/c...MuaWGHPp1mhlGnw

-- obecnie
-- obecnie
-- dawniej
-- dawniej
-- dawniej
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-09-02, 21:57


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4395 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

luki, nie pomagaj ju? wi?cej :)


Podmie? w getElementModel argument hitElement na el

Podpis

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

 
Wysłany: 2016-09-04, 10:05


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

naprawi?em.

Postaw piwo autorowi tego posta
 

 
Tagi: jak :: zrobić :: zeby :: działało :: jak :: ktos :: skin
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