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

Wysłany: 2014-08-07, 15:16


Mizy1999

I <3 Mta






Wiek: 28
Na forum: 4995 dni
Posty: 157
Nick w MP: xxx

Piwa: 154

Respekt: 40

Witam drogich forum'owiczy,

Prosz? was o podanie funkcji dzi?ki kt?rym by? bym w stanie zrobi? kod odnosz?cy si? do oferowania naprawy pojazdu za pomoc? komendy /napraw gracz cena, nast?pnie gracz ten kt?remu kto? zaoferowa? mo?e wpisa? /akceptujnaprawe, auto by si? naprawi?o a pieni??ki da?y mechanikowi. Prosz? o funkcje, co? z nich z?o?? dalsze kroki przelej? na forum.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-07, 16:16


McDeKi







Wiek: 28
Na forum: 4844 dni
Posty: 95
Nick w MP: McDeKi

Piwa: 186

Respekt: 60


function WyslijRequestDlaGraczaWysylajacyKomendaGraczCena ) 
    if not Gracz == nil then
        if not Cena == nil then
            if type(Cena) == "number" then
                if not getPlayerFromNameGracz ) == false then
                    if getPlayerMoneygetPlayerFromNameGracz ) ) > Cena then
                    local XYgetElementPositiongetPlayerFromNameGracz ) )
                    local X2Y2Z2 getElementPositionWysylajacy )
                        if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then
                            if getElementDatagetPlayerFromNameGracz ), "ChceNaprawic" ) == false then
                            outputChatBox("Mechanik o nicku "..Wysylajacy.." chce naprawic twoje auto, cena: "..Cena.." wpisz /akceptujnaprawe, aby zaakceptowac."getPlayerFromName(Gracz))
                            local timer setTimer(function() setElementData(getPlayerFromNameGracz ), "ChceNaprawic"false end120000) -- po 2 minutach resetujemy
                            setElementData(getPlayerFromNameGracz ), "ChceNaprawic", {WysylajacyCenaTimer} )
                            XYnil
                            X2Y2Z2  nil
                        else
                        outputChatBox("Osoba ju? dostala prosbe naprawy."Wysylajacy)
                        end
                        else
                        outputChatBox("Jestes za daleko."Wysylajacy)
                        XYnil
                        X2Y2Z2  nil
                        end
                    else
                    outputChatBox("Gracz nie ma wystarczajacej gotowki."Wysylajacy)
                    end
                else
                outputChatBox("Podany gracz jest nieprawidlowy."Wysylajacy)
                end
            else
            end
        else
        outputChatBox("Wpisz cene."Wysylajacy)
        end
    else
    outputChatBox("Podaj gracza."Wysylajacy)
    end
end    
addCommandHandler("napraw"WyslijRequestDlaGracza)

function zaakceptujRequestWysylajacyKomenda )
    if not getPedOccupiedVehicle Wysylajacy ) == false then
        if not getElementDataWysylajacy"ChceNaprawic" ) == false then
            if ( getElementDataWysylajacy"ChceNaprawic" )[2] < getPlayerMoney(Wysylajacy)) then
            local XYgetElementPositiongetElementDatagetPlayerFromNameGracz ), "ChceNaprawic") )
            local X2Y2Z2 getElementPositionWysylajacy )
                if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then
                fixVehicle(getPedOccupiedVehicle Wysylajacy ))
                givePlayerMoney getElementDataWysylajacy"ChceNaprawic" )[1], getElementDataWysylajacy"ChceNaprawic" )[2] )
                killTimer(getElementDataWysylajacy"ChceNaprawic" )[3])
                setElementDataWysylajacy"ChceNaprawic"false)
                XYnil
                X2Y2Z2  nil
                else
                outputChatBox("Jestes za daleko od mechanika."Wysylajacy)
                XYnil
                X2Y2Z2  nil
                end
            else
            outputChatBox("Nie masz wystarczajacej gotowki."Wysylajacy)
            end
        else
        outputChatBox("Nikt nie chce naprawic twojego auta."Wysylajacy)
        end
    else
    outputChatBox("Musisz siedziec w aucie."Wysylajacy)
    end
