King12 Posted October 25, 2017 Share Posted October 25, 2017 Hello there, let's say, I've inserted a random serial in SQL, and wanted to load it when player joins and compare if his serial matches the one in the database. How can I compare it? i'm still learning on SQL, would be great if you offer help. [Note: the random serial is a string inserted from a command] Link to comment
King12 Posted October 25, 2017 Author Share Posted October 25, 2017 What am I doing wrong? [Sorry if it looks stupid, but I'm still learning so] attempt to index field '?' (a nil value) [Line 5] addEventHandler('onPlayerLogin', root, function () local serialofJoiner = getPlayerSerial(source) local checkSerial = executeSQLQuery("SELECT * FROM `offlinemutes` WHERE playerSerial = ?", serial ) if serialofJoiner == checkSerial[1]['playerSerial'] then if not ( type ( checkSerial ) == 'table' and #checkSerial == 0 or not checkSerial ) then outputChatBox("You should be muted") else return end else return end end ) Link to comment
King12 Posted October 26, 2017 Author Share Posted October 26, 2017 fixed it, one last question. is it possible to mute someone by console if he joins using. executeCommandHandler("mute",source , name.." "..reason.." "..seconds) source here returns the player who joined, so that means if he doesn't have /mute permission, he will not be muted. so, any idea how to mute that person by console? Link to comment
King12 Posted October 26, 2017 Author Share Posted October 26, 2017 (edited) I apologize for the bump, but I can't update my replies. I've added a check to see if the serial is in table then it should just update it, but the fact I can't select a column, it updates all columns for xDuration as seen in the images. addCommandHandler("update", root, function (player, cmd, duration) executeSQLQuery("UPDATE Xofflinemuts SET xDuration=?", duration ) outputChatBox("Updated Duration", player, 0, 255, 0) end ) Edited October 26, 2017 by King12 Link to comment
Captain Cody Posted October 26, 2017 Share Posted October 26, 2017 Been a while so not too certain, but executeSQLQuery("UPDATE Xofflinemuts SET xDuration=? WHERE `playerSerial`=?", duration,Serial ) Not tested. 1 Link to comment
King12 Posted October 26, 2017 Author Share Posted October 26, 2017 58 minutes ago, CodyJ(L) said: Been a while so not too certain, but executeSQLQuery("UPDATE Xofflinemuts SET xDuration=? WHERE `playerSerial`=?", duration,Serial ) Not tested. Thanks a lot dude! Link to comment
King12 Posted October 26, 2017 Author Share Posted October 26, 2017 one last question. is it possible to mute someone by console if he joins using. executeCommandHandler("mute",source , name.." "..reason.." "..seconds) source here returns the player who joined, so that means if he doesn't have permission to /mute , he will not be muted. any idea how to mute that person by console? Link to comment
Administrators Lpsd Posted October 26, 2017 Administrators Share Posted October 26, 2017 https://wiki.multitheftauto.com/wiki/SetPlayerMuted Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now