Jump to content

Sasu

MTA Contributors
  • Posts

    1,056
  • Joined

  • Last visited

Posts posted by Sasu

  1. A ver, el problema está en éste código.
    local info = exports.sql:query_assoc_single( "SELECT userID, username, banned, activationCode, password, userOptions FROM wcf1_user WHERE username = '%s'") 
    

    Aquí todo el código

    function performLogin( source, token, isPasswordAuth, ip ) 
        if source and ( isPasswordAuth or not triedTokenAuth[ source ] ) then 
            triedTokenAuth[ source ] = true 
            if token then 
                if #token == 80 then 
                    local info = exports.sql:query_assoc_single( "SELECT userID, username, banned, activationCode, password, userOptions FROM wcf1_user WHERE username = '%s'") 
                    p[ source ] = nil 
                    if not info then 
                        if isPasswordAuth then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 1 ) -- Wrong username/password 
                        end 
                        return false 
                    else 
                        if info.banned == 1 then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 2 ) -- Banned 
                            return false 
                        elseif info.activationCode > 0 then 
                            triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 3 ) -- Requires activation 
                            return false 
                        else 
                            -- check if another user is logged in on that account 
                            for player, data in pairs( p ) do 
                                if data.userID == info.userID then 
                                    triggerClientEvent( source, getResourceName( resource ) .. ":loginResult", source, 5 ) -- another player with that account found 
                                    return false 
                                end 
                            end 
                            
                            local username = info.username 
                            p[ source ] = { userID = info.userID, username = username, options = info.userOptions and fromJSON( info.userOptions ) or { } } 
                            
                            -- check for admin rights 
                            aclUpdate( source, true ) 
                            
                            -- show characters 
                            local chars = exports.sql:query_assoc( "SELECT characterID, characterName, skin FROM characters WHERE userID = " .. info.userID .. " ORDER BY lastLogin DESC" ) 
                            local chars2 = exports.sql:query_assoc( "SELECT COUNT(*) AS count FROM characters WHERE userID = ".. info.userID .."" ) 
                                if chars2 then 
                                for key, value in ipairs( chars2 ) do 
                                    --(value.count < 3) then 
                                    local cuenta = value.count 
                                end 
                            end 
                            local chars = exports.sql:query_assoc( "SELECT characterID, characterName, skin FROM characters WHERE userID = " .. info.userID .. " ORDER BY lastLogin DESC" ) 
                            p[source].cuenta = #chars 
                            if isPasswordAuth then 
                                triggerClientEvent( source, getResourceName( resource ) .. ":characters", source, chars, true, token, getPlayerIP( source ) ~= "127.0.0.1" and getPlayerIP( source ), #chars ) 
                            else 
                                triggerClientEvent( source, getResourceName( resource ) .. ":characters", source, chars, true, _, _, #chars ) 
                            end  
                            outputServerLog( "FLINT LOGIN: " .. getPlayerName( source ) .. " logueado como " .. info.username .. " (IP: " .. getPlayerIP( source ) .. ", Serial: " .. getPlayerSerial( source ) .. ")" ) 
                            exports.server:message( "%C04[" .. getID( source ) .. "]%C %B" .. info.username .. "%B se logueo (Nick: %B" .. getPlayerName( source ):gsub( "_", " " ) .. "%B)." ) 
                            exports.sql:query_free( "UPDATE wcf1_user SET lastIP = '%s', lastSerial = '%s' WHERE userID = " .. tonumber( info.userID ), getPlayerIP( source ), getPlayerSerial( source ) ) 
                            
                            return true 
                        end 
                    end 
                end 
            end 
        end 
        return false 
    end 
    

    No especificas el username %s en los argumentos por lo tanto no devolverá ningún row.

  2. Are you sure textFrom is returning the proper text?

    I tested this in runcode:

    crun outputChatBox(   split("Dollars - USD"," - ")[1]   ) outputChatBox(   split("Dollars - USD"," - ")[2]   ) 
    

    And it works properly,

    PIFBmm4.png

    so i really think it's textForm (guiComboBoxGetItemText) causing the issue.

    In the picture, you tried without spaces so try without spaces.

  3. Hi there!

    I want you to know that I have just updated my turf system, which it works with gang system by Castillo and it's completely editable. This update contains features, for example capturing the turf will stop if there isn't anyone of the gang, and bug fixes. Also, I will give support so if anybody find a bug or need help with it, contact me sending PM.

    Download link: https://community.multitheftauto.com/index.php?p=resources&s=details&id=6772

    Have fun and a nice day!

  4. Intenta con esto..
      
    setTimer( 
        function ( ) 
            for index, value in ipairs ( getElementsByType("player") ) do 
                if ( exports.players:getCharacterID(value) ) then 
                    if ( exports.factions:isPlayerInFaction(value, 5) ) then 
                        if ( getFactionRank(value) ) then 
                            local money = getFactionRank(value) * 50  
                            exports.players:giveMoney(value, money) 
                            outputChatBox ( "Gobierno: #00FF00$"..money, value, 255, 193, 37, true) 
                        end 
                    end 
                end 
            end 
        end, 150000, 0) 
         
    function getFactionRank(player) 
        db_call = exports.sql:query_assoc( "SELECT factionRank FROM character_to_factions WHERE characterID = " .. exports.players:getCharacterID(player) ) 
        if ( db_call and #db_call > 1 ) then 
            for _, data in ipairs ( db_call ) do 
                if ( data.factionRank ) then 
                    return data.factionRank 
                else 
                    outputDebugString("Something went wrong, failing on looping "..getPlayerName(player).."'s data.") 
                end 
            end 
        else 
            outputDebugString("Something went wrong, failing on getting "..getPlayerName(player).."'s faction rank.") 
        end 
    end 
      
      
    

    ¿Por qué mayor a uno? ¿Es decir que tienes mas de un fila con el mismo id?

    if ( db_call and #db_call > 1 ) then 
    

    Debería ser > 0 o >= 1, se me pasó xD

    Pues ahi esta el error de Blue Pie, pues es que loopea las dos filas, uno que tiene un rank y otro que tiene otro. A pesar de que le pongas eso Tomas, siempre va a devolver el valor de la primera fila ya que el return hace que finalice por completo la funcion y es por eso que ahora solo devuelve una vez. Pero si le funciona, supongo que no habrá problema.

  5. Intenta con esto..
      
    setTimer( 
        function ( ) 
            for index, value in ipairs ( getElementsByType("player") ) do 
                if ( exports.players:getCharacterID(value) ) then 
                    if ( exports.factions:isPlayerInFaction(value, 5) ) then 
                        if ( getFactionRank(value) ) then 
                            local money = getFactionRank(value) * 50  
                            exports.players:giveMoney(value, money) 
                            outputChatBox ( "Gobierno: #00FF00$"..money, value, 255, 193, 37, true) 
                        end 
                    end 
                end 
            end 
        end, 150000, 0) 
         
    function getFactionRank(player) 
        db_call = exports.sql:query_assoc( "SELECT factionRank FROM character_to_factions WHERE characterID = " .. exports.players:getCharacterID(player) ) 
        if ( db_call and #db_call > 1 ) then 
            for _, data in ipairs ( db_call ) do 
                if ( data.factionRank ) then 
                    return data.factionRank 
                else 
                    outputDebugString("Something went wrong, failing on looping "..getPlayerName(player).."'s data.") 
                end 
            end 
        else 
            outputDebugString("Something went wrong, failing on getting "..getPlayerName(player).."'s faction rank.") 
        end 
    end 
      
      
    

    ¿Por qué mayor a uno? ¿Es decir que tienes mas de un fila con el mismo id?

    if ( db_call and #db_call > 1 ) then 
    

  6. No se nada sobre hardware pero creo que antes deberias fijarte cuales son los recursos que utilizan mucha CPU con el resource "perfomancebrowser", tal vez puedas optimizarlos, y, también, cuanto ancho de banda utilizan los jugadores con /shownetstat, ya que a lo mejor haya algún que otro script enviando información constantemente y capaz lo puedas reducir (ejemplo ejecutar setElementData cada 1 seg a todos los jugadores, puedes aumentar el intervalo). Si ya haz hecho esto, ignora este comentario.

  7. Osvaldo098

    Gracias, ya lo pegué como estaba, pero no me aparece, que hago?

    Gracias, saludos.

    en vez de 'root' utiliza getRootElement()

    'root' esta predefinido en MTA y es lo mismo que getRootElement().

    @Osvaldo098: Escribe "debugscript 3"(sin comillas) en F8 y dinos si sale algún error.

  8. Puedes jugar con las funciones de XML y analizar los ejemplos que tiene la wiki, y en caso de que tengas algún problema te ayudaremos.

  9. Desde y hasta donde se ejecuta, en este caso seria 1..2..3..4...........99999..100000 y ahi termina. El foreach lo utilizas cuando tienes una tabla indexada numericamente y el iterate lo puedes usar cuando quieres repetir ciertas acciones.

  10. Hasta donde yo entendí, basándome en los ejemplos, solo le da un parametro a la función que está dentro del async:foreach, y ese es el valor. Es decir:

    for i, v in ipairs(table) do 
        print(v) 
    end 
      
    -- Es lo mismo que.. 
      
    async:foreach(table,  
        function(v) 
            print(v) 
        end 
    ) 
    

    En cuanto a async:iterate sería lo siguiente:

    for i = 1, 100000 do 
        print(i) 
    end  
      
    -- Es lo mismo que.. 
      
    async:iterate(1, 100000,  
        function(i) 
            print(i) 
        end 
    ) 
    

    No soy bueno explicando, disculpas. :roll:

  11. function createPickupsOnServerStart() 
        iPickup = 0 
        async:foreach(pickupPositions.residential,  
            function(pos) 
                iPickup = iPickup + 1 
                createItemLoot("residential", pos[1], pos[2], pos[3], iPickup) 
            end 
        ) 
        setTimer(createPickupsOnServerStart2, 20000, 1) 
    end 
    

    Y para el script de skins deberas pasar la tabla porque no se como pasar el index por esa función. Algo asi me refiero:

    --[[ Tu debes tener una tabla como esta 
    local skins = { 
    [id] = name, 
    [id] = name 
    } 
    ]] 
      
    local skins = { 
    {id, name}, 
    {id, name} 
    } 
      
    function Replaceskins ( ) 
        async:foreach(skins,  
            function(v) 
                txd = engineLoadTXD ( v[2]..".txd" ) 
                engineImportTXD ( txd, v[1] ) 
                dff = engineLoadDFF ( v[2]..".dff", 0 ) 
                engineReplaceModel ( dff, v[1] ) 
            end 
        ) 
    end 
    addEventHandler ( "onClientResourceStart", resourceRoot, Replaceskins) 
    

  12. Al parecer, el máximo valor que se le puede otorgar es 350. Lo comprobé ejecutando un mini-código que hize en el runcode:

    i = 0  
    repeat  
        i = i+1  
        test = setWeaponProperty(28, "pro", "weapon_range", i)  
        outputChatBox(tostring(test and i), root)  
    until not test 
    

×
×
  • Create New...