end    
addCommandHandler("akceptujnaprawe",     zaakceptujRequest)

Edit: dodalem dystans, nie testowalem.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-07, 18:14


Mizy1999

I <3 Mta






Wiek: 28
Na forum: 4995 dni
Posty: 157
Nick w MP: xxx

Piwa: 154

Respekt: 40

Wci?nij mi w to sprawdzanie czy gracz jest w acl, przyczynisz si? do kolejnych +5 % ;D Wynagrodz? 10 rep, max piffkami ;P

Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-07, 18:59


McDeKi







Wiek: 28
Na forum: 4844 dni
Posty: 95
Nick w MP: McDeKi

Piwa: 186

Respekt: 60

Nigdy nie u?ywa?em ACl, ale powinno by? dobrze + naprawi?em wszystkie bugi + doda?em, ?e nie mo?esz samemu sobie naprawia? auta.


function WyslijRequestDlaGraczaWysylajacyKomendaGraczCena ) 
if isObjectInACLGroup ("user."..getAccountName getPlayerAccount Wysylajacy ) ), aclGetGroup "NazwaGrupy" ) ) then
    if not Gracz == nil then
        if not Cena == nil then
            if not (tonumber(Cena) == nilthen
                if not getPlayerFromNameGracz ) == false then
                    if not getPlayerFromNameGracz ) == Wysylajacy then
                         if getPlayerMoneygetPlayerFromNameGracz ) ) >= tonumber(Cenathen
                      local XYgetElementPositiongetPlayerFromNameGracz ) )
                      local X2Y2Z2 getElementPositionWysylajacy )
                        if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then
                            if getElementDatagetPlayerFromNameGracz ), "ChceNaprawic" ) == false then
                            outputChatBox("Mechanik o nicku "..getPlayerName(Wysylajacy).." chce naprawic twoje auto, cena: "..Cena.." wpisz /akceptujnaprawe, aby zaakceptowac."getPlayerFromName(Gracz))
                            local timer setTimer(function() setElementData(getPlayerFromNameGracz ), "ChceNaprawic"false end120000) -- po 2 minutach resetujemy
                            setElementData(getPlayerFromNameGracz ), "ChceNaprawic", {Wysylajacytonumber(Cena), timer} )
                            XYnil
                            X2Y2Z2  nil
                        else
                        outputChatBox("Osoba ju? dostala prosbe naprawy."Wysylajacy)
                        end
                        else
                        outputChatBox("Jestes za daleko."Wysylajacy)
                        XYnil
                        X2Y2Z2  nil
                        end
                    else
                    outputChatBox("Gracz nie ma wystarczajacej gotowki."Wysylajacy)
                    end
                    else
                    outputChatBox("Nie mozesz naprawic swojego auta."Wysylajacy)
                    end
                else
                outputChatBox("Podany gracz jest nieprawidlowy."Wysylajacy)
                end
            else
            end
        else
        outputChatBox("Wpisz cene."Wysylajacy)
        end
    else
    outputChatBox("Podaj gracza."Wysylajacy)
    end
    else
    outputChatBox("Nie jestes w ACL."Wysylajacy)
    end
end    
addCommandHandler("napraw"WyslijRequestDlaGracza)

