![]() |
|
|
#1 |
|
Архивный участник
Join Date: Jun 2005
Posts: 104
|
Hi I need help on SQL, what i would like to do is to set all players chars adena to 0 even their warehouse and leave one char of player a 5million adena for example.
Anyone have this script? Tnx in advance. |
|
|
|
|
#2 |
|
Архивный участник
Join Date: Jul 2005
Posts: 108
|
This will set the adena amount (assuming your adena item id is 57 in itemdata.txt) to 0 in all chars in the account named 'useraccount' both inventory and warehouse
Be more specific on what you'd like to do with the 5mil you are saing... Code:
UPDATE user_item SET amount = 0 WHERE user_item.char_id = user_data.char_id AND user_item.item_type =57 AND user_data.account_name='useraccount' |
|
|
|
|
#3 |
|
Архивный участник
Join Date: Jun 2005
Posts: 104
|
wow tnx for fast reply... sorry for not being specific... what i would like to do is set all adena amount to zero of all plyers Chars. Not only for specific players but all players and there chars.
After reseting it to zero give one Char of each player a 5Million Adena. 5Million Adena is just a example amount. Again Tnx in Advance. |
|
|
|
|
#4 |
|
Архивный участник
Join Date: Jul 2005
Posts: 108
|
Ok since I wanted to find out also for my self how to do something like that I searched and studied a little about MSSQL Queries
And I actually wrote a script that does this! First of all you run this: Code:
UPDATE user_item SET amount = 0 WHERE user_item.char_id = user_data.char_id AND user_item.item_type =57 Then you run this rather sofisticated :P SQL Query that does exactly what you need! Finds the first character from ALL accounts and gives 5mil adena to it! Only 1 character per account, the first one! ![]() Code:
DECLARE @count int; DECLARE @last int; DECLARE @total int; SET @total = (SELECT COUNT(DISTINCT account_name) AS ccount FROM user_data) SET @count = 0; SET @last = 0; WHILE @total > @count BEGIN SET @last = (SELECT TOP 1 account_id FROM user_data WHERE account_id > @last); DECLARE @charid int; SET @charid = (SELECT TOP 1 char_id FROM user_data WHERE account_id = @last) ; UPDATE user_item SET amount=5000000 WHERE char_id=@charid AND item_type=57 AND warehouse = 0; SET @count = @count + 1; END HAVE FUN!! ![]() EDIT: Did a small correction, added warehouse = 0 as a safety cause you dont want to set 5mil both to users inventory and warehouse (thats 10mil total) |
|
|
|
|
#5 |
|
Архивный участник
Join Date: Jun 2005
Posts: 104
|
Wow MoSs cool tnx...
One more question thus warehouse adena is set to 0? |
|
|
|
|
#6 |
|
Архивный участник
Join Date: Jul 2005
Posts: 108
|
Yes the first query sets all adena to 0 warehouse and inventory, the second adds 5mil to the inventory only
|
|
|
|
|
#7 |
|
Архивный участник
Join Date: Jun 2005
Posts: 104
|
user_data is in l2world right?
|
|
|
|
|
#8 |
|
Архивный участник
Join Date: Jun 2005
Posts: 104
|
MoSs I forgot to ask if also clan warehouse will also be affected? if not can u tell me pls?
tnx in advance. |
|
|
|
|