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

  • 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!

  • 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.

sOxTw

Member
Jan 27, 2017
35
2
8
30
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_language.skript:
on chat:
    set {_chat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%player%'"
    if {_chat::*} = "ON":
        loop all players:
            set {_loopchat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%loop-player%'"
            set {_loopuser::*} to objects in column "Usuario" from result of query "SELECT Usuario FROM `{@clanes}` WHERE `ChatMode` = 'SPY'"
            if {_loopchat::*} = "SPY":
                broadcast "&7Loop variable: %{_loopuser::*}%"
                send "{@prefijoChatSpy} %{_PrefixPlayer}%  &8» &f%message%" to loop-player
                stop

What am I failing?
 
did you try this?

code_language.skript:
on chat:
    set {_chat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%player%'"
    broadcast "%{_chat::*}%"
    if {_chat::*} = "ON":
        loop all players:
            set {_loopchat::*} to objects in column "ChatMode" from result of query "SELECT ChatMode FROM `{@clanes}` WHERE `Usuario` = '%loop-player%'"
            set {_loopuser::*} to objects in column "Usuario" from result of query "SELECT Usuario FROM `{@clanes}` WHERE `ChatMode` = 'SPY'"
            broadcast "%{_loopchat::*}%"
            broadcast "%{_loopuser::*}%"
            if {_loopchat::*} = "SPY":
                broadcast "&7Loop variable: %{_loopuser::*}%"
                send "{@prefijoChatSpy} %{_PrefixPlayer}%    &8» &f%message%" to loop-player
                stop

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
 
I will be testing and I will say thank you very much for the help. I had not tried it this way.
 
  • Like
Reactions: Tinkot
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.

Thank you very much I'm testing it to see if it works
[doublepost=1525837848,1525835070][/doublepost]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_language.skript:
Options:
    clans: clan_info
on skriitp load:
    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?
 
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_language.skript:
on script load:
    set {sql} to the database "mysql://123.12.123.123:3306/mydatabase?user=myusername&password=mypassword&useSSL=false"
    wait 1 tick
    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}

#your uuid need to be in the database in order to return data with this test command. otherwise it will return <none>
command /test:
    trigger:
        set {_uuid} to "%Player's UUID%"
        execute "SELECT * FROM clan_info WHERE uuid = '%unsafe {_uuid}%'" in {sql} and store result in {_output::*}
        broadcast "%{_output::*}%"
        broadcast "%{_output::Clan::*}%"
        broadcast "%{_output::Rango::*}%"
        broadcast "%{_output::Usuario::*}%"
        broadcast "%{_output::ChatMode::*}%"
        broadcast "%{_output::UUID::*}%"


#broadcasting your output
command /updatesomething:
    trigger:
        set {_uuid} to "%Player's UUID%"
        execute "UPDATE clan_info SET Clan = 'SkriptClan' WHERE UUID = '%unsafe {_uuid}%'" in {sql}
 
Last edited:
Thank you very much for the help. now I test if everything works correctly: D
 
Status
Not open for further replies.