Announcement

Collapse
No announcement yet.

wrid mariadb query problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    wrid mariadb query problem

    hi.
    so i'm trying to check database if player exist ( steamid ).
    the query is fine but the result is not ?
    on my database i can clearly see my manually entered steam id ( modified here with * to keep it private ****1198115562342 ) .
    when i log into the server in the game , my steamid is still the good one in chat and server console.
    but mariadb query result is always " 7.65612e+16 "
    WTF ???
    did it all myself according to some tutorial , the wiki and base script as exemple sicne im learnign lua. thats why i dont ask any code and dont use any base or rp ready gamemode.
    here is my server code
    Code:
    function OnPlayerSteamAuth(player)
    print("Player "..player.." authenticated with SteamId "..GetPlayerSteamId(player))
    AddPlayerChat(player, GetPlayerSteamId(player))
    
    local query = mariadb_prepare(db, "SELECT * FROM users WHERE steam_id = '?' LIMIT 1", GetPlayerSteamId(player))
    mariadb_query(db, query, LoadPlayer, player)
    
    end
    AddEvent("OnPlayerSteamAuth", OnPlayerSteamAuth)
    
    function LoadPlayer(player)
    local rows = mariadb_get_row_count()
    if (rows == 0) then
    AddPlayerChat(player, "No account found for that steamId")
    else
    AddPlayerChat(player, "there is an account for that steamId")
    end
    by the way , the database steam_id column is varchar because they all say to not use int.
    also , yes , i tried ToString.
    can you help me please ? no error at all in any log file.
    the is mariadb log line about my query
    Code:
    [2021-01-02 09:55:08.190] [mariadb] [info] query "SELECT * FROM users WHERE steam_id = '7.65612e+16' LIMIT 1" successfully executed within 0.867 milliseconds
    [2021-01-02 09:55:08.190] [mariadb] [debug] ResultSet::Create(connection=0x10a2bfdd1f0, query_str='SELECT * FROM users WHERE steam_id = '7.65612e+16' LIMIT 1')
    because the result is wrong , i cant do anything else like show a login form or whatever.

    console giving the right steamid
    Code:
    2021-01-02 09:54:36 [info] Server loaded. Entering simulation...
    2021-01-02 09:55:07 [info] Client requesting connection 127.0.0.1:54103
    2021-01-02 09:55:07 [info] Player (ID 1) joining the game (127.0.0.1:54103)
    2021-01-02 09:55:08 [script] Player 1 authenticated with SteamId ****1198115562342
    2021-01-02 09:55:21 [info] Player (ID 1) disconnected (127.0.0.1:54103)
    thank you

    #2
    Hi. I can't see in your script how you retrieve the steamid as a string.

    You can also check the example scripts how it's done there: https://github.com/BlueMountainsIO/O...counts.lua#L34

    The database sql file: https://github.com/BlueMountainsIO/O...ster/onset.sql

    Comment


      #3
      Originally posted by Talos View Post
      Hi. I can't see in your script how you retrieve the steamid as a string.

      You can also check the example scripts how it's done there: https://github.com/BlueMountainsIO/O...counts.lua#L34

      The database sql file: https://github.com/BlueMountainsIO/O...ster/onset.sql
      Code:
      print("Player "..player.." authenticated with SteamId "..GetPlayerSteamId(player))
      AddPlayerChat(player, GetPlayerSteamId(player))
      those value are correct. the problem is in the database. the steamid is right everywhere but in the query as we can see in the mariadb log.

      EDIT
      thats why this script wasnt working for me...
      the line
      [/CODE]
      PlayerData[player].accountid = mariadb_get_value_index(1, 1)
      [/CODE]
      give me
      Code:
      Error in MariaDB callback: [string "Explicit_RP/base/server_base.lua"]:106: attempt to index a nil value (field '?')
      but now my previous issue seems to be sesolved. i must have typed soemthing wrong when i first tried.



      Last edited by br4inl3ss; 01-03-2021, 12:03 AM.

      Comment


        #4
        well i guess the problem is in the mariadb callback. even trying the whole exemple give many error about mariadb. and none related to me sicne i took the whole exemple file.
        EDIT
        well confirmed 100% mariadb fault ( or onset itself ? anyhow it explain the very low amount of help and servers ).
        Last edited by br4inl3ss; 01-03-2021, 03:04 PM.

        Comment


          #5
          What's the exact problem now?
          Everything works fine for me.

          Comment


            #6
            i said what was the problem...
            Code:
            Error in MariaDB callback: [string "Explicit_RP/base/server_base.lua"]:106: attempt to index a nil value (field '?')
            at this line
            Code:
            PlayerData[player].accountid = mariadb_get_value_index(1, 1)

            Comment


              #7
              Looks like variable player is nil.

              Comment


                #8
                Originally posted by Talos View Post
                Looks like variable player is nil.
                i know , two lua coder told me that. but they cant help anymore since they have the same exact problem.
                by the way , its the code from the github you sent me.
                and also , its WRITING to the variable not READING.
                so once again it comes from mariadb.
                Last edited by br4inl3ss; 01-04-2021, 07:08 AM.

                Comment


                  #9
                  PlayerData is not initialized with "player" as a key that why you get this error.

                  All code of the OnsetLuaScripts repo is running fine on my "Talos Testserver".

                  Originally posted by br4inl3ss View Post
                  and also , its WRITING to the variable not READING.
                  What do you mean by that?

                  Comment

                  Working...
                  X