1. 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 comminuty!

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

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[on chat:] with MySQL variables (Help me)

Discussion in 'Skript' started by sOxTw, May 7, 2018.

Thread Status:
Not open for further replies.
  1. sOxTw

    sOxTw Member

    Joined:
    Jan 27, 2017
    Messages:
    35
    Likes Received:
    2
    Hello I need help, when trying to do a send "" loop-player using variables obtained from MySQL, it does not send to all the users that are in the list. Could you guide me in this?
    - if they ask, do not give any error in the console, simply the message is sent only to the first player that enters and has declared "SPY" in its MySQL registry

    Skript Plugin Version: 2.2-Mineplex-Core-Patch

    Code (Skript):
    1. on chat:
    2.     set {_chat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%player%'"
    3.     if {_chat::*} = "ON":
    4.         loop all players:
    5.             set {_loopchat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%loop-player%'"
    6.             set {_loopuser::*} to objects in column "Usuario" from result of query "SELECT Usuario FROM `{@clanes}` WHERE `ChatMode` = 'SPY'"
    7.             if {_loopchat::*} = "SPY":
    8.                 broadcast "&7Loop variable: %{_loopuser::*}%"
    9.                 send "{@prefijoChatSpy} %{_PrefixPlayer}%  &8» &f%message%" to loop-player
    10.                 stop
    What am I failing?
     
  2. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    did you try this?

    Code (Skript):
    1. on chat:
    2.     set {_chat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%player%'"
    3.     broadcast "%{_chat::*}%"
    4.     if {_chat::*} = "ON":
    5.         loop all players:
    6.             set {_loopchat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%loop-player%'"
    7.             set {_loopuser::*} to objects in column "Usuario" from result of query "SELECT Usuario FROM `{@clanes}` WHERE `ChatMode` = 'SPY'"
    8.             broadcast "%{_loopchat::*}%"
    9.             broadcast "%{_loopuser::*}%"
    10.             if {_loopchat::*} = "SPY":
    11.                 broadcast "&7Loop variable: %{_loopuser::*}%"
    12.                 send "{@prefijoChatSpy} %{_PrefixPlayer}%    &8» &f%message%" to loop-player
    13.                 stop
    14.  
    if its not returning anything it means your database is not setup correct or your query is not correct. maybe changing all ` with ' works. I also heard the default mysql function of skript is broken. i started using skript-db myself. hope i helped you out
     
  3. sOxTw

    sOxTw Member

    Joined:
    Jan 27, 2017
    Messages:
    35
    Likes Received:
    2
    I will be testing and I will say thank you very much for the help. I had not tried it this way.
     
    • Like Like x 1
  4. Snow-Pyon

    Moderator Resource Staff

    Joined:
    Jan 25, 2017
    Messages:
    1,236
    Likes Received:
    176
    Medals:
    1. You shouldn't use that version of Skript, use bensku's fork instead.
    2. I wouldn't recommend skQuery's SQL, it has its issues and can cause lag that way. Use skript-db instead.
     
    • Like Like x 1
  5. sOxTw

    sOxTw Member

    Joined:
    Jan 27, 2017
    Messages:
    35
    Likes Received:
    2
    Thank you very much I'm testing it to see if it works
    --- Double Post Merged, May 9, 2018, Original Post Date: May 9, 2018 ---
    I have a problem now, it's a big change I do not understand how to create tables, how to consult them among other things.

    The following piece of code was used to create a table that does not:

    Code (Skript):
    1. Options:
    2.     clans: clan_info
    3. on skriitp load:
    4.     update "CREATE TABLE IF NOT EXISTS `{@clan}` (`Clan` varchar(255),`Rango` varchar(255),`Usuario` varchar(255), `ChatMode` varchar(255),`UUID` varchar(255))"
    Now it gives error, it is obsolete.
    - how is it to create a table with Skriot-db (addon)?
    - How are consultations made?
     
  6. Tinkot

    Tinkot Active Member

    Joined:
    Feb 10, 2018
    Messages:
    57
    Likes Received:
    1
    sometimes you have to put %unsafe {_variable}%. its not explained very well in the docs but it should always work just fine using the unsafe expression if its a text variable
    Code (Skript):
    1. on script load:
    2.     set {sql} to the database "mysql://123.12.123.123:3306/mydatabase?user=myusername&password=mypassword&useSSL=false"
    3.     wait 1 tick
    4.     update "CREATE TABLE IF NOT EXISTS clan_info (`Clan` varchar(255),`Rango` varchar(255),`Usuario` varchar(255), `ChatMode` varchar(255),`UUID` varchar(255))" in {sql}
    5.  
    6. #your uuid need to be in the database in order to return data with this test command. otherwise it will return <none>
    7. command /test:
    8.     trigger:
    9.         set {_uuid} to "%Player's UUID%"
    10.         execute "SELECT * FROM clan_info WHERE uuid = '%unsafe {_uuid}%'" in {sql} and store result in {_output::*}
    11.         broadcast "%{_output::*}%"
    12.         broadcast "%{_output::Clan::*}%"
    13.         broadcast "%{_output::Rango::*}%"
    14.         broadcast "%{_output::Usuario::*}%"
    15.         broadcast "%{_output::ChatMode::*}%"
    16.         broadcast "%{_output::UUID::*}%"
    17.  
    18.  
    19. #broadcasting your output
    20. command /updatesomething:
    21.     trigger:
    22.         set {_uuid} to "%Player's UUID%"
    23.         execute "UPDATE clan_info SET Clan = 'SkriptClan' WHERE UUID = '%unsafe {_uuid}%'" in {sql}
     
    #6 Tinkot, May 9, 2018
    Last edited: May 9, 2018
  7. sOxTw

    sOxTw Member

    Joined:
    Jan 27, 2017
    Messages:
    35
    Likes Received:
    2
    Thank you very much for the help. now I test if everything works correctly: D
     
Thread Status:
Not open for further replies.

Share This Page

Loading...