Skocz do zawartości
  • 0

Przepisanie Kodu pod Skript-db


LordeqHD
 Udostępnij

Pytanie

Witam
Ostatnio szukam osoby która pomoże mi przepisać mój skript używając dodatku skript-db
oto mój skript:

script options:
    $ init com.mysql.jdbc.Driver
    $ db url jdbc:mysql://local:3306/base
    $ db username ***
    $ db password ***
 
options:
        table_prefix: staty_
       
On script load:
    update "CREATE TABLE IF NOT EXISTS `{@table_prefix}Player` (`Gracz` varchar(255),`Zabojstwa` varchar(255),`Zgony` varchar(255),`Poziom RPG` varchar(255),`Progres RPG` varchar(255),`Klasa` varchar(255),`Poziom Klasy` varchar(255),`Ranga` varchar(255))"
 
   
   
   
on join:  
    if {zgony.ilosc::%player%} is not set:
        set {zgony.ilosc::%player%} to 0
        set {zabojstwa.ilosc::%player%} to 0  
        update "INSERT INTO `{@table_prefix}Player` (`Gracz`, `Zabojstwa`, `Zgony`, `Poziom RPG`, `Progres RPG`, `Klasa`, `Poziom Klasy`, `Ranga`, `Kiedy Dolaczyl`) VALUES ('%player%', '0', '0', '0', '0', '0', '0', '%coloured player's prefix%')"      
every 5 second:
    loop all players:
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Poziom RPG` = '%{poziom::%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Klasa` = '%{RPGSkript.klasachat.%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Poziom Klasy` = '%{Klasa.vip.Exp.%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Progres RPG` = '%{xp::%loop-player%}%/%{mxp::%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Zabojstwa` = '%{zabojstwa.ilosc::%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
        update "UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Zgony` = '%{zgony.ilosc::%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"

 

Odnośnik do komentarza
Udostępnij na innych stronach

3 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
Expression Data Source => datasource
Stores the connection information for a data source. This should be saved to a variable in a script load event or manually through an effect command.

The url format for your database may vary! The example provided uses a MySQL database.

Syntax
[the] data(base|[ ]source) [(of|at)] %string%
Examples
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
Effect Execute Statement
Executes a statement on a database and optionally stores the result in a variable. Expressions embedded in the query will be escaped to avoid SQL injection.

If a single variable, such as {test}, is passed, the variable will be set to the number of affected rows.

If a list variable, such as {test::*}, is passed, the query result will be mapped to the list variable in the form {test::<column name>::<row number>}

Syntax
execute %string% (in|on) %datasource% [and store [[the] (output|result)[s]] (to|in) [the] [var[iable]] %-objects%]
Examples
execute "select * from table" in {sql} and store the result in {output::*}
execute "select * from %{table variable}%" in {sql} and store the result in {output::*}
Expression Last Data Source Error => text
Stores the error from the last executed statement, if there was one.

Syntax
[the] [last] (sql|db|data(base|[ ]source)) error
Expression Unsafe Expression => text
Opts out of automatic SQL injection protection for a specific expression in a statement.

Syntax
unsafe %text%
Examples
execute "select %unsafe {columns variable}% from %{table variable}%" in {sql}
execute unsafe {fully dynamic query} in {sql}

Tu jest cała dokumentacja

set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"

to ci się przyda

execute "select %unsafe {columns variable}% from %{table variable}%" in {sql}
execute unsafe {fully dynamic query} in {sql}

Tu masz wykonywanie tych twoich

UPDATE `{@table_prefix}Player` SET `{@table_prefix}Player`.`Zgony` = '%{zgony.ilosc::%loop-player%}%' WHERE `{@table_prefix}Player`.`Gracz` = '%loop-player%'"
Edytowane przez Rejszpat
Odnośnik do komentarza
Udostępnij na innych stronach

  • 0
57 minut temu, LordeqHD napisał:

@Rejszpat

Dzięki za odpowiedź oraz chęć pomocy 
Niestety gdy próbuję przepisać skript wywala błędy :/

Czy mógłby mi ktoś dać przykład jak to zrobić ewentualnie jeśli nie pod skript db to może być poprzez skellett
Pozdrawiam

Możesz pokazać jakie błędy?

Odnośnik do komentarza
Udostępnij na innych stronach

Dołącz do dyskusji

Możesz dodać zawartość już teraz a zarejestrować się później. Jeśli posiadasz już konto, zaloguj się aby dodać zawartość za jego pomocą.

Nieaktywny
Odpowiedz na pytanie...

×   Wklejono zawartość z formatowaniem.   Usuń formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Odnośnik został automatycznie osadzony.   Przywróć wyświetlanie jako odnośnik

×   Przywrócono poprzednią zawartość.   Wyczyść edytor

×   Nie możesz bezpośrednio wkleić grafiki. Dodaj lub załącz grafiki z adresu URL.

 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...