Post Pacific

Post Pacific (https://postpacific.mmorpg-game.online/index.php)
-   Темы без сохранившегося раздела (https://postpacific.mmorpg-game.online/forumdisplay.php?f=10001)
-   -   How to set Adena of 1 account (https://postpacific.mmorpg-game.online/showthread.php?t=1638)

noypi 28.08.2005 11:45

How to set Adena of 1 account
 
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.

MoSs 28.08.2005 12:09

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'

noypi 28.08.2005 13:35

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.

MoSs 28.08.2005 15:30

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
To set to 0 all adena from ALL players (including builders :P)

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

Of course you realise that you should execute this ONLY when the server is OFFLINE!

HAVE FUN!! :D

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)

noypi 28.08.2005 16:00

Wow MoSs cool tnx...

One more question thus warehouse adena is set to 0?

MoSs 28.08.2005 16:10

Yes the first query sets all adena to 0 warehouse and inventory, the second adds 5mil to the inventory only

noypi 28.08.2005 17:12

user_data is in l2world right?

noypi 29.08.2005 01:39

MoSs I forgot to ask if also clan warehouse will also be affected? if not can u tell me pls?

tnx in advance.


All times are GMT. The time now is 21:41.