Jump to content

comparing player serial with a string serial. SQL


King12

Recommended Posts

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

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

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

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.

 

rfBWrbTdTIyQ4TpmwR7Nzw.png

qRWEnWB8RKuhB6a5cHu1Jw.png

 

addCommandHandler("update", root,
function (player, cmd, duration) 
  executeSQLQuery("UPDATE Xofflinemuts SET xDuration=?", duration )
  outputChatBox("Updated Duration", player, 0, 255, 0)
end
)

 

Edited by King12
Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...