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

Wysłany: 2023-05-08, 12:14


mis14







Wiek: 25
Na forum: 3924 dni
Posty: 185

Piwa: 73

Respekt: -149

mo?e ?le robi? kod prosz? o naprowadzenie mnie
Kod:

addEvent("wwynikilvl", true)
addEventHandler("wwynikilvl", root, function(id)
local uid=getElementData(source,"player:uid")
if not uid then return end
local result=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE lvl=? LIMIT 25;", id)
if #result > 0 then
triggerClientEvent(client, "wyniki", root, result)
end
end)


addEvent("sprawdzamy", true)
addEventHandler("sprawdzamy", root, function(id)
local uid=getElementData(source,"player:uid")
if not uid then return end
local veh = getPedOccupiedVehicle(source)
local color1, color2, color3 = getVehicleColor (veh, true)
if color1 == 255 and color2 == 255 and color3 == 0 then
triggerClientEvent(client, "sprawdzono", root)
elseif color1 == 255 and color2 == 0 and color3 == 99 then
triggerClientEvent(client, "sprawdzono", root)
elseif color1 == 215 and color2 == 142 and color3 == 16 then
triggerClientEvent(client, "sprawdzono", root)

else
outputChatBox("#629ec6Ⓘ #e7d9b0Tw?j pojazd posiada niew?a?ciwy kolor aby podj?? zlecenie.",source,255,255,0,true) return end
end)


addEvent("taxujemy", true)
addEventHandler("taxujemy", root, function(id,mamona)
local uid=getElementData(source,"player:uid")
if not uid then return end
removeElementData(source,"taxo:wynagrodzenie")

local result=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE id=?", id)
if #result > 0 then
triggerClientEvent(client, "zaczynamy", root)
setElementData(client,"taxo:wynagrodzenie",mamona)
triggerClientEvent(client, "jedziemypozioma", root, result)
end
for i,v in pairs(result) do
v.od=split(v.od,",")
v.cel=split(v.cel,",")
przedzial1 = v.przedzial1
przedzial2 = v.przedzial2
if not result then return end
local od = v.od[1]..","..v.od[2]..","..v.od[3]
local cel = v.cel[1]..","..v.cel[2]..","..v.cel[3]
outputChatBox("#629ec6Ⓘ #e7d9b0Odbierz klienta z #ffb77d"..v.nazwaod,source,255,255,0,true)
setElementData(source,"player:poklienta",true)
exports["db"]:dbSet("DELETE FROM taxo_kursy WHERE id=? AND lvl=? ",id,v.lvl)

local result2=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE id=?", id)
if #result2 > 0 then
return end
local kwota = math.random(tonumber(przedzial1),tonumber(przedzial2))
local ukryty = math.random(0,1)
exports["db"]:dbSet("INSERT taxo_kursy (id,lvl,od,nazwaod,cel,nazwacel,przedzial1,przedzial2,kwota,ukryty) VALUES (?,?,?,?,?,?,?,?,?,?)",id, v.lvl, od, v.nazwaod, cel, v.nazwacel, v.przedzial1, v.przedzial2,kwota,ukryty)
end

end)


local function findFreeSeatInVehicle(veh)
if not veh then return end
if not isElement(veh) then return end
local vp=getVehicleOccupants(veh)
for i=getVehicleMaxPassengers(veh),1,-1 do
if not vp[i] then return i end
end
return nil
end

function getElementSpeed(theElement, unit)
assert(isElement(theElement), "Bad argument 1 @ getElementSpeed (element expected, got " .. type(theElement) .. ")")
local elementType = getElementType(theElement)
assert(elementType == "player" or elementType == "ped" or elementType == "object" or elementType == "vehicle" or elementType == "projectile", "Invalid element type @ getElementSpeed (player/ped/object/vehicle/projectile expected, got " .. elementType .. ")")
assert((unit == nil or type(unit) == "string" or type(unit) == "number") and (unit == nil or (tonumber(unit) and (tonumber(unit) == 0 or tonumber(unit) == 1 or tonumber(unit) == 2)) or unit == "m/s" or unit == "km/h" or unit == "mph"), "Bad argument 2 @ getElementSpeed (invalid speed unit)")
unit = unit == nil and 0 or ((not tonumber(unit)) and unit or tonumber(unit))
local mult = (unit == 0 or unit == "m/s") and 50 or ((unit == 1 or unit == "km/h") and 180 or 111.84681456)
return (Vector3(getElementVelocity(theElement)) * mult).length
end

