Recent Posts

Pages: [1] 2 3 ... 10
1
General Chat & Help and Support / Re: Text question
« Last post by FritzJent on Today at 03:29:15 AM »
How many different colored user groups can you create like this?
2
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by jacksop on January 27, 2020, 10:46:34 PM »
Awesome. I believe that worked! Nice work thinking of that. (I probs would never have)

Thanks for your help through all this. Would have been stuck for countless hours otherwise. I couldn't find any other forum post similar to mine so I started this one so thank you.
Funny how far we got from the actual problem that started this thread.

Thank you again!
3
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by Timmy on January 26, 2020, 11:04:09 PM »
Oh, I bet MySQLOO returns the ID as a string... Cast it to a number before comparing.

if (value and tonumber(value.job_id) ~= currentteam) then

If you ever need to debug something like this, you can get the data type of a value with type().

print(type(my_variable))
4
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by jacksop on January 26, 2020, 04:48:30 PM »
Ahhh right. That's handy.

I've tested what you said and changed the if statement to include the if value and value.job_id.
What happens is the query2 runs regardless of the if statement. The way I know this is everytime a player disconnects, the console prints:

[SQL] The players job was logged

...and the text for the UpdateULXRank function doesn't - therefore that if statement works but the save job if statement does not.

The function does replace the value in the database table under job_id to the correct team/job (I think job and team are related somehow...) - if I change jobs before I disconnect from the server, the number in the job_id column in the database changes. Also, if I print value.job_id it is the correct number that I am expecting.

This is really confusing because both functions should act the same.... weird...  ???
5
General Chat & Help and Support / Re: Text question
« Last post by Timmy on January 26, 2020, 12:46:02 PM »
OP has added a poll/reply:
Quote
No, I want to change the color and so that instead of the admin name the moderator writes

You can change the colors in the ULX menu: Open ULX menu (XGUI) > Click "Settings" tab > Click "Server" tab > Click "ULX Command/Event Echoes"



I don't understand "so that instead of the admin name the moderator writes". Can you rephrase or explain?
6
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by Timmy on January 26, 2020, 12:45:12 AM »
Garry made some modifications to the Lua engine so you can actually use != to negate in GLua. It's not valid in regular Lua though. :D

I don't see any obvious mistakes in the last snippet you posted.

If the UPDATE query does not run, keep track of the value in currentteam. Does it update after you switch jobs? Perhaps you are confusing teams and jobs?

There will also be a Lua error if query1 returns no results. Make sure value is not nil before accessing job_id. Something like this will work:
if (value and value.job_id ~= currentteam) then
7
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by jacksop on January 25, 2020, 05:15:39 PM »
Oh ok thanks for clearing that up! Realised I used the wrong negation operator for lua!

After some playing around with the code you gave me I believe its working now!! THANKS!

I have another one of these functions but I don't understand why it isn't working. They are basically identical despite the job parameters. Just wanna keep track of this too.

Code: [Select]
function DBSaveJobID (currentteam, steamid, nickname)
local query1 = DB_RP:query( "SELECT job_id FROM player_information WHERE steam_id = '" .. steamid .. "';")

query1.onSuccess = function()
local results = query1:getData()
local value = results[1]
if (value.job_id ~= currentteam) then
local query2 = DB_RP:query("UPDATE player_information SET job_id = '".. currentteam .."' WHERE steam_id = '".. steamid.."';")
query2.onSuccess = function()
MsgC( Color (0, 0, 255), "[SQL] The players job was logged \n")
end
query2.onError = function(db, err)
MsgC( Color (255, 0, 0), "[SQL] (Job Update) - Error: ", err)
end
query2:start()
end
end
query1:start()
end

Thanks so much for helping this far...
8
General Chat & Help and Support / Re: Text question
« Last post by Timmy on January 25, 2020, 09:17:00 AM »
The image is a little blurry. Are you asking how to change the orange text?

The orange text is the kick/ban reason.

In chat:
!kick Bot01 Kick reason here...
!ban Bot01 1h Ban reason here...



Advanced customizations would require changes to lua/ulx/modules/sh/util.lua
9
General Chat & Help and Support / Re: Text question
« Last post by Soda on January 25, 2020, 07:58:35 AM »
I don’t know, I searched all the source files and didn’t find it. Can’t you tell me the approximate path or name of the source file
10
Developers Corner / Re: Error in External MySQL database config - bad key
« Last post by Timmy on January 25, 2020, 03:39:36 AM »
The query looks fine.

That if-statement looks odd.

There's a # in front of query2. The length operator (#) is used to get the length of a table or string.

Note that the GetData function returns a table of result rows. It takes a few more steps to access the rank.

Try to debug the select query a little further. Perhaps you could try something like this (untested)?
Code: [Select]
query2.onSuccess = function()
    local results = query2:getData()
    local result = results[1] -- Get first result

    if result then
        PrintTable(result)

        if result.ulx_rank ~= currentulxrank then
            print("TODO: Update user rank from " .. result.ulx_rank .. " to " .. currentulxrank)
        else
            print("No update required")
        end
    else
        print("No results for this SteamID")
    end
end
Pages: [1] 2 3 ... 10