function zaakceptujRequestWysylajacyKomenda )
    if not getPedOccupiedVehicle Wysylajacy ) == false then
        if not getElementDataWysylajacy"ChceNaprawic" ) == false then
            if ( getElementDataWysylajacy"ChceNaprawic" )[2] <= getPlayerMoney(Wysylajacy)) then
            local XYgetElementPositiongetElementDataWysylajacy"ChceNaprawic")[1] )
            local X2Y2Z2 getElementPositionWysylajacy )
                if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then
                fixVehicle(getPedOccupiedVehicle Wysylajacy ))
                outputChatBox(getPlayerMoney(Wysylajacy))
                takePlayerMoneyWysylajacygetElementDataWysylajacy"ChceNaprawic" )[2])
                givePlayerMoney getElementDataWysylajacy"ChceNaprawic" )[1], getElementDataWysylajacy"ChceNaprawic" )[2] )
                killTimer(getElementDataWysylajacy"ChceNaprawic" )[3])
                setElementDataWysylajacy"ChceNaprawic"false)
                XYnil
                X2Y2Z2  nil
                else
                outputChatBox("Jestes za daleko od mechanika."Wysylajacy)
                XYnil
                X2Y2Z2  nil
                end
            else
            outputChatBox("Nie masz wystarczajacej gotowki."Wysylajacy)
            end
        else
        outputChatBox("Nikt nie chce naprawic twojego auta."Wysylajacy)
        end
    else
    outputChatBox("Musisz siedziec w aucie."Wysylajacy)
    end
end    
addCommandHandler("akceptujnaprawe"zaakceptujRequest)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-07, 22:24


Mizy1999

I <3 Mta






Wiek: 28
Na forum: 4995 dni
Posty: 157
Nick w MP: xxx

Piwa: 154

Respekt: 40

Okej, dobra dzia?a?o, ale doda?em kilka urozmaice?, kolory itd, ponadto wywala ?e musz? poczeka? troch?, a db3 ?adne xD. Ju? daje te repy, by nie by?o ?e k?ama?em xd.
Kod:

