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

Wysłany: 2015-08-03, 10:31


Vxen







Wiek: 28
Na forum: 4227 dni
Posty: 293

Piwa: 1299

Respekt: 130,5
Respekt: 130,5

Siemanko. Mam kod lecz nie wiem czy to jest na dawanie kasy czy na zapis ale po funkcjach widz? ze to jest na dawanie siana. A gdzie w tym kodzie jest komenda? Nie widz? tu addComend.
Oto kod:

_root = getRootElement()

function giveMoney(thePlayer, amount)
    if ( type( tonumber(amount) ) == "number" and getElementType( thePlayer ) == "player" ) then
        if ( amount == 0 ) then
            return true
        elseif ( thePlayer and isElement(thePlayer) and tonumber(amount) > 0 ) then
                amount = math.floor( tonumber(amount) )
        
                setElementData(thePlayer, "money", getMoney( thePlayer ) + amount )
                local result, error = exports.sql:query_free("UPDATE `characters` SET `cash` = cash + " .. amount .. " WHERE charid = '" .. getElementData( thePlayer, "characterID" ) .."'" )
                if ( result ) then
                    givePlayerMoney( thePlayer, amount )
                else
                    return outputDebugString( error )
                end
            return true
        end
        return false
    else
        return outputDebugString("MISSING_ARGUMENTS")
    end
end

function takeMoney(thePlayer, amount, rest)
    amount = tonumber( amount ) or 0
    if amount == 0 then
        return true, 0
    elseif thePlayer and isElement(thePlayer) and amount > 0 then
        amount = math.ceil( amount )
        
        local money = getMoney( thePlayer )
        if rest and amount > money then
            amount = money
        end
        
        if amount == 0 then
            return true, 0
        elseif hasMoney(thePlayer, amount) then
            setElementData(thePlayer, "money", money - amount )
            if getElementType(thePlayer) == "player" then
                exports.sql:query_free("UPDATE `characters` SET `cash` = cash - " .. amount .. " WHERE charid = '" .. getElementData( thePlayer, "characterID" ) .."' " )
                takePlayerMoney( thePlayer, amount )
            return true, amount
            end
        end
    return false, 0
    end
end

function setMoney(thePlayer, amount)
    amount = tonumber( amount ) or 0
    if thePlayer and isElement(thePlayer) and amount >= 0 then
        amount = math.floor( amount )
        
        setElementData(thePlayer, "money", amount )
        if getElementType(thePlayer) == "player" then
            exports.sql:query_free("UPDATE characters SET money = " .. amount .. " WHERE charid = " .. getElementData( thePlayer, "dbid" ) )
            setPlayerMoney( thePlayer, amount )
        elseif getElementType(thePlayer) == "team" then
            exports.sql:query_free("UPDATE factions SET bankbalance = " .. amount .. " WHERE charid = " .. getElementData( thePlayer, "id" ) )
        end
        return true
    end
    return false
end

function hasMoney(thePlayer, amount)
    amount = tonumber( amount ) or 0
    if thePlayer and isElement(thePlayer) and amount >= 0 then
        amount = math.floor( amount )
        
        return getMoney(thePlayer) >= amount
    end
    return false
end

function getMoney(thePlayer, nocheck)
    if not nocheck then
        checkMoneyHacks(thePlayer)
    end
    return getElementData(thePlayer, "money") or 0
end

function checkMoneyHacks(thePlayer)
    if not getMoney(thePlayer, true) or getElementType(thePlayer) ~= "player" then return end
    
    local safemoney = getMoney(thePlayer, true)
    local hackmoney = getPlayerMoney(thePlayer)

    if (safemoney~=hackmoney) then
        --banPlayer(thePlayer, getRootElement(), "Money Hacks: " .. hackmoney .. "$.")
        setPlayerMoney(thePlayer, safemoney)
        --sendMessageToAdmins("Possible money hack detected: "..getPlayerName(thePlayer))
        return true
    else
        return false
    end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-03, 10:41


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4979 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Bo to jest na dawanie kasy poprzez mysql

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-03, 10:43


Vxen







Wiek: 28
Na forum: 4227 dni
Posty: 293

Piwa: 1299

Respekt: 130,5
Respekt: 130,5

I tu niema ?adnej komendy? Po prostu w bazie ustawiamy kase?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-03, 10:48


Fanciak

BOT






Wiek: 26
Na forum: 4587 dni
Posty: 728
Nick w MP: Fanciak

Piwa: 1572

Respekt: 500
Respekt: 500

Tak, w bazie.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-08-03, 21:21


Tostuch







Wiek: 28
Na forum: 5072 dni
Posty: 483
Nick w MP: Tost

Piwa: 137

Respekt: 110
Respekt: 110

Tu s? funkcje nie tylko do dawania, ale og?lnie do zarz?dzania pieni?dzmi gracza.

#Tak troche s?abo u?ywa? tego antyczita valhalli, ?atwo go obej?? :D

Postaw piwo autorowi tego posta
 

 
Tagi: czy :: zapis?
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