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
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.
Wysłany: 2014-08-07, 16:16
McDeKi
Wiek: 28 Na forum: 4844 dni Posty: 95
Nick w MP: McDeKi
Piwa : 186
function WyslijRequestDlaGracza ( Wysylajacy , Komenda , Gracz , Cena )
if not ( Gracz == nil ) then
if not ( Cena == nil ) then
if type ( Cena ) == "number" then
if not ( getPlayerFromName ( Gracz ) == false ) then
if getPlayerMoney ( getPlayerFromName ( Gracz ) ) > 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 ( "Mechanik o nicku " .. Wysylajacy .. " chce naprawic twoje auto, cena: " .. Cena .. " wpisz /akceptujnaprawe, aby zaakceptowac." , getPlayerFromName ( Gracz ))
local timer = setTimer (function() setElementData ( getPlayerFromName ( Gracz ), "ChceNaprawic" , false ) end , 120000 , 1 ) -- po 2 minutach resetujemy
setElementData ( getPlayerFromName ( Gracz ), "ChceNaprawic" , { Wysylajacy , Cena , Timer } )
X , Y , Z = nil
X2 , Y2 , Z2 = nil
else
outputChatBox ( "Osoba ju? dostala prosbe naprawy." , Wysylajacy )
end
else
outputChatBox ( "Jestes za daleko." , Wysylajacy )
X , Y , Z = nil
X2 , Y2 , Z2 = 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 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 ( getPlayerFromName ( Gracz ), "ChceNaprawic" ) )
local X2 , Y2 , Z2 = getElementPosition ( Wysylajacy )
if getDistanceBetweenPoints3D ( X , Y , Z , X2 , Y2 , Z2 ) < 10 then
fixVehicle ( getPedOccupiedVehicle ( Wysylajacy ))
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 ( "Jestes za daleko od mechanika." , Wysylajacy )
X , Y , Z = nil
X2 , Y2 , Z2 = 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.
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
Wci?nij mi w to sprawdzanie czy gracz jest w acl, przyczynisz si? do kolejnych +5 % ;D Wynagrodz? 10 rep, max piffkami
Wysłany: 2014-08-07, 18:59
McDeKi
Wiek: 28 Na forum: 4844 dni Posty: 95
Nick w MP: McDeKi
Piwa : 186
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 WyslijRequestDlaGracza ( Wysylajacy , Komenda , Gracz , Cena )
if isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( Wysylajacy ) ), aclGetGroup ( "NazwaGrupy" ) ) 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 ( "Mechanik o nicku " .. getPlayerName ( Wysylajacy ).. " chce naprawic twoje auto, cena: " .. Cena .. " wpisz /akceptujnaprawe, aby zaakceptowac." , getPlayerFromName ( Gracz ))
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 ( "Osoba ju? dostala prosbe naprawy." , Wysylajacy )
end
else
outputChatBox ( "Jestes za daleko." , Wysylajacy )
X , Y , Z = nil
X2 , Y2 , Z2 = 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 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 ( getPlayerMoney ( 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 ( "Jestes za daleko od mechanika." , Wysylajacy )
X , Y , Z = nil
X2 , Y2 , Z2 = 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 )
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
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)
Wysłany: 2014-08-07, 22:51
McDeKi
Wiek: 28 Na forum: 4844 dni Posty: 95
Nick w MP: McDeKi
Piwa : 186
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" ) == nil 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" , nil ) 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 -- //Gracz nie ma wystarczajcej ilosci gotowki
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
-- //Tonumber zwrocil nil, czyli string zawieral litery
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" ) == nil ) 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" , getElementData ( Wysylajacy , "ChceNaprawic" )[ 1 ]) -- //Nie wysylasz tego do wykonawcy komendy tylko do mechanika
takePlayerMoney ( Wysylajacy , getElementData ( Wysylajacy , "ChceNaprawic" )[ 2 ])
givePlayerMoney ( getElementData ( Wysylajacy , "ChceNaprawic" )[ 1 ], getElementData ( Wysylajacy , "ChceNaprawic" )[ 2 ] )
killTimer ( getElementData ( Wysylajacy , "ChceNaprawic" )[ 3 ])
setElementData ( Wysylajacy , "ChceNaprawic" , nil )
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 )
addEventHandler ( "onResourceStop" , resourceRoot , -- //Zasob zostal zatrzymany, zmieniamy element data na nil
function ( )
for k , v in ipairs ( getElementsByType ( "player" )) do
setElementData ( v , "ChceNaprawic" , nil )
end
end
)
EDIT: Poprawilem maly blad.
Tagi: /napraw
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: