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

Wysłany: 2019-04-25, 23:44


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot??, gdy rozpoczynam prac? nie daje mi kosiarki, oto b??d
db3
https://imgur.com/ba0wH0z
c.lua
--[[
    AutorMalentas
]]
 
local sxsy guiGetScreenSize()
local okno1 false
local ulepszenia false

local dostal_powiadomienie false;
 
local pracodawca createPed(16773.27, -1305.9413.560)
setElementData(pracodawca"name""Pracodawca")
setElementDimension(pracodawca0)
setElementFrozen(pracodawcatrue)
local rozpoczecie createMarker(773.18, -1304.6613.56-.95"cylinder"1255255255)
setElementData(rozpoczecie"praca"true)
setElementDimension(rozpoczecie0)
 
 
addEventHandler("onClientMarkerHit"rozpoczecie, function(gracz)
    if gracz ~= localPlayer then return end
    if getPedOccupiedVehicle(localPlayerthen return end
    if getElementData(localPlayer"pracuje"then
        if getElementData(localPlayer"pracuje") ~= "kosiarki" then exports["np-notyfikacje"]:noti("Posiadasz inn? aktywn? prace!""error") return end
    end
    addEventHandler("onClientRender"rootguistart)
    okno1 true
    showCursor(true)
    triggerServerEvent("pokazTopke:kosiarki:source"localPlayer)
end)
 
local font dxCreateFont("cz.ttf"10)
local font2 dxCreateFont("cz.ttf"12)
 
local font dxCreateFont("cz.ttf"10)
local font2 dxCreateFont("cz.ttf"12)
 
local pracownicy = { }
 
local listaulepszen = {
    {"Pojemniejsza kosiarka""Dzi?ki temu twoja kosiarka ma wieksz? pojemno?? kosza"500"dolar.png"},
    {"Zarobek +5%""Dzi?ki temu ulepszeniu zarabiasz wi?cej o 5%"700"dolar.png"},
}
 
 
function guistart()
    dxDrawImage(scale_x(402), scale_y(251), scale_x(637), scale_y(399), ":np-gui/grafiki/tlo.png"000tocolor(255255255255), false)
    if ulepszenia == false then
       local punkty getElementData(localPlayer"kospunkty") or 0
       local zlecenia getElementData(localPlayer"koszlecenia") or 0
        shadowText("Praca piel?gnowania trawnika"scale_x(401), scale_y(251), scale_x(1039), scale_y(295), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        --shadowText("Wymagania:\nBRAK"scale_x(401), scale_y(295), scale_x(719), scale_y(449), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        shadowText("Wykonane zlecenia: "..zlecenia.."\nPunkty: "..punkty..""scale_x(402), scale_y(510), scale_x(719), scale_y(646), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        shadowText("Top pracownicy:"scale_x(719), scale_y(295), scale_x(1036), scale_y(329), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        dxDrawImage(scale_x(415), scale_y(310), scale_x(304), scale_y(175), ":np-magazynier/grafiki/bg4.png"000tocolor(255255255255), false)
        shadowText("Wymagania: brak"scale_x(415), scale_y(500), scale_x(719), scale_y(548), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        if mysz(scale_x(889), scale_y(592), scale_x(139), scale_y(44)) then
           dxDrawImage(scale_x(889), scale_y(592), scale_x(139), scale_y(44), ":np-gui/grafiki/button_on.png"000tocolor(255255255255), false)
        else
           dxDrawImage(scale_x(889), scale_y(592), scale_x(139), scale_y(44), ":np-gui/grafiki/button_off.png"000tocolor(255255255255), false)
        end
        if mysz(scale_x(729), scale_y(592), scale_x(139), scale_y(44)) then
           dxDrawImage(scale_x(729), scale_y(592), scale_x(139), scale_y(44), ":np-gui/grafiki/button_on.png"000tocolor(255255255255), false)
        else
           dxDrawImage(scale_x(729), scale_y(592), scale_x(139), scale_y(44), ":np-gui/grafiki/button_off.png"000tocolor(255255255255), false)
        end
        if getElementData(localPlayer"pracuje") == "kosiarki" then
           shadowText("Zako?cz prace"scale_x(728), scale_y(591), scale_x(868), scale_y(636), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        else
           shadowText("Rozpocznij prace"scale_x(728), scale_y(591), scale_x(868), scale_y(636), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        end
        shadowText("Ulepszenia"scale_x(888), scale_y(592), scale_x(1028), scale_y(637), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        dxDrawImage(scale_x(1010), scale_y(261), scale_x(16), scale_y(16), ":guieditor/images/cross.png"000tocolor(255255255255), false)
        shadowText("Nickname:"scale_x(729), scale_y(329), scale_x(880), scale_y(363), tocolor(255255255255), 1.00font"center""center"falsefalsefalsefalsefalse)
        shadowText("Skoszone pola:"scale_x(877), scale_y(329), scale_x(1028), scale_y(363), tocolor(255255255255), 1.00font"center""center"falsefalsefalsefalsefalse)
 
        for iv in ipairs(pracownicy) do
           local dodatekY = (scale_y(37))*(i-1)
           local dodatekY2 = (scale_y(74))*(i-1)
 
           dxDrawRectangle(scale_x(729), scale_y(363) + dodatekYscale_x(299), scale_y(35), tocolor(000120), false)
           shadowText(v.nickscale_x(729), scale_y(364) + dodatekY2scale_x(877), scale_y(398), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
           shadowText(v.liczbascale_x(880), scale_y(364) + dodatekY2scale_x(1028), scale_y(398), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        end
    else
        local punkty getElementData(localPlayer"kospunkty") or 0
        shadowText("Kupno ulepszen"scale_x(401), scale_y(251), scale_x(1039), scale_y(295), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        dxDrawImage(scale_x(1011), scale_y(262), scale_x(16), scale_y(16), ":np-gui/grafiki/cofnij.png"000tocolor(255255255255), false)
        dxDrawText("Posiadasz: "..punkty.." punkt?w"scale_x(402), scale_y(582), scale_x(1037), scale_y(648), tocolor(02550255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        for iv in ipairs(listaulepszen) do
            local dodatekY = (scale_y(72))*(i-1)
            local dodatekY2 = (scale_y(144))*(i-1)
 
            dxDrawRectangle(scale_x(417), scale_y(297)+dodatekYscale_x(610), scale_y(70), tocolor(000120), false)
            dxDrawImage(scale_x(432), scale_y(307)+dodatekYscale_x(50), scale_y(50), ":np-magazynier/grafiki/"..v[4]..""000tocolor(255255255255), false)
            shadowText(v[1], scale_x(501), scale_y(297)+dodatekY2scale_x(874), scale_y(332), tocolor(255255255255), 1.00font2"left""center"falsefalsefalsefalsefalse)
            shadowText(v[2], scale_x(501), scale_y(332)+dodatekY2scale_x(874), scale_y(367), tocolor(255255255255), 1.00font"left""center"falsefalsefalsefalsefalse)
            if mysz(scale_x(904), scale_y(312)+dodatekYscale_x(113), scale_y(38)) then
                dxDrawImage(scale_x(904), scale_y(312)+dodatekYscale_x(113), scale_y(38), ":np-gui/grafiki/button_on.png"000tocolor(255255255255), false)
            else
                dxDrawImage(scale_x(904), scale_y(312)+dodatekYscale_x(113), scale_y(38), ":np-gui/grafiki/button_off.png"000tocolor(255255255255), false)
            end
            shadowText("Zakup"scale_x(904), scale_y(312)+dodatekY2scale_x(1017), scale_y(350), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
            shadowText("Cena: "..v[3].."p"scale_x(781), scale_y(297)+dodatekY2scale_x(894), scale_y(335), tocolor(255255255255), 1.00font2"center""center"falsefalsefalsefalsefalse)
        end
    end
end
 
addEventHandler("onClientClick"root, function(btnstate)
  if btn == "left" and state == "down" then
    if mysz(scale_x(729), scale_y(592), scale_x(139), scale_y(44)) and okno1 == true and ulepszenia == false then
        if getElementData(localPlayer"pracuje") == "kosiarki" then
            zakonczprace()
        else
            rozpocznijprace()
        end
    elseif mysz(scale_x(889), scale_y(592), scale_x(139), scale_y(44)) and okno1 == true and ulepszenia == false then
        ulepszenia true
    elseif mysz(scale_x(1010), scale_y(261), scale_x(16), scale_y(16)) and okno1 == true and ulepszenia == false then
        removeEventHandler("onClientRender"rootguistart)
        okno1 false
        showCursor(false)
    elseif mysz(scale_x(1011), scale_y(262), scale_x(16), scale_y(16)) and okno1 == true and ulepszenia == true then
        ulepszenia false
    end
    for iv in ipairs(listaulepszen) do
        local dodatekY = (scale_y(72))*(i-1)
        if mysz(scale_x(904), scale_y(312)+dodatekYscale_x(113), scale_y(38)) and okno1 == true and ulepszenia == true then
            local punkty getElementData(localPlayer"kospunkty") or 0
            if punkty tonumber(v[3]) then exports["np-notyfikacje"]:noti("Posiadasz za ma?o punkt?w by zakupi? to ulepszenie""error") return end
            if v[1] == "Pojemniejsza kosiarka" then
                if getElementData(localPlayer"kosiarki:ulepszenie1") == 1 then exports["np-notyfikacje"]:noti("Posiadasz ju? to ulepszenie""error") return end
                setElementData(localPlayer"kosiarki:ulepszenie1"1)
            elseif v[1] == "Zarobek +5%" then
                if getElementData(localPlayer"kosiarki:ulepszenie2") == 1 then exports["np-notyfikacje"]:noti("Posiadasz ju? to ulepszenie""error") return end
                setElementData(localPlayer"kosiarki:ulepszenie2"1)
            end
            exports["np-notyfikacje"]:noti("Zakupujesz ulepszenie: "..v[1])
            setElementData(localPlayer"kospunkty"punkty-tonumber(v[3]))
        end
    end
  end
end)
 
addEvent("pokazTopke:kosiarki:client"true)
addEventHandler("pokazTopke:kosiarki:client"root, function(tabelka)
  pracownicy tabelka
end)
 
 
-- praca
 
 
 
local trawy 0
 
function rozpocznijprace()
    setElementData(localPlayer"pracuje""kosiarki")
    triggerServerEvent("dajKosiarke:kosiarki"localPlayer)
    losuj()
    zaladunek 0
    removeEventHandler("onClientRender"rootguistart)
    okno1 false
    showCursor(false)
    wyladunek createMarker(735.11, -1303.0313.57-.95"cylinder"225131)
    addEventHandler("onClientMarkerHit"wyladunek, function(gracz)
        if gracz ~= localPlayer then return end
        if not getPedOccupiedVehicle(localPlayerthen return end
        if getElementData(localPlayer"kosiarki:ulepszenie1") == 1 then
            ilosc 500
        else
            ilosc 250
        end
        if zaladunek ~= ilosc then return end
        if ilosc == 250 then
            zarobek =  math.random(7090)
        elseif ilosc == 500 then
            zarobek =  math.random(10040)
        end
        if getElementData(localPlayer"premium"then
            zarobek zarobek zarobek*0.15
        end
        if getElementData(localPlayer"kosiarki:ulepszenie1") == 2 then
            zarobek zarobek zarobek*0.05
        end
        local nagroda math.random(15)
        if tonumber(nagroda) == 5 then
            local los2 math.random(13)
            if getElementData(localPlayer"player:premium"then
                los2 math.random(26)
            end
            setElementData(localPlayer"punkty"getElementData(localPlayer"punkty")+los2)
            exports["np-notyfikacje"]:noti("Za dobr? prace otrzymujesz "..los2.." RP")
        end
        local zarobek2 string.format("%1d"zarobek)
        setElementData(localPlayer"pieniadze"getElementData(localPlayer"pieniadze")+zarobek2)
        exports["np-notyfikacje"]:noti("Wy?adowa?e? trawe zarabiasz "..zarobek2.." PLN")
        dostal_powiadomienie false;
        zaladunek 0
        local los math.random(1,3)
        local pkt getElementData(localPlayer"kospunkty") or 0
        setElementData(localPlayer"kospunkty"pkt+los)
    end)
end
 
function zakonczprace()
    setElementData(localPlayer"pracuje"false)
    triggerServerEvent("usunKosiarke:kosiarki"localPlayer)
    for iv in ipairs(getElementsByType("marker")) do
        if getElementData(v"element"then
            destroyElement(getElementData(v"element"))
            destroyElement(v)
        end
    end
    destroyElement(wyladunek)
end
 
 
local miejsca = {
    {773.27, -1295.4013.56},
    {752.78, -1295.8413.57},
    {752.78, -1253.2513.56},
    {774.34, -1253.1313.56},
}
 
function losuj()
    trawy 0
    local los miejsca[math.random(#miejsca)]
    for 130 do
        local add i
        obj createObject(818los[1], los[2]+addlos[3]-2)
        setObjectScale(obj0.5)
        marker createMarker(los[1], los[2]+addlos[3], "corona"0.82552552550)
        setElementData(marker"element"obj)
        trawy trawy 1
    end
    for 114 do
        local add i
        obj createObject(818los[1]-addlos[2], los[3]-2)
        setObjectScale(obj0.5)
        marker createMarker(los[1]-addlos[2], los[3], "corona"0.82552552550)
        setElementData(marker"element"obj)
        trawy trawy 1
        for i2 130 do
            local add2 i2
            obj createObject(818los[1]-addlos[2]+add2los[3]-2)
            setObjectScale(obj0.5)
            marker createMarker(los[1]-addlos[2]+add2los[3], "corona"0.82552552550)
            setElementData(marker"element"obj)
            trawy trawy 1
        end
    end
    addEventHandler("onClientMarkerHit"root, function(gracz)
        if gracz ~= localPlayer then return end
        if not source then return end
        if not getElementData(source"element"then return end
        if not getPedOccupiedVehicle(graczthen return end
        if getElementData(localPlayer"kosiarki:ulepszenie1") == 1 then
            ilosc 350
        else
            ilosc 250
        end
        if zaladunek == ilosc then 
            if not dostal_powiadomienie then
                exports["np-notyfikacje"]:noti("Twoja kosiarka jest pe?na musisz j? wy?adowa?""error");
                dostal_powiadomienie true;
            end
            return;
        end
        destroyElement(getElementData(source"element"))
        destroyElement(source)
        trawy trawy 1
        zaladunek zaladunek 1
        if trawy == 0 then
            for iv in ipairs(getElementsByType("marker")) do
                if getElementData(v"element"then
                    destroyElement(getElementData(v"element"))
                    destroyElement(v)
                end
            end
            marker false
            losuj()
            triggerServerEvent("daj:koszlecenia"localPlayerlocalPlayer)
        end
    end)
end
 
strefa createColCuboid(722.99, -1308.7013.57-16010010)

addEventHandler("onClientColShapeLeave"strefa, function(gracz)
    if gracz ~= localPlayer then return end
    if getElementData(localPlayer"pracuje") == "kosiarki" then
        zakonczprace()
    end
end)


--opcje
 
function shadowText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
    dxDrawText(text,x+1,y+1,w+1,h+1,tocolor(0,0,0),size,font,xx,yy,x1,x2,x3,x4,x5)
    dxDrawText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
end
 
function mysz(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end
 
function scale_x(value)
    local result = (value 1440) * sx
 
    return result
end
 
function scale_y(value)
    local result = (value 900) * sy
 
    return result
end

s.lua
function pokazpracownikow()
    local q exports['np-mysql']:wykonaj("SELECT * from konta order by koszlecenia desc")
    local topka = {}

    for 1,do
        table.insert(topka, {nick q[i]["login"], liczba q[i]["koszlecenia"]})
    end

    return topka
end


tablica pokazpracownikow()

setTimer(function()
    tablica pokazpracownikow()
end6000000)

addEvent("pokazTopke:kosiarki:source"true)
addEventHandler("pokazTopke:kosiarki:source"root, function()
    triggerClientEvent(source"pokazTopke:kosiarki:client"sourcetablica)
end)

kosiarka = { }

addEvent("dajKosiarke:kosiarki"true)
addEventHandler("dajKosiarke:kosiarki"root, function()
    kosiarka[source] = createVehicle(572770.50, -1306.1813.140.90.03.4)
    warpPedIntoVehicle(sourcekosiarka[source])
    triggerClientEvent(root"ghost:vehicle"rootkosiarka[source])
    setElementData(kosiarka[source], "kierowca:kosiarki"getElementData(source"dbid"))
end)

addEvent("usunKosiarke:kosiarki"true)
addEventHandler("usunKosiarke:kosiarki"root, function()
    if isElement(kosiarka[client]) then
        destroyElement(kosiarka[client])
    end
end)

addEventHandler("onPlayerQuit"root, function()
    if isElement(kosiarka[source]) then
        destroyElement(kosiarka[source])
    end
end)

addEvent("daj:koszlecenia"true)
addEventHandler("daj:koszlecenia"root, function(player)
    local dbid getElementData(player"dbid")
    local ilosc getElementData(player"koszlecenia") or 0
    local q exports['np-mysql']:wykonaj("UPDATE konta SET koszlecenia=koszlecenia+1 where dbid=?"dbid)
    setElementData(player"koszlecenia"ilosc+1)
end)

addEventHandler("onVehicleStartEnter"root, function(graczseat)
    if seat ~= 0 then return end
    if getElementData(gracz"pracuje") == "kosiarki" then
        if getElementData(source"id"then
            cancelEvent()
        end
        if getElementData(source"kierowca:kosiarki") ~= getElementData(gracz"dbid"then
            cancelEvent()
        end
    else
        if getElementData(source"kierowca:kosiarki"then
            cancelEvent()
        end
    end
end)


Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-27, 11:02


Ciastuuś

Truck soon...






Wiek: 26
Na forum: 3071 dni
Posty: 799
Nick w MP: Ciastuuś

Piwa: 4297

Respekt: 640
Respekt: 640Respekt: 640

dajKosiarke:kosiarki nie jest dodana po stronie servera.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-27, 14:07


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Jak to zrobi??

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-04-27, 14:45


Wilq







Wiek: 24
Na forum: 4429 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8


Więcej informacji znajdziesz w Wikipedii MTA:

addEvent


Więcej informacji znajdziesz w Wikipedii MTA:

addEventHandler


Przeczytaj CA?E OBIE STRONY zanim poprosisz o gotowy kod.

Postaw piwo autorowi tego posta
 

 
Tagi: serverside
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Serverside 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