function WyslijRequestDlaGracza( Wysylajacy, Komenda, Gracz, Cena )
if isObjectInACLGroup ("user."..getAccountName ( getPlayerAccount ( Wysylajacy ) ), aclGetGroup ( "Fcmc" ) ) then
if not ( Gracz == nil ) then
if not ( Cena == nil ) then
if not (tonumber(Cena) == nil) then
if not ( getPlayerFromName( Gracz ) == false ) then
if not ( getPlayerFromName( Gracz ) == Wysylajacy ) then
if getPlayerMoney( getPlayerFromName( Gracz ) ) >= tonumber(Cena) then
local X, Y, Z = getElementPosition( getPlayerFromName( Gracz ) )
local X2, Y2, Z2 = getElementPosition( Wysylajacy )
if getDistanceBetweenPoints3D(X, Y, Z, X2, Y2, Z2 ) < 10 then
if getElementData( getPlayerFromName( Gracz ), "ChceNaprawic" ) == false then
outputChatBox("[Oferta] Mechanik "..getPlayerName(Wysylajacy).." chce naprawic twoje auto, cena: "..Cena.." wpisz /akceptujnaprawe, aby zaakceptowac.", getPlayerFromName(Gracz), 0, 150, 0)
local timer = setTimer(function() setElementData(getPlayerFromName( Gracz ), "ChceNaprawic", false ) end, 120000, 1 ) -- po 2 minutach resetujemy
setElementData(getPlayerFromName( Gracz ), "ChceNaprawic", {Wysylajacy, tonumber(Cena), timer} )
X, Y, Z = nil
X2, Y2, Z2 = nil
else
outputChatBox("[Info] Osobie tej niedawno oferowa?e? napraw?, poczekaj troch? z kolejn?.", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Jeste? za daleko od gracza.", Wysylajacy, 150, 0, 0)
X, Y, Z = nil
X2, Y2, Z2 = nil
end
else
outputChatBox("[Info] Gracz kt?remu oferowa?e? napraw? jest od ciebi? za daleko, podejd? bli?ej.", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Niestety, lecz nie mo?esz naprawi? swojego auta!", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Podany gracz jest nieprawid?owy spr?buj ponownie!", Wysylajacy, 150, 0, 0)
end
else
end
else
outputChatBox("[Info] Wpisz kwot? za kt?r? chcesz naprawi? danemu graczu pojazd.", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Podaj gracza kt?remu chcesz zaoferowa? napraw?.", Wysylajacy)
end
else
outputChatBox("[B??d] Nie jeste? pracownikiem Fort Carson Mechanic Center by naprawia? pojazdy.", Wysylajacy, 150, 0, 0)
end
end
addCommandHandler("napraw", WyslijRequestDlaGracza)

function zaakceptujRequest( Wysylajacy, Komenda )
if not ( getPedOccupiedVehicle ( Wysylajacy ) == false ) then
if not ( getElementData( Wysylajacy, "ChceNaprawic" ) == false ) then
if ( getElementData( Wysylajacy, "ChceNaprawic" )[2] <= getPlayerMoney(Wysylajacy)) then
local X, Y, Z = getElementPosition( getElementData( Wysylajacy, "ChceNaprawic")[1] )
local X2, Y2, Z2 = getElementPosition( Wysylajacy )
if getDistanceBetweenPoints3D(X, Y, Z, X2, Y2, Z2 ) < 10 then
fixVehicle(getPedOccupiedVehicle ( Wysylajacy ))
outputChatBox("[Uwaga] Naprawi?e? pojazd, dosta?e? kwot? pieni??n? kt?r? z?o?y?e? w ofercie",Wysylajacy)
takePlayerMoney( Wysylajacy, getElementData( Wysylajacy, "ChceNaprawic" )[2])
givePlayerMoney ( getElementData( Wysylajacy, "ChceNaprawic" )[1], getElementData( Wysylajacy, "ChceNaprawic" )[2] )
killTimer(getElementData( Wysylajacy, "ChceNaprawic" )[3])
setElementData( Wysylajacy, "ChceNaprawic", false)
X, Y, Z = nil
X2, Y2, Z2 = nil
else
outputChatBox("[Info] Jeste? za daleko od mechanika oferuj?cego ci napraw?.", Wysylajacy, 150, 0, 0)
X, Y, Z = nil
X2, Y2, Z2 = nil
end
else
outputChatBox("[Info] Nie posiadasz wystarczaj?cej ilo?ci got?wki.", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Nikt nie oferowa? ci naprawy.", Wysylajacy, 150, 0, 0)
end
else
outputChatBox("[Info] Musisz znajdowa? si? w poje?dzie by akceptowa? napraw?.", Wysylajacy, 150, 0, 0)
end
end
addCommandHandler("akceptujnaprawe", zaakceptujRequest)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2014-08-07, 22:51


McDeKi







Wiek: 28
Na forum: 4844 dni
Posty: 95
Nick w MP: McDeKi

Piwa: 186

Respekt: 60


function WyslijRequestDlaGraczaWysylajacyKomendaGraczCena ) 
    if isObjectInACLGroup ("user."..getAccountName getPlayerAccount Wysylajacy ) ), aclGetGroup "Fcmc" ) ) then
        if not Gracz == nil then 
            if not Cena == nil then 
                if not (tonumber(Cena) == nilthen 
                    if not getPlayerFromNameGracz ) == false then 
                        if not getPlayerFromNameGracz ) == Wysylajacy then 
                            if getPlayerMoneygetPlayerFromNameGracz ) ) >= tonumber(Cenathen 
                            local XYgetElementPositiongetPlayerFromNameGracz ) ) 
                            local X2Y2Z2 getElementPositionWysylajacy ) 
                                if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then 
                                    if getElementDatagetPlayerFromNameGracz ), "ChceNaprawic" ) == nil then 
                                    outputChatBox("[Oferta] Mechanik "..getPlayerName(Wysylajacy).." chce naprawic twoje auto, cena: "..Cena.." wpisz /akceptujnaprawe, aby zaakceptowac."getPlayerFromName(Gracz), 01500) 
                                    local timer setTimer(function() setElementData(getPlayerFromNameGracz ), "ChceNaprawic"nil end120000) -- po 2 minutach resetujemy 
                                    setElementData(getPlayerFromNameGracz ), "ChceNaprawic", {Wysylajacytonumber(Cena), timer} ) 
                                    XYnil 
                                    X2Y2Z2 nil 
                                else
                                outputChatBox("[Info] Osobie tej niedawno oferowa?e? napraw?, poczekaj troch? z kolejn?."Wysylajacy15000)
                                end 
                            else 
                            outputChatBox("[Info] Jeste? za daleko od gracza."Wysylajacy15000) 
                            XYnil 
                            X2Y2Z2 nil 
                        end 
                        else  --//Gracz nie ma wystarczajcej ilosci gotowki
                        outputChatBox("[Info] Gracz kt?remu oferowa?e? napraw? jest od ciebi? za daleko, podejd? bli?ej."Wysylajacy15000) 
                        end 
                    else 
                    outputChatBox("[Info] Niestety, lecz nie mo?esz naprawi? swojego auta!"Wysylajacy15000) 
                    end 
                else 
                outputChatBox("[Info] Podany gracz jest nieprawid?owy spr?buj ponownie!"Wysylajacy15000) 
                end 
            else
            --//Tonumber zwrocil nil, czyli string zawieral litery
            end 
        else 
        outputChatBox("[Info] Wpisz kwot? za kt?r? chcesz naprawi? danemu graczu pojazd."Wysylajacy15000) 
        end 
    else 
    outputChatBox("[Info] Podaj gracza kt?remu chcesz zaoferowa? napraw?."Wysylajacy) 
    end 
   else 
   outputChatBox("[B??d] Nie jeste? pracownikiem Fort Carson Mechanic Center by naprawia? pojazdy."Wysylajacy15000) 
   end 
