Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 22/01/20 in all areas

  1. Mano........................ presta só um pouco de atenção, não precisa nem ser muito, eu copiei só o comando, troque o comando apenas que esta la por esse.......
    2 points
  2. I am not a string reg prof, but it works... ? local theString = "254646" local length = string.len(theString) local visibleCount = math.max(length - 2, 0) print(string.rep("*", string.len(string.sub(theString, 1, visibleCount))) .. string.sub(theString, visibleCount, length))
    1 point
  3. See https://wiki.multitheftauto.com/wiki/Split http://Lua-users.org/wiki/StringLibraryTutorial string.len string.rep local emailParts = split("[email protected]", "@") iprint(emailParts[1]) iprint(emailParts[2]) iprint(emailParts[1] .. "@" .. emailParts[2]) iprint(string.rep("*", string.len(emailParts[1])) .. "@" .. emailParts[2])
    1 point
  4. How do I implement the following action. There is a row in the database with the name "uid" How to check if there is no such UID then writes an error. Example: User type in edit UID "2" but it is not in the database, there is only "1" then The message appears with error. if user type in edit UID "1" then The message appears without error. --server dbSecurityConnection = dbConnect( 'sqlite', 'test.db') dbExec( dbSecurityConnection, ' CREATE TABLE if not exists `accs` (uid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, login) ' ) function date(uid, userlogin) dbExec( dbSecurityConnection, ' INSERT INTO `accs` VALUES(?, ? ) ', uid, userlogin) end
    1 point
  5. You can't index a non existing table. So you have to check if it exist before indexing a second time. if result[1] then
    1 point
  6. UID works just like a normal id. I’ll ask a little different. function fun1 () dbSecurityConnection = dbConnect( 'sqlite', 'accs.db') local getAnswerData = dbQuery( dbSecurityConnection, ' SELECT `email` FROM `accs` WHERE uid = ? ', 1 ) local result = dbPoll( getAnswerData, -1 ) local finduid = result[1].email outputChatBox ( ""..finduid.."" ) end addCommandHandler ( "tt", fun1 ) If I use this code, I use "1" in line local getAnswerData = dbQuery( dbSecurityConnection, ' SELECT `email` FROM `accs` WHERE uid = ? ', 1 ) I will get the output in chat: "mail.ru" if i use "2" in line local getAnswerData = dbQuery( dbSecurityConnection, ' SELECT `email` FROM `accs` WHERE uid = ? ', 2 ) i will get the output in chat: "dat.ru" It all works as planned BUT if i use "3" in line: local getAnswerData = dbQuery( dbSecurityConnection, ' SELECT `email` FROM `accs` WHERE uid = ? ', 3 ) As you can see on the screen of the database, there is no such line(with uid "3") A question: How can I make it so that when I type a non-existent UID in the database, I get an error in the chat NOT in code like this: I wanted to use something like this, but it not working: function fun1 () dbSecurityConnection = dbConnect( 'sqlite', 'accs.db') local getAnswerData = dbQuery( dbSecurityConnection, ' SELECT `email` FROM `accs` WHERE uid = ? ', 3 ) if getAnswerData then local result = dbPoll( getAnswerData, -1 ) local finduid = result[1].email outputChatBox ( ""..finduid.."" ) else outputChatBox ( "error" ) end end addCommandHandler ( "tt", fun1 )
    1 point
  7. I am not sure what uid is. But normally you would have 1 column called: id Which auto increment when items are added. This value makes sure that each item added is unique. In some cases for example a login system you can also set the username as primary key, which is to prevents duplication for the usernames. So make sure that you understand your own data. LIMIT is used to select only a maximum items. If you need 1 item, you put the limit to 1, so that the database knows that it has to stop when it found what it is looking for. - Selecting a max amount of items. - Increase the performance.
    1 point
  8. It was just an example How to write it right? I need to know how to write a condition for checking in the database. need to check on the line "UID" on datebase and if this is not found then If in "uid" there will be such values as "1" and "2" how to work with other? I guess in the line "Limit 1" work is underway on this figure, but if it is in the database? I can be wrong, I have not worked with it yet. It is necessary that there is a check for "uid" and if this is not the case, then the method of exclusion In this case, there are no more digits 3 and above , but if appear "3" in uid how then to write correctly? Then there should be a check if This is in the database.
    1 point
  9. Use the SELECT query. It is not as if you should combine queries. The error is given because it is protecting itself from item duplication. Which means that it already went wrong. SELECT uid FROM accs WHERE uid = ? LIMIT 1
    1 point
  10. Yes it is possible but no one will tell you. Ask the author for an unencrypted version.
    0 points
×
×
  • Create New...