Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   [TOOL] NPCDATA Import / Export - mySQL/PHP (https://postpacific.loc-online.com/showthread.php?t=2548)

Firedaemon 15.11.2005 19:12

[TOOL] NPCDATA Import / Export - mySQL/PHP
 
Greetings,

I shared part of this on RZ in the past; but thought I would share our entire system for managing npc data here on PP.

The following PHP and SQL scripts will allow you to manage your NPC data through mySQL. If you use this and then use something like PHPmyAdmin, you can edit npcdata alot faster, perform complex searches and etc. Its much better than editing in a text editor or Excel. It will also help you to maintain a master npc database having multiple people contribute to the editing.

Also, the SQL has many of the pre-defined npc options already defined. So when it comes to adding new npcs and etc, you can make use of drop down menus and etc making the job much easier.

These scrips make use of the iconv library for PHP to convert the npcdata.txt from UTF-16 into ASCII automatically and viceversa. There is no need for you to save it as ASCII before trying to import it as the script will auto convert it. Same with the export, as it will save as Unicode 16 LE.

You will need to change some values in the php script such as your mysql username, password and possibly path to your npcdata.txt.

There are 3 files included with this release.

isogames_npc.sql - Contains the sql for mySQL
npc_import.php - Imports UTF-16 npcdata.txt into an empty database
npc_export.php - Exports UTF-16 npcdata.txt from the contents of the database

Hope some of you find this useful. This is used by isoGames in our day to day management of npc data. It is mostly bug free. If you have problems with the import, it is more than likeley due to improperly formatted npcdata.txt. If you make sure there are no spaces in the file, then you should be fine.

Nurgl 15.11.2005 19:39

Re: [TOOL] NPCDATA Import / Export - mySQL/PHP
 
Quote:

Originally Posted by Firedaemon
Greetings,

I shared part of this on RZ in the past; but thought I would share our entire system for managing npc data here on PP.

The following PHP and SQL scripts will allow you to manage your NPC data through mySQL. If you use this and then use something like PHPmyAdmin, you can edit npcdata alot faster, perform complex searches and etc. Its much better than editing in a text editor or Excel. It will also help you to maintain a master npc database having multiple people contribute to the editing.

Also, the SQL has many of the pre-defined npc options already defined. So when it comes to adding new npcs and etc, you can make use of drop down menus and etc making the job much easier.

These scrips make use of the iconv library for PHP to convert the npcdata.txt from UTF-16 into ASCII automatically and viceversa. There is no need for you to save it as ASCII before trying to import it as the script will auto convert it. Same with the export, as it will save as Unicode 16 LE.

You will need to change some values in the php script such as your mysql username, password and possibly path to your npcdata.txt.

There are 3 files included with this release.

isogames_npc.sql - Contains the sql for mySQL
npc_import.php - Imports UTF-16 npcdata.txt into an empty database
npc_export.php - Exports UTF-16 npcdata.txt from the contents of the database

Hope some of you find this useful. This is used by isoGames in our day to day management of npc data. It is mostly bug free. If you have problems with the import, it is more than likeley due to improperly formatted npcdata.txt. If you make sure there are no spaces in the file, then you should be fine.

Hmm, this for l2j mysql database ?

Firedaemon 15.11.2005 19:42

No, this is not intended for l2j

oddy 16.11.2005 06:15

Nice management system. Thanks for the share.

Nurgl 16.11.2005 11:04

Quote:

Originally Posted by oddy
Nice management system. Thanks for the share.

Share PHP for convert drop to l2j :lol:

Forbik 16.11.2005 13:55

NPC Data Lines: 3797
Successfully added NPC Data #1
Successfully added NPC Data #2
Successfully added NPC Data #3
Successfully added NPC Data #4
Successfully added NPC Data #5
Successfully added NPC Data #6
== MYSQL ERROR ==


== NPC QUERY ==
string(2177) "
INSERT INTO
npcdata
SET
`class`='warrior',
`id`='7',
`title`='[forest_walking_fungus]',
`level`='9',
`exp`='31378.8',
`acquire_exp_rate`='x.x7',
`undying`='0',
`can_be_attacked`='1',
`acquire_sp`='36',
`race`='plant',
`sex`='male',
`temper`='100',
`safe_height`='100',
`org_jump`='15',
`skill_list`='{@s_burning_wood;@s_plant_weakness}' ,
`magic_list`='{}',
`max_item`='50',
`item_make_list`='{}',
`corpse_make_list`='{{[suede];1;1;xx.xx07};{[cotton_shoes];1;1;6.0695}}',
`additional_make_list`='{}',
`additional_make_multi_list`='{{{{[adena];66;89;100}};70};{{{[leather_shirt];1;1;xx.xx1};{[leather_pants];1;1;xx.xx9}};1.5517};{{{[stem];1;1;xx.xx73};{[suede];1;1;xx.xx24};{[swift_attack_potion];1;1;3.0303}};3.3252}}',
`slot_chest`='[]',
`slot_rhand`='[]',
`slot_lhand`='[]',
`base_attack_type`='fist',
`base_can_penetrate`='0',
`base_attack_range`='40',
`base_damage_range`='{0;0;80;120}',
`base_rand_dam`='30',
`str`='40',
`int`='21',
`dex`='30',
`wit`='20',
`con`='43',
`men`='10',
`hp_increase`='10',
`mp_increase`='3',
`org_hp_regen`='2',
`org_mp_regen`='x.x',
`ground_low`='{70;0;10}',
`ground_high`='{110;-30;30}',
`underwater_low`='{50;0;10}',
`underwater_high`='{0;0;30}',
`fly_low`='{0;0;10}',
`fly_high`='{0;-30;30}',
`float_low`='{0;0;10}',
`float_high`='{0;-30;30}',
`org_earshot`='100',
`sight`='{0;0;2500;120;5}',
`agro_range`='1000',
`org_hp`='xx.x3801724886',
`org_mp`='xx.x8',
`base_defend`='xx.x70490485705',
`base_magic_attack`='x.x170704847468',
`base_magic_defend`='xx.x56383171859',
`base_physical_attack`='xx.x09668033088',
`physical_hit_modify`='x.x5',
`physical_avoid_modify`='0',
`base_attack_speed`='253',
`base_reuse_delay`='0',
`base_critical`='4',
`magic_use_speed_modify`='0',
`status`='{normal}',
`align`='-81',
`collision_radius`='15',
`collision_height`='xx.x',
`category`='{}',
`clan`='{@walking_fungus}',
`clan_help_range`='300',
`guild`='{}',
`pledge`='{}',
`pledge_leader`='0',
`alliance`='{}',
`alliance_leader`='0',
`ignore_clan_list`='{}',
`ruler`='0',
`ruling_domain`='{}',
`npc_ai`='{[forest_walking_fungus]}',
`corpse_time`='7',
`no_sleep_mode`='0'
"


== DB RESULT QUERY ==

SELECT
*
FROM
npcdata
WHERE
id='7'


bool(false)


== NPC TEXT ==
npc_beginwarrior7[forest_walking_fungus]level=9exp=31378.8acquire_exp_rate=3.27undying=0ca n_be_attacked=1acquire_sp=36race=plantsex=maletemp er=100safe_height=100org_jump=15skill_list={@s_bur ning_wood;@s_plant_weakness}magic_list={}max_item= 50item_make_list={}corpse_make_list={{[suede];1;1;xx.xx07};{[cotton_shoes];1;1;6.0695}}additional_make_list={}additional_mak e_multi_list={{{{[adena];66;89;100}};70};{{{[leather_shirt];1;1;xx.xx1};{[leather_pants];1;1;xx.xx9}};1.5517};{{{[stem];1;1;xx.xx73};{[suede];1;1;xx.xx24};{[swift_attack_potion];1;1;3.0303}};3.3252}}slot_chest=[]slot_rhand=[]slot_lhand=[]base_attack_type=fistbase_can_penetrate=0base_atta ck_range=40base_damage_range={0;0;80;120}base_rand _dam=30str=40int=21dex=30wit=20con=43men=10hp_incr ease=10mp_increase=3org_hp_regen=2org_mp_regen=0.9 ground_low={70;0;10}ground_high={110;-30;30}underwater_low={50;0;10}underwater_high={0;0 ;30}fly_low={0;0;10}fly_high={0;-30;30}float_low={0;0;10}float_high={0;-30;30}org_earshot=100sight={0;0;2500;120;5}agro_ra nge=1000org_hp=2xx.xx8017248857org_mp=1xx.xxbase_d efend=xx.xx04904857045base_magic_attack=7.21707048 474684base_magic_defend=xx.xx63831718592base_physi cal_attack=xx.xx96680330876physical_hit_modify=4.7 5physical_avoid_modify=0base_attack_speed=253base_ reuse_delay=0base_critical=4magic_use_speed_modify =0status={normal}align=-81collision_radius=15collision_height=22.5category ={}clan={@walking_fungus}clan_help_range=300guild= {}pledge={}pledge_leader=0alliance={}alliance_lead er=0ignore_clan_list={}ruler=0ruling_domain={}npc_ ai={[forest_walking_fungus]}corpse_time=7no_sleep_mode=0npc_end


Criticle Error. NPC Data Mis Match with key:class having a value of
:(

Firedaemon 16.11.2005 19:52

With every single npc that is added to the database, it checks to make sure that the data added is the same as what was inserted. So after each query it performs a query and compares it.

More than likeley, your NPC data contains data that is not pre-defined in the table structure. For NPC ID#7, check that @walking_fungus is defined in the table field `clan` as a predefined clan. If it is already defined, then examine the row carefully to make sure that it is being parsed correctly. If the clan is not in the field as a pre-defined option, then simply add it.

Forbik 16.11.2005 20:08

This is NPCDATA.txt from PPL2C_v1.0 :(

Cremator 23.01.2006 17:44

Quote:

Originally Posted by Forbik
This is NPCDATA.txt from PPL2C_v1.0 :(

Big 10x to Firedaemon for this great share, I just tune the sql create table script to fit PPL2C_v1.0 npcdata.

Kenster 10.02.2006 20:31

Fire. Not sure if your around, but I tested this many ways, Import script is flawless. If you try to export, and run. It errors with Synatx errors. And there is no way I am going through that many lines of code to find a bug :P

Kenster 12.02.2006 03:58

Very Odd. I started the server with 20 mobs each, until I did ALL of them. Found 4 mobs with Random bugs. Not sure exactly how that happened. But checking ur Scripts now. 1 was missing a }} on AI. Another was missing } on ai, but it doesnt even have AI, default was {}. Another pushed magic_list=add itional something, and another mixed adition_make_list with another.

Firedaemon 12.02.2006 07:44

I have made some changes to my scripts since I originally published. Perhaps I will reshare this coming week. I think it is time :)

