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

Wysłany: 2021-03-02, 22:29


K4n33







Wiek: 23
Na forum: 2123 dni
Posty: 11
Nick w MP: ZwyklyChlopak

Piwa: 4

Respekt: 50

Witam mam problem z kasynem mianowice nie wiem jaka jest element data na wygrane bety poniewaz mam tak lecz jak ktos wygra to daje caly hajs x2 ale nie tylko ten co postawil
c.lua

--Autor: pkpk#7539 (Kuks)
--kuksssyt@gmail.com

local markers = {
    {1731.31, -1644.88, 20.23-1, 270},
    {1731.39, -1650.15, 20.23-1, 270},
    {1731.44, -1653.18, 20.24-1, 270},
    {1731.49, -1657.55, 20.24-1, 270},
    {1730.84, -1660.80, 20.24-1, 230},
    {1712.22, -1653.25, 20.22-1, 90},
    {1712.18, -1650.84, 20.22-1, 90},
    {1712.23, -1648.53, 20.22-1, 90},
}

for i, v in ipairs(markers) do
    local m = createMarker(v[1], v[2], v[3], "corona", 2, 255, 255, 255, 0)
    setElementInterior(m, 18)
    setElementData(m, "kasyno", true)
    setElementInterior(createObject(2640, v[1], v[2], v[3]+0.9, 0, 0, v[4]), 18)
end

local x, y = guiGetScreenSize()
local px, py = (x/1024), (y/768)

local edit = guiCreateEdit(457*px, 400*py, 110*px, 30*py, "Kwota", false)
guiSetVisible(edit, false)

addEventHandler("onClientMarkerHit", resourceRoot, function(plr)
    if plr ~= localPlayer then return end
    if not getElementData(source, "kasyno") == true then return end
    if not isEventHandlerAdded("onClientRender", root, render) then
        addEventHandler("onClientRender", root, render)
        showCursor(true)
        guiSetVisible(edit, true)
        triggerServerEvent("casino_balance", localPlayer)
    end
end)

int = 0

local rt = dxCreateRenderTarget(500, 1500, true)

last_bets = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

bety_red = {}
bety_black = {}
bety_green = {}

for k = 1, 6 do
    for i = 1, 7 do --czerwone bety
        local offset = 80 * (i-1)
        local off2 = (k-1) * 560
        if off2+offset+int ~= 560 and off2+offset+int ~= (560*2) and off2+offset+int ~= (560*3) and off2+offset+int ~= (560*4) and off2+offset+int ~= (560*5) and off2+offset+int ~= (560*6) then
            table.insert(bety_red, {off2+offset+int, i})
        end
    end
    for i = 8, 14 do --czarne bety
        local offset = 80 * (i-8)
        local off2 = (k-1) * 560
        table.insert(bety_black, {off2+(offset+40+int), i})
    end
end

table.insert(bety_green, {560+int, 0})
table.insert(bety_green, {(560*2)+int, 0})
table.insert(bety_green, {(560*3)+int, 0})
table.insert(bety_green, {(560*4)+int, 0})
table.insert(bety_green, {(560*5)+int, 0})
table.insert(bety_green, {(560*6)+int, 0})

function removeHex(text, digits)
    assert (type (text) == "string", "Bad argument 1 @ removeHex [String expected, got "..tostring(text).."]")
    assert (digits == nil or (type (digits) == "number" and digits > 0), "Bad argument 2 @ removeHex [Number greater than zero expected, got "..tostring (digits).."]")
    return string.gsub (text, "#"..(digits and string.rep("%x", digits) or "%x+"), "")
end

local colors_textures = {
    red = dxCreateTexture("files/red.png", "argb", false),
    green = dxCreateTexture("files/green.png", "argb", false),
    black = dxCreateTexture("files/black.png", "argb", false)
}

setElementData(localPlayer, "bet", nil)


addEvent("kasyno_setBet1", true)
addEventHandler("kasyno_setBet1", root, function()
    players_red = {}
    players_green = {}
    players_black = {}
end)

