Jump to content
  • 0

NPC alter a SQL table


Dust87

Question


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  24
  • Reputation:   0
  • Joined:  04/28/14
  • Last Seen:  

Hi guys !

I would be greatfull if someone can tell me how to make a NPC wich is able to alter a custom SQL Table.

I want to create a system that can randomly create a quest (or at least select one in a SQL table) but I have no idea how to do that and if it's possible
Thanks for your help! ?

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

Let me try to point you to the right direction mate.

  1. https://github.com/rathena/rathena/wiki/Basic-Scripting
  2. https://github.com/rathena/rathena/blob/429541fb81ac5d54007b42eb9ca9393bb01d0856/doc/script_commands.txt#L8210-L8238
  • Spoiler

    *query_sql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});
    *query_logsql("your MySQL query"{, <array variable>{, <array variable>{, ...}}});


    Executes an SQL query. A 'select' query can fill array variables with up to 2 billion rows of
    values, and will return the number of rows (i.e. array size) or -1 on failure.


    Note that 'query_sql' runs on the main database while 'query_logsql' runs on the log database.


    Example:
        .@nb = query_sql("select name,fame from `char` ORDER BY fame DESC LIMIT 5", .@name$, .@fame);
        mes "Hall Of Fame: TOP5";
        mes "1." + .@name$[0] + "(" + .@fame[0] + ")"; // largest fame value.
        mes "2." + .@name$[1] + "(" + .@fame[1] + ")";
        mes "3." + .@name$[2] + "(" + .@fame[2] + ")";
        mes "4." + .@name$[3] + "(" + .@fame[3] + ")";
        mes "5." + .@name$[4] + "(" + .@fame[4] + ")";


    ---------------------------------------


    *escape_sql(<value>)


    Converts the value to a string and escapes special characters so that it is safe to
    use in query_sql(). Returns the escaped form of the given value.


    Example:
        .@name$ = "John's Laptop";
        .@esc_str$ = escape_sql(.@name$); // Escaped string: John\'s Laptop


    ---------------------------------------

     

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...