Yes there were a few issues with it that I found since I published. Most have been corrected. I dont use the import script hardley but my npcdata is always generated from my mySQL database contents.

I will probably republish the next version on Monday or Tuesday. It does auto EXP calculation based on mob level now and also sets up rates as well as the aquire exp based on my own proprietary formula.

Details soon...

Zil 12.02.2006 19:06

:( i can't do somethig...my php say Error :( Please, can you share maded npcdata.txt?

TuMBLer 14.02.2006 15:21

cool.
thx. very thx.

Kenster 14.02.2006 21:32

Ok. I got it fully working. Although this is listed in the GPL, my modifications are 100% mine. I will show you a like of our new database once I can do it, without giving away the content. Right now it lists the strings for the mobs, and you lazy people would be able to copy and paste perfect c3 mobs :P Anyway. It does work, just it can be buggy.

TuMBLer 14.02.2006 22:19

damn :cry:
seems all works fine but when i try import
at line 540 stops
Code:

NPC Data Lines: 3624
Empty data detected.

Successfully added NPC Data #2
Successfully added NPC Data #3
Successfully added NPC Data #4
Successfully added NPC Data #5
Successfully added NPC Data #6
Successfully added NPC Data #7
Successfully added NPC Data #8
---
Successfully added NPC Data #535
Successfully added NPC Data #536
Successfully added NPC Data #537
Successfully added NPC Data #538
Successfully added NPC Data #539
Successfully added NPC Data #540

in database addet only 540 rows...
no syntax errors ...
nothing...

Kenster 15.02.2006 02:53

Space maybe at the end of the npc to make it think its over?

TuMBLer 15.02.2006 12:37

no spaces =( cheked many times...

Kenster 20.02.2006 18:15

This is what my team made with this for my players
http://l2-paradise.com/npc

Enjoy viewing

melwidh 06.04.2006 16:36

My errors:

With the npcdata of my server:

NPC Data Lines: 3826
== UNIQUE FIELD DATA ==
array(0) {
}

With the one of PP release(with some changes)

NPC Data Lines: 3796
== UNIQUE FIELD DATA ==
array(0) {
}

PD: Sorry for reopen this :oops:


All times are GMT. The time now is 15:10.