Jump to content
  • 0

applying to the whole account (SQL)


Question

Posted (edited)

I'm trying to make a quest account bound, but not quite sure how to properly update the sql side of this.
 
what i want to do is to find the following variable on all players and make it apply to the whole account.
 
petquest  to #petquest
 
but the 'petquest' is saved in char_reg_num
 
I need to change it to #petquest and move it to acc_reg_num
 
I'm not sure how to run this on sql. Any help is appreciated!

Edited by Emistry
removed db link.

2 answers to this question

Recommended Posts

  • 0
Posted

Do it using OnPCLogintEvent, haven't tried this hope it works.

 

First query it will check if the character have the petrequest.

Second query will delete data on char_reg_num.

Next line it will set the #petrequest to 1.

-		script	transfer	-1,{
	OnPCLoginEvent:
		query_sql ("SELECT `char_id` FROM `char_reg_num` WHERE `char_id`= '" + getcharid(0) + "' and `key` = 'petquest'", .@char_id$);
		if(.@char_id$ != ""){
			query_sql ("DELETE FROM `char_reg_num` WHERE `char_id`= '" + getcharid(0) + "' and `key` = 'petquest'");
			set #petquest , 1;
			end;
		}
}
  • 0
Posted

well, there are some better way by using SQL Query ... something like...

INSERT INTO àccount_table ( column1,column2 ) VALUES 
SELECT variable,value FROM char_table WHERE variable LIKE 'petquest' 

but since account table save account_id and not char_id, you need some trick like "JOIN TABLE" to update with correct value..

 
for beginner / most easier way ....

OnPCLoginEvent:
    if ( petquest ) {
        #petquest = petquest;
        petquest = 0;
    }
    end;

@sryx

you method are abit wrong here, the char variable will be "re-added" when he server save the char/updating the variable.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...