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

Wysłany: 2020-11-17, 15:21


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

Witam chcia?bym si? zapyta? jak mog? zrobi? by np w komencie lub w edit boksie zmieni? wpisywanie liczb np chc? zrobi? zamiast /przelej nick 1000 m?g?bym wpisa? 1k i automatycznie uzupe?ni w przelaniu ?e jest to 1000 tak samo 2.5k czyli jest to 2500

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-18, 14:52


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

U?ywaj?c string.find. Przyk?ad

addCommandHandler("przelej",function(plr,cmd,ilosc)
    if string.find(ilosc,"k"then
        ilosc=string.gsub(ilosc,"k","")
        ilosc=tonumber(ilosc)*1000
    end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-19, 00:12


killercycDDS

Migacz






Wiek: 25
Na forum: 4512 dni
Posty: 629
Nick w MP: killer_cyc[DDS]

Piwa: 1659

Respekt: 22

"Shuffle" napisał/a:

U?ywaj?c string.find. Przyk?ad

addCommandHandler("przelej",function(plr,cmd,ilosc)
    if string.find(ilosc,"k"then
        ilosc=string.gsub(ilosc,"k","")
        ilosc=tonumber(ilosc)*1000
    end
end)

co? dzia?a lecz mam problem zrobi?em nowy warunek na kk lecz gdy wpisz? np 1kk to wykrywa tylko warunek odpowiadaj?cy za jedno k


function onTransferMoney2(plrcmdtargetiloscilosc2)
    if not target then
        outputChatBox('Poprawne u?ycie: #FFFF00/przelej <nick/ID> <kwota>'plr,255,255,255,true)

        return
    end
    local target=findPlayer(plr,target)
    if not target then
        outputChatBox("Nie znaleziono podanego gracza."plr255,0,0,true)
        return
    end
    if string.find(ilosc,"k"then
        ilosc=string.gsub(ilosc,"k","")
        ilosc=tonumber(ilosc)*1000

    if not (getElementData(target"player:logged") == truethen
       outputChatBox("Podany gracz nie jest zalogowany."plr255,0,0,true)
    return end
    if getElementData(plr,"kasa:gracza") < ilosc then
        outputChatBox("Nie posiadasz wystarczaj?cych ?rodk?w przy sobie."plr255,0,0,true)
        return
    end
    if ilosc == or ilosc 0 then
        outputChatBox("Podano nie prawid?ow? warto??."plr255,0,0,true)
        return
    end

    if getElementData(plr"antyspam:przelej") == 2 then return end
    setElementData(plr"antyspam:przelej"2)
    setTimer(function()
    setElementData(plr"antyspam:przelej"false)
    end25001)

    
    
    setElementData(plr,'kasa:gracza',getElementData(plr,'kasa:gracza')-ilosc)
    setElementData(target,'kasa:gracza',getElementData(target,'kasa:gracza')+ilosc)

    outputChatBox("#FFFFFFPrzela?e?/a? got?wk? graczowi: (#FFFF00"..getElementData(target,"id").."#FFFFFF) #FFFF00"..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."#FFFFFF, ilo?? przelanej got?wki: #FFFF00"..przecinek(string.format("%u",ilosc)).." PLN"plr,  2452190true)
    outputChatBox("#FFFFFFOtrzyma?e?/a? got?wk? od gracza: (#FFFF00"..getElementData(plr,"id").."#FFFFFF) #FFFF00"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").."#FFFFFF, ilo?? otrzymanej got?wki: #FFFF00"..przecinek(string.format("%u",ilosc)).. " PLN"target,  2251990true)

    local transfer_text=('(Przelew) [%d]%s(sid:%d) >> [%d]%s(sid:%d): %s PLN'):format(getElementData(plr,"id"), getPlayerName(plr):gsub("#%x%x%x%x%x%x",""), getElementData(plr,"player:sid"), getElementData(target,"id"), getPlayerName(target):gsub("#%x%x%x%x%x%x",""), getElementData(target,"player:sid"), przecinek(string.format("%u",ilosc)))
    --triggerClientEvent("onDebugMessage"resourceRoottransfer_text,4"PRZELEWY")
    triggerEvent("admin:addText"resourceRootRGBToHex(203,0,255)..transfer_text..RGBToHex(255,255,255),math.random(0,99))
    triggerEvent("admin:logs"roottransfer_text)
    outputServerLog(transfer_text)
    --exports["ec-logi-discord"]:connectWeb(('(Przelew) [%d]%s(sid:%d) >> [%d]%s(sid:%d): %s PLN'):format(getElementData(plr,"id"), getPlayerName(plr):gsub("#%x%x%x%x%x%x",""), getElementData(plr,"player:sid"), getElementData(target,"id"), getPlayerName(target):gsub("#%x%x%x%x%x%x",""), getElementData(target,"player:sid"), przecinek(string.format("%u",value))), "logiprzelewy")--]]
--end
elseif string.find(ilosc2,"kk"then
    ilosc2=string.gsub(ilosc2,"kk","")
    ilosc2=tonumber(ilosc2)*1000000

    if ilosc2 == or ilosc2 0 then
        outputChatBox("Podano nie prawid?ow? warto??."plr255,0,0,true)
        return
    end
    if getElementData(plr,"kasa:gracza") < ilosc2 then
        outputChatBox("Nie posiadasz wystarczaj?cych ?rodk?w przy sobie."plr255,0,0,true)
        return
    end
    setElementData(plr,'kasa:gracza',getElementData(plr,'kasa:gracza')-ilosc2)
    setElementData(target,'kasa:gracza',getElementData(target,'kasa:gracza')+ilosc2)
    
    outputChatBox("#FFFFFFPrzela?e?/a? got?wk? graczowi: (#FFFF00"..getElementData(target,"id").."#FFFFFF) #FFFF00"..getPlayerName(target):gsub("#%x%x%x%x%x%x","").."#FFFFFF, ilo?? przelanej got?wki: #FFFF00"..przecinek(string.format("%u",ilosc2)).." PLN"plr,  2452190true)
    outputChatBox("#FFFFFFOtrzyma?e?/a? got?wk? od gracza: (#FFFF00"..getElementData(plr,"id").."#FFFFFF) #FFFF00"..getPlayerName(plr):gsub("#%x%x%x%x%x%x","").."#FFFFFF, ilo?? otrzymanej got?wki: #FFFF00"..przecinek(string.format("%u",ilosc2)).. " PLN"target,  2251990true)
end
end
addCommandHandler('przelej.k'onTransferMoney2)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-19, 00:55


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Sprawdzaj czy wykrylo "k" i czy w tek?cie NIE MA "kk", czyli dodajesz not string.find(..., "kk")
Pierwsze co mi do g?owy przysz?o.

Postaw piwo autorowi tego posta
 

 
Tagi: formatowanie :: liczb
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