end 
addCommandHandler("napraw"WyslijRequestDlaGracza) 

function zaakceptujRequestWysylajacyKomenda ) 
    if not getPedOccupiedVehicle Wysylajacy ) == false then 
        if not getElementDataWysylajacy"ChceNaprawic" ) == nil then 
            if ( getElementDataWysylajacy"ChceNaprawic" )[2] <= getPlayerMoney(Wysylajacy)) then 
            local XYgetElementPositiongetElementDataWysylajacy"ChceNaprawic")[1] ) 
            local X2Y2Z2 getElementPositionWysylajacy ) 
                if getDistanceBetweenPoints3D(XYZX2Y2Z2 ) < 10 then 
                fixVehicle(getPedOccupiedVehicle Wysylajacy )) 
                outputChatBox("[Uwaga] Naprawi?e? pojazd, dosta?e? kwot? pieni??n? kt?r? z?o?y?e? w ofercie"getElementDataWysylajacy"ChceNaprawic" )[1]) --//Nie wysylasz tego do wykonawcy komendy tylko do mechanika
                takePlayerMoneyWysylajacygetElementDataWysylajacy"ChceNaprawic" )[2]) 
                givePlayerMoney getElementDataWysylajacy"ChceNaprawic" )[1], getElementDataWysylajacy"ChceNaprawic" )[2] ) 
                killTimer(getElementDataWysylajacy"ChceNaprawic" )[3]) 
                setElementDataWysylajacy"ChceNaprawic"nil) 
                XYnil 
                X2Y2Z2 nil 
            else 
            outputChatBox("[Info] Jeste? za daleko od mechanika oferuj?cego ci napraw?."Wysylajacy15000) 
            XYnil 
            X2Y2Z2 nil 
            end 
        else 
        outputChatBox("[Info] Nie posiadasz wystarczaj?cej ilo?ci got?wki."Wysylajacy15000) 
        end 
    else 
    outputChatBox("[Info] Nikt nie oferowa? ci naprawy."Wysylajacy15000) 
    end 
   else 
   outputChatBox("[Info] Musisz znajdowa? si? w poje?dzie by akceptowa? napraw?."Wysylajacy15000) 
   end 
end 
addCommandHandler("akceptujnaprawe"zaakceptujRequest)

addEventHandler "onResourceStop"resourceRoot, --//Zasob zostal zatrzymany, zmieniamy element data na nil
    function (  )
        for kv in ipairs(getElementsByType "player" )) do
        setElementData(v"ChceNaprawic"nil)
    end
end    
)


EDIT: Poprawilem maly blad.

Postaw piwo autorowi tego posta
 

 
Tagi: /napraw
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