local function dodajPedaDoAuta(veh,seat)
local taxoped = createPed(math.random(30,90), 0, 0, 3 )
if not taxoped then return end
warpPedIntoVehicle(taxoped, veh, seat)
setElementData(taxoped, "name", "Pasa?er")
setElementData(taxoped,"taxo:ped",true)
end

local function openDoors(veh,seat)
if seat == 0 then
drzwi = 2 elseif seat == 1 then
drzwi = 3 elseif seat == 2 then
drzwi = 4 elseif seat == 3 then
drzwi = 5 end
setVehicleDoorOpenRatio(veh, drzwi, 1, 350)
end

local function lockDoors(veh,seat)
if seat == 0 then
drzwi = 2 elseif seat == 1 then
drzwi = 3 elseif seat == 2 then
drzwi = 4 elseif seat == 3 then
drzwi = 5 end
setVehicleDoorOpenRatio(veh, drzwi, 0, 500)
end


addEvent("sprawdzammiejsca", true)
addEventHandler("sprawdzammiejsca", root, function(id)
local result=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE id=?", id)
if #result > 0 then
end
for i,v in pairs(result) do
v.od=split(v.od,",")
v.cel=split(v.cel,",")
if not result then return end
local veh=getPedOccupiedVehicle(source)
if not veh then return end
local iloscmiejsc = getVehicleMaxPassengers(veh)
local speedkmh = getElementSpeed(veh, "km/h")

iloscgraczywpojezdzie = 0
for i,v in pairs(getVehicleOccupants(veh)) do
if v then
iloscgraczywpojezdzie = iloscgraczywpojezdzie+1
end
end
if speedkmh > 1.5 then
outputChatBox("#629ec6Ⓘ #e7d9b0Zatrzymaj pojazd.",source,255,255,0,true)
return end


if v.lvl == 1 or v.lvl == 2 then
local seat=findFreeSeatInVehicle(veh)
if seat and seat>0 then
dodajPedaDoAuta(veh,seat)
openDoors(veh,seat)
setTimer(function()
lockDoors(veh,seat)
end, 350, 1)
triggerClientEvent(client, "odbieramy", root, result)
else outputChatBox("#629ec6Ⓘ #e7d9b0Aby odebra? klienta potrzebujesz wolnego miejsca w poje?dzie.",source,255,255,0,true) return end
end
if v.lvl == 3 or v.lvl == 4 then
if iloscgraczywpojezdzie>2 then
outputChatBox("#629ec6Ⓘ #e7d9b0Aby odebra? klient?w potrzebujesz wolnych #ffb77d2#e7d9b0 miejsc w poje?dzie.",source,255,255,0,true) return end
local seat=findFreeSeatInVehicle(veh)
if seat and seat>0 then
dodajPedaDoAuta(veh,seat)
openDoors(veh,seat)
setTimer(function()
lockDoors(veh,seat)
end, 350, 1)
end
local seat2=findFreeSeatInVehicle(veh)
if seat2 and seat2>0 then
dodajPedaDoAuta(veh,seat2)
openDoors(veh,seat2)
setTimer(function()
lockDoors(veh,seat2)
end, 350, 1)
triggerClientEvent(client, "odbieramy", root, result)
end

end
end
end)





addEvent("odebrano", true)
addEventHandler("odebrano", root, function(id)
local result=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE id=?", id)
if #result > 0 then
triggerClientEvent(client, "jedziemyzziomem", root, result)
end
for i,v in pairs(result) do
v.od=split(v.od,",")
v.cel=split(v.cel,",")
if not result then return end
local veh = getPedOccupiedVehicle(source)
local skm = getElementData(veh, "vehicle:mileage")
outputChatBox("#629ec6Ⓘ #e7d9b0Zabierz klienta do #ffb77d"..v.nazwacel,source,255,255,0,true)
removeElementData(source,"player:poklienta")
setElementData(source,"player:zklientem",true)
setElementData(source,"player:skm", skm)
end
end)