addEvent("casino_addPlayer", true)
addEventHandler("casino_addPlayer", root, function(name, kwota, kolor)
    if kolor == 'red' then
        if not getElementData(source, "bet") then
            setElementData(source, "bet", 'red')
            table.insert(players_red, {name, kwota})
        end
    elseif kolor == 'green' then
        setElementData(source, "bet", 'green')
        table.insert(players_green, {name, kwota})
    elseif kolor == 'black' then
        if not getElementData(source, "bet") then
            setElementData(source, "bet", 'black')
            table.insert(players_black, {name, kwota})
        end
    end
    --setElementData(source, "bet", kolor)
end)

addEvent("casino_clearList", true)
addEventHandler("casino_clearList", root, function(name, kwota, kolor)
    if smgs then return end
    smgs = true
    players_red = {}
    players_green = {}
    players_black = {}
end)

function sprawdz(ile)
    for i, v in ipairs(bety_red) do
        if (v[1]-250) <= ile and (v[1]-210) >= ile then
            table.remove(last_bets, 1)
            table.insert(last_bets, v[2])
            triggerServerEvent("money_casino", localPlayer, 'red')
            return
        end
    end
    
    for i, v in ipairs(bety_black) do
        if (v[1]-250) <= ile and (v[1]-210) >= ile then
            table.remove(last_bets, 1)
            table.insert(last_bets, v[2])
            triggerServerEvent("money_casino", localPlayer, 'black')
            return
        end
    end
    
    for i, v in ipairs(bety_green) do
        if (v[1]-250) <= ile and (v[1]-210) >= ile then
            table.remove(last_bets, 1)
            table.insert(last_bets, v[2])
            triggerServerEvent("money_casino", localPlayer, 'green')
            return
        end
    end
end

function krec()
    int = interpolateBetween(0, 0, 0, -liczba, 0, 0, (getTickCount()-tick)/5000, "OutQuad")
    if int <= -liczba then
        smgs = nil
        removeEventHandler("onClientRender", root, krec)
        sprawdz(liczba)
        roluje = nil
    end
end

function krecenie(rnd)
    if rnd then
        liczba = rnd
        tick = getTickCount()
        addEventHandler("onClientRender", root, krec)
        roluje = true
    end
end
addEvent("kasyno_krecenie", true)
addEventHandler("kasyno_krecenie", root, krecenie)

timeToEnd = 15

addEvent("odlicz_kasyno", true)
addEventHandler("odlicz_kasyno", root, function(ile)
    timeToEnd = ile
end)

