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: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

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.93, 4)
local marker = createMarker( 2177.87,-2164.94,13.03, "cylinder", 1.5, 0, 150, 100, 80)

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

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

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

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

    if not isElement(veh) then
    return false
    end
    
addVehicleUpgrade(veh, czesc)
end
addEvent("addUpgrade", true)
addEventHandler("addUpgrade", getRootElement(), addUpgrade)

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

    if not isElement(veh) then
    return false
    end

removeVehicleUpgrade(veh, czesc)
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(veh, v)
        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(veh, v)
        end
    end
end
addEvent("addUpgradeOnClose", true)
addEventHandler("addUpgradeOnClose", getRootElement(), addUpgradeOnClose)

--[[
usuwa dane, przywraca 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 serwera, potem to przenosze do klienta
upgradesVeh = {}

function loadItems()
local file_root = xmlLoadFile("moditems.xml")
local sub_node = xmlFindChild(file_root, "item", 0)
i = 0
    while sub_node do
    item = xmlNodeGetAttribute(sub_node, "itemid")
    name = xmlNodeGetAttribute(sub_node, "name")
    price = xmlNodeGetAttribute(sub_node, "price")
    upgradesVeh[i] = {item, name, price}
    
    i = i + 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.84, 27 )


Postaw piwo autorowi tego posta
 

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


marcin778

Krytyk serwerów MTA






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

Piwa: 4661

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: 5416 dni
Posty: 1948
Nick w MP: LuKiO

Piwa: 6103

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."..login, aclGetGroup ("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: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

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.", 255, 0, 0)
        return
    end
    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("Na stanowisku monta??u nie ma ??adnego pojazdu.", 255, 0, 0)
        return
    end
    if #vehicles > 1 then
        outputChatBox(" Na stanowisku monta??u jest zbyt du??o pojazd??w.", 255, 0, 0)
        return
    end
    if getElementHealth(vehicles[1]) < 900 then
        outputChatBox(" Pojazd jest zbyt uszkodzony aby zamontowa?&#8225; ?&#8250;wiat?&#8218;a.", 255, 0, 0)
        return
    end
    isVehicles=vehicles[1]
    showCursor(true,false)
    guiGridListClear(wn.grid)
    guiSetVisible(wn.window, true)
    for i,v in ipairs(isCzesci) do
        local row=guiGridListAddRow(wn.grid)
        guiGridListSetItemText(wn.grid, row, 1, v[1].."("..v[2]..")", false, false)
        guiGridListSetItemData(wn.grid, row, 1, v[2], false, false)
        guiGridListSetItemText(wn.grid, row, 2, v[3].." PLN", false, false)
        guiGridListSetItemData(wn.grid, row, 2, v[3], false, false)
    end
end)


Postaw piwo autorowi tego posta
 

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


luki123luki123

Place Game






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

Piwa: 6103

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: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

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: 4290 dni
Posty: 2268
Nick w MP: Marcineg

Piwa: 4661

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.", 255, 0, 0)
        return
    end
    local vehicles=getElementsWithinColShape(cs,"vehicle")
    if #vehicles < 1 then
        outputChatBox("Na stanowisku monta??u nie ma ??adnego pojazdu.", 255, 0, 0)
        return
    end
    if #vehicles > 1 then
        outputChatBox(" Na stanowisku monta??u jest zbyt du??o pojazd??w.", 255, 0, 0)
        return
    end
    if getElementHealth(vehicles[1]) < 900 then
        outputChatBox(" Pojazd jest zbyt uszkodzony aby zamontowa?&#8225; ?&#8250;wiat?&#8218;a.", 255, 0, 0)
        return
    end
    isVehicles=vehicles[1]
    showCursor(true,false)
    guiGridListClear(wn.grid)
    guiSetVisible(wn.window, true)
    for i,v in ipairs(isCzesci) do
        local row=guiGridListAddRow(wn.grid)
        guiGridListSetItemText(wn.grid, row, 1, v[1].."("..v[2]..")", false, false)
        guiGridListSetItemData(wn.grid, row, 1, v[2], false, false)
        guiGridListSetItemText(wn.grid, row, 2, v[3].." PLN", false, false)
        guiGridListSetItemData(wn.grid, row, 2, v[3], false, false)
    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: 33
Na forum: 4535 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8578

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: 25
Na forum: 4185 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 378

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 » jak zrobić zeby działało jak ktos ma skin id 50 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