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

Wysłany: 2018-12-17, 20:44


Adaskokieblasko







Wiek: 23
Na forum: 3095 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100

Witam mam ma?y b??d :/ a dok?adniej ,,attempt to compare number with string"
Kod:
--[[
Autor: Malentas
]]

local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()
local px, py = screenW/1440, screenH/900

local font = dxCreateFont("cz.ttf", 10)
local font2 = dxCreateFont("cz.ttf", 13)

local okno = false

local rzeczy = {
    --- nazwa, tekst, cena, %najedzenia, grafika
    {"Hamburger", "Kupuj?c hamburgera dostajesz +20% najedzenia", 20, 20, 1},
    {"Hotdog", "Kupuj?c hotdoga dostajesz +15% najedzenia", 10, 15, 2},
    {"Kebab", "Kupuj?c kebaba dostajesz +20% najedzenia", 25, 20, 3},
    {"Woda", "Kupuj?c wode dostajesz +5% najedzenia", 5, 5, 7},
    {"P?czek", "Kupuj?c p?czka dostajesz +10% najedzenia", 10, 10, 5},
}

function gui()
      dxDrawImage(510*px, 233*py, 420*px, 435*py, ":np-gui/grafiki/tlo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    dxDrawText("Zakup fastfood?w", 509*px, 233*py, 930*px, 272*py, tocolor(255, 255, 255, 255), 1.00, font2, "center", "center", false, false, false, false, false)
    dxDrawImage(904*px, 243*py, 16*px, 16*py, ":guieditor/images/cross.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
    for i, v in ipairs(rzeczy) do
        local dodatekY = (73*py)*(i-1)
        local dodatekY2 = (146*py)*(i-1)

        dxDrawRectangle(520*px, 281*py+dodatekY, 400*px, 70*py, tocolor(0, 0, 0, 120), false)
        dxDrawImage(530*px, 291*py+dodatekY, 50*px, 50*py, ":np-fastfoody/grafy/"..v[5]..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(v[1], 598*px, 281*py+dodatekY2, 826*px, 309*py, tocolor(255, 255, 255, 255), 1.00, font, "left", "center", false, false, false, false, false)
        dxDrawText(v[2], 598*px, 309*py+dodatekY, 826*px, 348*py, tocolor(255, 255, 255, 255), 1.00, font, "left", "top", false, true, false, false, false)
      dxDrawImage(834*px, 316*py+dodatekY, 76*px, 25*py, ":np-gui/grafiki/button_off.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
      dxDrawText("Kup", 833*px, 315*py+dodatekY2, 910*px, 341*py, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
        dxDrawText(""..v[3].." PLN", 826*px, 281*py+dodatekY2, 920*px, 311*py, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
       end
end

addEventHandler("onClientClick", root, function(btn, state)
  if btn == "left" and state == "down" then
      for i,v in ipairs(rzeczy) do
          local dodatekY = (73*py)*(i-1)
          if mysz(826*px, 301*py+dodatekY, 100*px, 50*py) and okno == true then
              --local najedzenie = getElementData(localPlayer, "najedzenie") or 0
              --if najedzenie >= 100 then exports["np-notyfikacje"]:noti("Jeste? najedzony", "error") return end
              --setElementData(localPlayer, "najedzenie", najedzenie+tonumber(v[4]))
            if getElementData( localPlayer, "pieniadze" ) < tonumber(v[3]) then
                exports['np-notyfikacje']:noti( "Brakuje Ci pieni?dzy, na zakupienie tego.", "error" );
                return;
            end
              setElementData(localPlayer, "pieniadze", getElementData(localPlayer, "pieniadze")-tonumber(v[3]))
              exports["np-notyfikacje"]:noti("Zakupujesz "..v[1]..", posiadasz go w swoim ekwipunku (M).")
            triggerServerEvent("daj:fastfoody", localPlayer, v[1])
          end
      end
    if mysz(904*px, 243*py, 16*px, 16*py) and okno == true then
        removeEventHandler("onClientRender", root, gui)
        okno = false
        showCursor(false)
    end
  end
end)

addEventHandler("onClientMarkerHit", resourceRoot, function(gracz)
    if gracz ~= localPlayer then return end
      if getPedOccupiedVehicle(localPlayer) then return end
      if getElementData(localPlayer, "bw") then return end
      if getElementDimension(localPlayer) ~= 0 or getElementInterior(localPlayer) ~= 0 then return end
    addEventHandler("onClientRender", root, gui)
    okno = true
    showCursor(true)
end)

addEventHandler("onClientMarkerLeave", resourceRoot, function(gracz)
  if gracz ~= localPlayer then return end
  removeEventHandler("onClientRender", root, gui)
  okno = false
  showCursor(false)
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


Dok?adniej chodzi o to
 if getElementData( localPlayer, "pieniadze" ) < tonumber(v[3]) then 

Dodam ze po restarcie skryptu zabiera pieni?dze dodaje przedmiot do ekwipunku ale mo?na zej?? z got?wka na -

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-17, 21:19


Query

SyndicateMTA






Wiek: 24
Na forum: 3212 dni
Posty: 319
Nick w MP: Query

Piwa: 5238

Respekt: 141
Respekt: 141

skrypt nie mo?e por?wna? liczby z ci?giem znak?w

Podpis
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-12-18, 06:06


Dawcio77







Wiek: 22
Na forum: 3453 dni
Posty: 89
Nick w MP: cx_u

Piwa: 136

Respekt: 35,8


 if tonumber(getElementData( localPlayer, "pieniadze" )) < tonumber(v[3]) then 


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Adaskokieblasko
Wysłany: 2018-12-18, 13:40


Adaskokieblasko







Wiek: 23
Na forum: 3095 dni
Posty: 101

Piwa: 18

Respekt: 100
Respekt: 100

Dzi?ki dzia?a do zamkni?cia ;)

Postaw piwo autorowi tego posta
 

 
Tagi: attempt :: compare :: number :: with :: string
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