function render()
    dxDrawImage(262*px, 184*py, 500*px, 400*py, "files/gui.png")
    dxDrawImage(287*px, 450*py, 130*px, 43*py, colors_textures.red)
    dxDrawImage(447*px, 450*py, 130*px, 43*py, colors_textures.green)
    dxDrawImage(607*px, 450*py, 130*px, 43*py, colors_textures.black)
    local balans = getElementData(localPlayer,'player:b_money') or 0
    dxDrawText(przecinki(balans).." PLN", 270*px, 190*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    if not roluje then
        dxDrawText("Nast?pne losowanie za: "..timeToEnd.."s", 470*px, 230*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    else
        dxDrawText("Losowanie...", 496*px, 230*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    end
    dxDrawText("1 - 7\nX2", 287*px, 450*py, 417*px, 493*py, tocolor(255, 255, 255), 1*px, "default-bold", "center", "center")
    dxDrawText("0\nX14", 447*px, 450*py, 577*px, 493*py, tocolor(255, 255, 255), 1*px, "default-bold", "center", "center")
    dxDrawText("8 - 14\nX2", 607*px, 450*py, 737*px, 493*py, tocolor(255, 255, 255), 1*px, "default-bold", "center", "center")
    dxDrawText("Zak?ady: "..(#players_red), 336*px, 435*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    dxDrawText("Zak?ady: "..(#players_green), 496*px, 435*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    dxDrawText("Zak?ady: "..(#players_black), 656*px, 435*py, 0, 0, tocolor(255, 255, 255), 0.6*px, "default-black")
    dxSetRenderTarget(rt, true)
    for k = 1, 6 do
        for i = 1, 7 do
            local offset = 80 * (i-1)
            local off2 = (k-1) * 560
            dxDrawRectangle(off2+offset+int, 0, 40, 100, tocolor(255, 0, 0))
            --dxDrawText(i, off2+offset+int+15, 39, 0, 0, tocolor(255, 255, 255), 1.5, "default-bold")
        end
        for i = 8, 14 do
            local offset = 80 * (i-8)
            local off2 = (k-1) * 560
            dxDrawRectangle(off2+(offset+40+int), 0, 40, 100, tocolor(0, 0, 0))
            --dxDrawText(i, off2+(offset+40+int)+10, 39, 0, 0, tocolor(255, 255, 255), 1.5, "default-bold")
        end
    end
    dxDrawRectangle(560+int, 0, 40, 100, tocolor(0, 255, 0))
    dxDrawRectangle((560*2)+int, 0, 40, 100, tocolor(0, 255, 0))
    dxDrawRectangle((560*3)+int, 0, 40, 100, tocolor(0, 255, 0))
    dxDrawRectangle((560*4)+int, 0, 40, 100, tocolor(0, 255, 0))
    dxDrawRectangle((560*5)+int, 0, 40, 100, tocolor(0, 255, 0))
    dxDrawRectangle((560*6)+int, 0, 40, 100, tocolor(0, 255, 0))
    --[[dxDrawText(0, 560+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")
    dxDrawText(0, (560*2)+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")
    dxDrawText(0, (560*3)+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")
    dxDrawText(0, (560*4)+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")
    dxDrawText(0, (560*5)+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")
    dxDrawText(0, (560*6)+int+15, 39, 40, 100, tocolor(255, 255, 255), 1.5, "default-bold")]]
    dxSetRenderTarget()
    dxDrawImage(263*px, 252*py, 498*px, 663*py, rt)
    dxDrawRectangle(511*px, 252*py, 3*px, 44*py)
    for i, v in ipairs(players_red) do
        if i < 5 then
            local offset = 20 * (i-1)
            dxDrawText(removeHex(v[1]).." "..przecinki(v[2]).." PLN", 287*px, (497+offset)*py, 417*px, (580+offset)*py, tocolor(255, 255, 255), 0.7*px, "default-bold", "center", "top")
        end
    end
    for i, v in ipairs(players_green) do
        if i < 5 then
            local offset = 20 * (i-1)
            dxDrawText(removeHex(v[1]).." "..przecinki(v[2]).." PLN", 532*px, (497+offset)*py, 497*px, (580+offset)*py, tocolor(255, 255, 255), 0.7*px, "default-bold", "center", "top")
        end
    end
    for i, v in ipairs(players_black) do
        if i < 5 then
            local offset = 20 * (i-1)
            dxDrawText(removeHex(v[1]).." "..przecinki(v[2]).." PLN", 672*px, (497+offset)*py, 677*px, (580+offset)*py, tocolor(255, 255, 255), 0.7*px, "default-bold", "center", "top")
        end
    end
    for i = 1, 10 do
        local offset = 35 * (i-1)
        if last_bets[i] == 0 then
            dxDrawRectangle((343+offset)*px, 354*py, 24*px, 28*py, tocolor(0, 255, 0))
        elseif last_bets[i] == 1 or last_bets[i] == 2 or last_bets[i] == 3 or last_bets[i] == 4 or last_bets[i] == 5 or last_bets[i] == 6 or last_bets[i] == 7 then
            dxDrawRectangle((343+offset)*px, 354*py, 24*px, 28*py, tocolor(255, 0, 0))
        elseif last_bets[i] == 8 or last_bets[i] == 9 or last_bets[i] == 10 or last_bets[i] == 11 or last_bets[i] == 12 or last_bets[i] == 13 or last_bets[i] == 14 then
            dxDrawRectangle((343+offset)*px, 354*py, 24*px, 28*py, tocolor(0, 0, 0))
        end
        dxDrawText(last_bets[i], (343+offset)*px, 354*py, (367+offset)*px, 382*py, tocolor(255, 255, 255), 1*px, "default-bold", "center", "center")
    end
end

addEventHandler("onClientClick", root, function(btn, state)
    if btn ~= "left" or state ~= "down" then return end
    if not isEventHandlerAdded("onClientRender", root, render) then return end
    if isMouseIn(730*px, 186*py, 30*px, 35*py) then
        removeEventHandler("onClientRender", root, render)
        showCursor(false)
        guiSetVisible(edit, false)
    end
    
    --BETOWANIE:
    if isMouseIn(287*px, 450*py, 130*px, 43*py) then --red
        if roluje then
            outputChatBox("Poczekaj na koniec losowania", 255, 0, 0)
            return
        end
        if not getElementData(localPlayer, "bet") then
            triggerServerEvent("addBet_casino", localPlayer, 'red', guiGetText(edit))
        end
    end
    
    if isMouseIn(447*px, 450*py, 130*px, 43*py) then --green
        if roluje then
            outputChatBox("Poczekaj na koniec losowania", 255, 0, 0)
            return
        end
        if getElementData(localPlayer, "bet") ~= "green" then
            triggerServerEvent("addBet_casino", localPlayer, 'green', guiGetText(edit))
        end 
    end
    
    if isMouseIn(607*px, 450*py, 130*px, 43*py) then --black
        if roluje then
            outputChatBox("Poczekaj na koniec losowania", 255, 0, 0)
            return
        end
        if not getElementData(localPlayer, "bet") then
            triggerServerEvent("addBet_casino", localPlayer, 'black', guiGetText(edit))
        end
    end
end)

function isEventHandlerAdded( sEventName, pElementAttachedTo, func )
     if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then
          local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo )
          if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then
               for i, v in ipairs( aAttachedFunctions ) do
                    if v == func then
                     return true
                end
           end
      end
     end
     return false
end

function isMouseIn(x, y, width, height)
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    
    return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
end

function przecinki(amount) 
    local formatted = amount 
    while true do   
      formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') 
      if (k==0) then 
        break 
      end 
    end 
    return formatted 
end


s.lua

--Autor: pkpk#7539 (Kuks)
--kuksssyt@gmail.com

bets = {}
ile = 15

setTimer(function()
    ile = ile - 1
    triggerClientEvent(root, "odlicz_kasyno", root, ile)
    if ile <= 0 then
        ile = 20
        local rand = math.random(1000, 2900)
        triggerClientEvent(root, "kasyno_krecenie", root, rand)
    end
end, 1000, 0)

setTimer(function()
    triggerClientEvent(root, 'kasyno_setBet1', root)
end, 500, 1)

addEvent("addBet_casino", true)
addEventHandler("addBet_casino", root, function(kolor, kasa)
    if getElementData(source, "bet") and kolor ~= "green" then return end
    if getElementData(source, "bet") == "green" and kolor == "green" then return end
    if not tonumber(kasa) then
        outputChatBox("Podaj liczb?", source, 255, 0, 0)
        return
    end
    if tonumber(kasa) < 1 then
        outputChatBox("Minimalny bet to 1,000,000 PLN", source, 255, 0, 0)
        return
    end
    if tonumber(kasa) > 99999999999999999999 then
        outputChatBox("Maksymalny bet to 4,000,000,000 PLN", source, 255, 0, 0)
        return
    end
    local sid = getElementData(source, "player:sid")
    if getElementData(source,'player:b_money') < tonumber(kasa) then
        outputChatBox("Nie masz tyle pieni?dzy", source, 255, 0, 0)
        return
    end
    --takePlayerMoney(source, tonumber(kasa))
    table.insert(bets, {player = source, color = kolor, money = tonumber(kasa)})
    triggerClientEvent(root, "casino_addPlayer", source, getPlayerName(source), kasa, kolor)
    local balans = getElementData(source, "player:b_money") or 0
    setElementData(source,'player:b_money',getElementData(source,'player:b_money') - tonumber(kasa))

end)

addEvent("money_casino", true)
addEventHandler("money_casino", root, function(kolor)
    if ile > 16 then return end
    triggerClientEvent(root, "casino_clearList", source, getPlayerName(source), kasa, kolor)
    for i, v in ipairs(bets) do
        setElementData(v.player, "bet", nil)
        if v.color == kolor then
            if kolor == "red" then
                --givePlayerMoney(v.player, v.money * 2)
                local sid = getElementData(v.player, "player:sid")
                    setElementData(source,'player:b_money',getElementData(source,'player:b_money')*2)

            elseif kolor == "black" then
                --givePlayerMoney(v.player, v.money * 2)
                local sid = getElementData(v.player, "player:sid")
                        setElementData(source,'player:b_money',getElementData(source,'player:b_money')*2)

            elseif kolor == "green" then
                --givePlayerMoney(v.player, v.money * 14)
                local sid = getElementData(v.player, "player:sid")
                    setElementData(source,'player:b_money',getElementData(source,'player:b_money')*2)

            end
        end
    end
    bets = {}
    for i, v in ipairs(getElementsByType("player")) do
        setElementData(v, "bet", nil)
    end
end)

--[[setTimer(function()
    if ile <= 0 then
        ile = 20
        local rand = math.random(1000, 2900)
        triggerClientEvent(root, "kasyno_krecenie", root, rand)
    end
end, 1000, 0)]]




Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-03, 08:46


xyzzzikk

.gg






Wiek: 19
Na forum: 2915 dni
Posty: 175
Nick w MP: aspyk

Piwa: 6564

Respekt: 30,5

masz na my?li, ?e nie daje kasy x2?

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-07, 19:44


K4n33







Wiek: 23
Na forum: 2123 dni
Posty: 11
Nick w MP: ZwyklyChlopak

Piwa: 4

Respekt: 50

NoToR, daje kase x2 ale cala przy sobie nie zbetowana

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-08, 22:20


vAnimo

Zielony w luła






Wiek: 20
Na forum: 2453 dni
Posty: 165
Nick w MP: vAnimo

Piwa: 883

Respekt: 70

Kod:

elseif kolor == "green" then
--givePlayerMoney(v.player, v.money * 14)
local sid = getElementData(v.player, "player:sid") setElementData(source,'player:b_money',getElementData(source,'player:b_money')*2)
end
tu masz b??d mno?ysz pieni?dze kogo?, ci??ko popatrzy? na kod?

u?yj
Kod:

setElementData(source,'player:b_money',getElementData(source,'player:b_money')+(v.money*2))

licze na :piwo: :piwo: :piwo:

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-12, 17:03


K4n33







Wiek: 23
Na forum: 2123 dni
Posty: 11
Nick w MP: ZwyklyChlopak

Piwa: 4

Respekt: 50

vAnimo, nie dzia?a

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-12, 20:35


vAnimo

Zielony w luła






Wiek: 20
Na forum: 2453 dni
Posty: 165
Nick w MP: vAnimo

Piwa: 883

Respekt: 70

Kod:

setElementData(source,'player:b_money',getElementData(source,'player:b_money')+tonumber(v.money*2))


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Wysłany: 2021-03-14, 20:12


K4n33







Wiek: 23
Na forum: 2123 dni
Posty: 11
Nick w MP: ZwyklyChlopak

Piwa: 4

Respekt: 50

Zamykam wystarczylo z source zmienic na v.player

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
borsuk
Tagi: kasynko
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