addEvent("oddano", true)
addEventHandler("oddano", root, function(id)
local result=exports["db"]:dbGet("SELECT * FROM taxo_kursy WHERE id=?", id)
if #result > 0 then
end
for i,v in pairs(result) do
v.od=split(v.od,",")
v.cel=split(v.cel,",")
local kwota= getElementData(source,"taxo:wynagrodzenie")
if not result then return end
local veh = getPedOccupiedVehicle(source)
local stan = getElementHealth(veh)
local premia = stan - 750
local kkm = getElementData(veh, "vehicle:mileage")
local sskm = getElementData(source,"player:skm")
local mkm = getElementData(source,"player:taxokm")
local uid = getElementData(source,"player:uid")
local wkm = kkm - sskm
if premia > 0 then

local hajs = (premia*0.4/100*0.25)
local bonus = kwota*hajs
outputChatBox("#87b87f✔ #e7d9b0Otrzymujesz #ffb77d"..string.format("%.2f",kwota/100).."€#e7d9b0 za kurs + #ffb77d"..string.format("%.2f",bonus/100).."€#e7d9b0 napiwku.",source,255,255,0,true)
outputChatBox(inspect(getElementData(source, "player:money")))
setElementData(source,"player:money",getElementData(source,"player:money")+kwota)
setElementData(source,"player:money",getElementData(source,"player:money")+bonus)

removeElementData(source,"player:zklientem")
else
outputChatBox("#87b87f✔ #e7d9b0Otrzymujesz #ffb77d"..string.format("%.2f",kwota/100).."€#e7d9b0 za kurs.",source,255,255,0,true)
setElementData(source,"player:money",getElementData(source,"player:money")+kwota)
removeElementData(source,"player:zklientem")
removeElementData(source,"taxo:wynagrodzenie")
end


if wkm > 30 then
wkm = 30 end

local wynik = mkm + wkm

exports['db']:dbSet("UPDATE nw_users SET taxokm=? WHERE id=?", wynik, uid)
removeElementData(source,"player:taxokm")
removeElementData(source,"player:skm")
setElementData(source,"player:taxokm",wynik)
veh=getPedOccupiedVehicle(source)
for seat, occupant in pairs(getVehicleOccupants(veh)) do

if getElementData(occupant,"taxo:ped") == true then

destroyElement(occupant)
openDoors(veh,seat)
setTimer(function()
lockDoors(veh,seat)
end, 350, 1)
end
end
end
end)


setTimer(function()
for i,v in pairs(getElementsByType("ped")) do
if getElementData(v,"taxo:ped") == true then
if getPedOccupiedVehicle(v) then return end
destroyElement(v)
end
end
end, 60000*3.5, 0)


addEvent("anulujzlecenie", true)
addEventHandler("anulujzlecenie", root, function(id)
local uid=getElementData(source,"player:uid")
if not uid then return end
if getElementData(source,"player:poklienta") then
removeElementData(source,"player:poklienta")
removeElementData(source,"taxo:wynagrodzenie")
triggerClientEvent(client, "niemamklienta", root, result) end
if getElementData(source,"player:zklientem") then
removeElementData(source,"player:zklientem")
removeElementData(source,"taxo:wynagrodzenie")
triggerClientEvent(client, "mamklienta", root)

end
end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2023-05-10, 18:59


kubax360







Wiek: 17
Na forum: 2103 dni
Posty: 2
Nick w MP: KubaX

Piwa: 293

Respekt: 50

Cze??, wystarczy lekko zmodyfikowa? kod od funkcji tworzenia peda, oraz utworzy? funkcj? od usuwania go, kt?r? mo?esz u?y? w potrzebnym momencie. Je?li nadal wyst?puje jaki? problem, mo?esz pisa?

Kod:


local function usunPedyZAuta(vehicle)
if not isElement(vehicle) or not getElementType(vehicle)=='vehicle' then return end --Sprawdzamy czy podana warto?? jest pojazdem.
local ped = getElementData(vehicle,'taxo:ped') -- Pobieramy peda z element daty.
if not isElement(ped) then return end -- Sprawdzamy czy ped istnieje
destroyElement(ped)
end

local function dodajPedaDoAuta(veh,seat)
local taxoped = createPed(math.random(30,90), 0, 0, 3 )
if not taxoped then return end
warpPedIntoVehicle(taxoped, veh, seat)
setElementData(taxoped, "name", "Pasa?er")
setElementData(taxoped,"taxo:ped",true)
setElementData(veh,"taxo:ped",taxoped) -- Ustawiamy zmienn? na pojazd, kt?ra okre?la jaki ped si? w nim znajduje.
end


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: brak :: usuwania :: ped :: pojazdu :: anulowaniu :: kursu
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Odpowiedz do tematu

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