Jump to content
  • 0

sql script


sader1992

Question


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

hello

i want to make script copy from table to table

 

OnTimer10000:

copy the account_id + str + value

from global_reg_value

and delete them

and make chg in  acc_reg_num

 

edit on the account_id

 

str = key

 

value = {value(global_reg_value)+value(acc_reg_num)}

 

 

or

 

 

set (global_reg_value)account_id = playeracc

 

set (global_reg_value)value = pointsupdate

 

atcommand"#CASHPOINTS "+playeracc" "+pointsupdate;

 

and delete the line in the table or set value(global_reg_value) = 0

 

 

 

 

Is this possible?

Edited by sader1992
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

like this

-	script	update points	-,{
OnPCLoginEvent:
query_sql( "SELECT `account_id`,`value` FROM `global_reg_value` ",.@iduser,.@valueuser );
.idus = .@iduser;
.valueus = .@valueuser;
query_sql("UPDATE `acc_reg_num` SET account_id = '"+.idus+"', key = #CASHPOINTS,  value = (value + '"+.valueus+"')");
query_sql("UPDATE `global_reg_value` SET account_id = 0, key = 0,  value = 0");
end;
}

but there is error~

anyone?

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Hmm maybe

-	script	update points	-1,{
OnPCLoginEvent:
	query_sql "INSERT INTO `acc_reg_num` (`account_id`, `key`, `index`, `value`) select account_id, '#CASHPOINTS', 0, `value` from `global_reg_value` where `account_id` "+
		"= '"+ getcharid(3) +"' on duplicate key update `acc_reg_num`.`value` = `acc_reg_num`.`value` + `global_reg_value`.`value`";
	query_sql "delete from `global_reg_value` where account_id = "+ getcharid(3) +" and `str` = '#CASHPOINTS'";
	end;
}
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

 

Hmm maybe

-	script	update points	-1,{
OnPCLoginEvent:
	query_sql "INSERT INTO `acc_reg_num` (`account_id`, `key`, `index`, `value`) select account_id, '#CASHPOINTS', 0, `value` from `global_reg_value` where `account_id` "+
		"= '"+ getcharid(3) +"' on duplicate key update `acc_reg_num`.`value` = `acc_reg_num`.`value` + `global_reg_value`.`value`";
	query_sql "delete from `global_reg_value` where account_id = "+ getcharid(3) +" and `str` = '#CASHPOINTS'";
	end;
}

 

Thank you

it's work Perfect

 

Solved

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Note it should be better to run the sql offline in one go (you save memory)

INSERT INTO `acc_reg_num` (`account_id`, `key`, `index`, `value`) select account_id, '#CASHPOINTS', 0, `value` from `global_reg_value` on duplicate key update `acc_reg_num`.`value` = `acc_reg_num`.`value` + `global_reg_value`.`value`

delete from `global_reg_value` where `str` = '#CASHPOINTS'
  • Upvote 1
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...