MYSQL reading data problem

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

snakercz_

Member
Jun 5, 2017
13
0
1
So there is a thing - I'm creating an anti-swear skript for czech server, aaaand that means we have swears with special letters as ř/č/á etc etc

And there I want to save these to MYSQL. Pretty simple. Well when I'm adding and removing swears, everything is okay, words keep adding to database. But there comes the problem.

Let's say I have word rohlik (not a swear word, just example). In our language, correct writing is "rohlík" (there is í instead of i), but I want in database both variants (since not everyone here uses diacritics in minecraft). So I added "rohlik" into the database and now I want to add "rohlík" and there is problem - it says it is already added. But when I type in in chat, it doesn't blank it. So I'm thinking that main problem is that when it checks database, it for some reason ignores the diacritics and instead of "rohlík" it reads as "rohlik". How can I prevent this?

Code of add swear:
Code:
#ano=true, no=false
    else if arg-1 is "addswear":
      if player has permission "chat123.addswear":
        if arg-2 is not set:
          send "&cPoužití: /chat123 addswear <slovo>"
        else:
          set {_wordisinmysql1::*} to objects in column "enabled" from result of query "SELECT `enabled` FROM `swearwords` WHERE `value` = '%arg-2%'"
          set {_wordisinmysql} to first element out of {_wordisinmysql1::*}   
          if {_wordisinmysql} is not set:
            update "INSERT INTO `swearwords` (`enabled`, `value`) VALUES ('ano', '%arg-2%');"
            send "&aSlovo &b%arg-2% &abylo přidáno na seznam zakázaných slov!"
          else if {_wordisinmysql} is "ano":
            send "&cSlovo &b%arg-2% &cjiž je na seznamu zakázaných slov!"     
          else if {_wordisinmysql} is "ne":
            update "UPDATE `swearwords` SET `enabled` = 'ano' WHERE `value` = '%arg-2%';"
            send "&aSlovo &b%arg-2% &abylo opět přidáno na seznam zakázaných slov!"
      else:
        send "&cNope."

Code of chat censoring system:
Code:
    set {_swears::*} to objects in column "value" from result of query "SELECT `value` FROM `swearwords` WHERE `enabled` = 'ano'"
    loop {_swears::*}:
        if {_message} contains "%loop-value%":
            replace "%loop-value%" with "**" in {_message}

Also, when I add it manually via phpmyadmin, it works and blanks the word successfully, but when I disable swear words, it replaces both values with value in command (so /chat123 removeswear rohlík sets "enabled" to false in database, but it also replaces the collumn "value" in database, so before command there was rohlik and rohlík, now it is two rohlík)

Skript version: Skript ver. 2.2-dev27
Server version: spigot 1.8.8
Addons using: SkQuery 3.21.4

I have multiple skripts running on server using mysql same as in my code, and there is no problem.

Before end - sure, I can add words manually via phpmyadmin, but i think it is more comfortable via command and if there is way to get this working... well I want it :emoji_grinning:


thanks for every help message
[doublepost=1559504113,1558542891][/doublepost]^
 
So there is a thing - I'm creating an anti-swear skript for czech server, aaaand that means we have swears with special letters as ř/č/á etc etc

And there I want to save these to MYSQL. Pretty simple. Well when I'm adding and removing swears, everything is okay, words keep adding to database. But there comes the problem.

Let's say I have word rohlik (not a swear word, just example). In our language, correct writing is "rohlík" (there is í instead of i), but I want in database both variants (since not everyone here uses diacritics in minecraft). So I added "rohlik" into the database and now I want to add "rohlík" and there is problem - it says it is already added. But when I type in in chat, it doesn't blank it. So I'm thinking that main problem is that when it checks database, it for some reason ignores the diacritics and instead of "rohlík" it reads as "rohlik". How can I prevent this?

Code of add swear:
Code:
#ano=true, no=false
    else if arg-1 is "addswear":
      if player has permission "chat123.addswear":
        if arg-2 is not set:
          send "&cPoužití: /chat123 addswear <slovo>"
        else:
          set {_wordisinmysql1::*} to objects in column "enabled" from result of query "SELECT `enabled` FROM `swearwords` WHERE `value` = '%arg-2%'"
          set {_wordisinmysql} to first element out of {_wordisinmysql1::*} 
          if {_wordisinmysql} is not set:
            update "INSERT INTO `swearwords` (`enabled`, `value`) VALUES ('ano', '%arg-2%');"
            send "&aSlovo &b%arg-2% &abylo přidáno na seznam zakázaných slov!"
          else if {_wordisinmysql} is "ano":
            send "&cSlovo &b%arg-2% &cjiž je na seznamu zakázaných slov!"   
          else if {_wordisinmysql} is "ne":
            update "UPDATE `swearwords` SET `enabled` = 'ano' WHERE `value` = '%arg-2%';"
            send "&aSlovo &b%arg-2% &abylo opět přidáno na seznam zakázaných slov!"
      else:
        send "&cNope."

Code of chat censoring system:
Code:
    set {_swears::*} to objects in column "value" from result of query "SELECT `value` FROM `swearwords` WHERE `enabled` = 'ano'"
    loop {_swears::*}:
        if {_message} contains "%loop-value%":
            replace "%loop-value%" with "**" in {_message}

Also, when I add it manually via phpmyadmin, it works and blanks the word successfully, but when I disable swear words, it replaces both values with value in command (so /chat123 removeswear rohlík sets "enabled" to false in database, but it also replaces the collumn "value" in database, so before command there was rohlik and rohlík, now it is two rohlík)

Skript version: Skript ver. 2.2-dev27
Server version: spigot 1.8.8
Addons using: SkQuery 3.21.4

I have multiple skripts running on server using mysql same as in my code, and there is no problem.

Before end - sure, I can add words manually via phpmyadmin, but i think it is more comfortable via command and if there is way to get this working... well I want it :emoji_grinning:


thanks for every help message
[doublepost=1559504113,1558542891][/doublepost]^
You could create a system that replaces every character like í, é etc with the 'normal' version of that letter in a local variable, so that you don't need to have that much stuff in your database.
PS: take a look at https://forums.skunity.com/resources/antiswear.522/, I did the same thing there
 
You could create a system that replaces every character like í, é etc with the 'normal' version of that letter in a local variable, so that you don't need to have that much stuff in your database.
PS: take a look at https://forums.skunity.com/resources/antiswear.522/, I did the same thing there

i just tried what did you recommend but i think i don't get it exactly... can you explain it better? Cause again-my problem is i can add diacritics into database bcs it doesnt recognize Í and Í as different letters for some reason. And i need to block both and I also want chat with diacritics...

thx for reply
 
i just tried what did you recommend but i think i don't get it exactly... can you explain it better? Cause again-my problem is i can add diacritics into database bcs it doesnt recognize Í and Í as different letters for some reason. And i need to block both and I also want chat with diacritics...

thx for reply
1) You add every word to the database, BUT no 'special' characters (e.g. í, è etc.).
2) In the chat event, you set a local variable to the message. Then you replace every 'special' character with their 'normal' version (e.g. í become i, è becomes e etc.). Then you loop over the database values, and check if the local variable contains the loop-value. If it does, cancel the event.
 
Status
Not open for further replies.