[Tutorial][For who can't Code] Code Simple NPC (CoEmu)

05/30/2009 04:06 danielachraf#1
First i will release the npc and explain you alot of good things

The npc

Ok .. here is the npc jail in TwinCity (Enter the jail and go out the jail)

in Handlers / NpcTalk.cs Search for
Code:
default:
                    {
                        Text("NPC " + ID + "'s dialog is not coded.", CSocket);
and above it add :

Code:
                case 435://CPs/money Trader
                    {
                        if (LinkBack == 0)
                        {
                            Text("Would you like To trade 5,000,000 Money for 5,000 CPs ?", CSocket);
                            Link("Sure Why not ?", 1, CSocket);
                            Link("No Thanks!", 255, CSocket);
                            End(CSocket);
                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Money >= 5000000)
                            {
                                Money(-5000000, CSocket);
                                CPs(+5000, CSocket);
                            }
                            else
                            {
                                Text("I'm sorry you do not have the required Money.", CSocket);
                                Link("Okay.", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }
- the npc is in TwinCity called ArenaGuardTang


For who wants to learn

Code:
                        if (LinkBack == 0)
                        {
                            Text("Would you like To trade 5,000,000 Money for 5,000 CPs ?", CSocket);
                            Link("Sure Why not ?", 1, CSocket);
                            Link("No Thanks!", 255, CSocket);
                            End(CSocket);
                        }
This code you must write in each TalkNpc .. (The starter)
- case 435: is the npc ID


and after } we will add
Code:
else if (LinkBack == 1)
what does it mean ?
After Sure why not .. 1, CSocket);
That's mean when you click on sure whynot something will happen

- under else if (LinkBack == 1) you must write {
now let's see when i click sure why not .. What i wanted to do ? i wanted to trade 5mill money for 5k cps ..

- under if { add if (CSocket.Client.Money >= 5000000)
that means that the character has more than 5mill money and under it add {

- and under { we will ad two lines to remove 5mill from my bag and put 5k cps
Code:
Money(-5000000, CSocket);
CPs(+5000, CSocket);
- Money -5000000 means will take from you 5mil and +5000 means will give you 5k cps
- after that you will write }

Now we need to add some lines to finish the npc, under }
Code:
                            else
                            {
                                Text("I'm sorry you do not have the required Money.", CSocket);
                                Link("Okay.", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }
- we use else to tell the char that he haven't money ...
and we will add a dialog again ...

Hmm ... if you want to make the char go to TC for example

After else if (LinkBack == 1) we will add the code to work the npc
under { add
Code:
Teleport([COLOR="Red"]1002[/COLOR], [COLOR="Magenta"]439[/COLOR], [COLOR="Pink"]390[/COLOR], 0, CSocket);
Map id , xCord , yCored

- don't forget after coding to debug the project

- i hope i explained good because i am not good explainer ..
- It is easier than LOTF
- All who know this before help other one if they ask questions because i will go now ..
- Press thanks if you like this guide ..
05/30/2009 04:12 ~*Dutchess*~#2
Good guide mate. very informative. :)
05/30/2009 04:36 araXis#3
Thanks daniel very very helpful guide ;)
05/30/2009 05:14 areudie#4
hey danielachraf thx for the tut now i some how no how to code >< sry newbies here :] just asking some question .. the npc id izzit found from the database?

and after i added the code but when i go in game the npc chat still say npc not coded.
05/30/2009 05:47 mohammed2007#5
Quote:
Originally Posted by danielachraf View Post
First i will release the npc and explain you alot of good things

The npc

Ok .. here is the npc jail in TwinCity (Enter the jail and go out the jail)

in Handlers / NpcTalk.cs Search for
Code:
default:
                    {
                        Text("NPC " + ID + "'s dialog is not coded.", CSocket);
and above it add :

Code:
                case 435://CPs/money Trader
                    {
                        if (LinkBack == 0)
                        {
                            Text("Would you like To trade 5,000,000 Money for 5,000 CPs ?", CSocket);
                            Link("Sure Why not ?", 1, CSocket);
                            Link("No Thanks!", 255, CSocket);
                            End(CSocket);
                        }
                        else if (LinkBack == 1)
                        {
                            if (CSocket.Client.Money >= 5000000)
                            {
                                Money(-5000000, CSocket);
                                CPs(+5000, CSocket);
                            }
                            else
                            {
                                Text("I'm sorry you do not have the required Money.", CSocket);
                                Link("Okay.", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }
- the npc is in TwinCity called ArenaGuardTang


For who wants to learn

Code:
                        if (LinkBack == 0)
                        {
                            Text("Would you like To trade 5,000,000 Money for 5,000 CPs ?", CSocket);
                            Link("Sure Why not ?", 1, CSocket);
                            Link("No Thanks!", 255, CSocket);
                            End(CSocket);
                        }
This code you must write in each TalkNpc .. (The starter)
- case 435: is the npc ID


and after } we will add
Code:
else if (LinkBack == 1)
what does it mean ?
After Sure why not .. 1, CSocket);
That's mean when you click on sure whynot something will happen

- under else if (LinkBack == 1) you must write {
now let's see when i click sure why not .. What i wanted to do ? i wanted to trade 5mill money for 5k cps ..

- under if { add if (CSocket.Client.Money >= 5000000)
that means that the character has more than 5mill money and under it add {

- and under { we will ad two lines to remove 5mill from my bag and put 5k cps
Code:
Money(-5000000, CSocket);
CPs(+5000, CSocket);
- Money -5000000 means will take from you 5mil and +5000 means will give you 5k cps
- after that you will write }

Now we need to add some lines to finish the npc, under }
Code:
                            else
                            {
                                Text("I'm sorry you do not have the required Money.", CSocket);
                                Link("Okay.", 255, CSocket);
                                End(CSocket);
                            }
                        }
                        break;
                    }
- we use else to tell the char that he haven't money ...
and we will add a dialog again ...

Hmm ... if you want to make the char go to TC for example

After else if (LinkBack == 1) we will add the code to work the npc
under { add
Code:
Teleport([COLOR="Red"]1002[/COLOR], [COLOR="Magenta"]439[/COLOR], [COLOR="Pink"]390[/COLOR], 0, CSocket);
Map id , xCord , yCored

- don't forget after coding to debug the project

- i hope i explained good because i am not good explainer ..
- It is easier than LOTF
- All who know this before help other one if they ask questions because i will go now ..
- Press thanks if you like this guide ..

please make video for that
05/30/2009 05:49 jvt619#6
wow nyc released man thanks!
05/30/2009 05:51 Zeroxelli#7
Quote:
Originally Posted by mohammed2007 View Post
please make video for that
...why? It's simply put, just read it again. Also, please; PLEASE; don't quote entire friggin posts x.x
06/19/2009 20:09 mihai90#8
man I want to code "Weapon Master"....can help me?
06/19/2009 20:24 WHITELIONX#9
Excellent guide even though there are several this is an easy explanation :D Next you need to explain how people use MySql to ADD new npcs which do not exist and then we can add extra things to the db.

I want to add a strength factor to items in db so I can adjust the actual attack of a weapon. I can do that client sided already have done but I don`t understand how to modify in MySql :( Nvm I figured it out and have added min and max attack to navicat :D
06/23/2009 23:24 dextercsar#10
I need the maps id please...
06/24/2009 01:21 danielachraf#11
Mapids:
Code:
Desert = 1000,
MysticCastle = 1001, 
TwinCity = 1002,
Mine = 1003,
Promotion = 1004,
Arena = 1005,
Stables = 1006,
BirthVillage = 1010,
PhoenixCastle = 1011,
RebirthMap = 1012,
HawkCave = 1013,
BanditCave = 1014,
BatCave = 1016,
AdvanceZone = 1017,
ApeMoutain = 1020,
DesertCity = 1000,
BirdIsland = 1015, 
DreamLand = 1012,
KylinCave = 1016,
TrainingGround = 1039,
Market = 1036,
Lottery = 700,
Jail = 6000,
GuildArea = 1038
grocery2 = 1009,
mine01 = 1003,
forum = 1004,
horse = 1006,
star01 = 1100,
star02 = 1101,
star03 = 1102,
star04 = 1103,
star05 = 1104,
star10 = 1105,
star06 = 1106,
star07 = 1107,
star08 = 1108,
star09 = 1109,
smith = 1007,
ArmorColour = 1008,
sky = 1012,
warena = 1017,
parena = 1018,
larena = 1019,
mine = 1021,
brave = 1022,
mineone = 1025,
minetwo = 1026,
minethree = 1027,
minefour = 1028,
mineone2 = 1029,
minetwo2 = 1030,
minethree2 = 1031,
minefour2 = 1032,
newbie2 = 1035,
playground = 1039,
mineone3 = 5000,
factionblack = 1037,
skycut = 1040,
skymaze = 1041,
prison2 = 6001,
lineuppass = 1042,
lineup = 1043,
lineup2 = 1044,
lineup3 = 1045,
lineup4 = 1046,
lineup5 = 1047,
lineup6 = 1048,
lineup7 = 1049,
lineup8 = 1050,
riskisland = 1051,
skymaze1 = 1060,
skymaze2 = 1061,
skymaze3 = 1062,
star = 1064,
boa = 1070,
parena1 = 1080,
parena2 = 1081,
newcanyon = 1075,
MapleForest = 1076,
newdesert = 1077,
newisland = 1078,
mysisland = 1079,
riskisland1 = 1063,
idlandmap = 1082,
parenam = 1090,
parenas = 1091,
house01 = 1098,
house03 = 1099,
sanctuary = 1601,
task01 = 1201,
task02 = 1202,
task04 = 1204,
task05 = 1205,
task07 = 1207,
task08 = 1208,
task10 = 1210,
task11 = 1211,
islandsnail = 1212,
desertsnail = 1213,
canyonfairy = 1214,
woodsfairy = 1215,
newplainfairy = 1216,
minea = 1500,
mineb = 1501,
minec = 1502,
mined = 1503,
stask01 = 1351,
stask02 = 1352,
stask03 = 1353,
stask04 = 1354,
slpk = 1505,
hhpk = 1506,
blpk = 1507,
ympk = 1508,
mfpk = 1509,
faction01 = 1550,
faction012 = 1551,
grocery3 = 1510,
forum1 = 1511,
tiger1 = 1512,
jokul01 = 1615,
tiemfiles = 1616,
tiemfiles1 = 1617,
Dgate = 2021,
Dsquare = 2022,
Dcloister = 2023,
Dsigil = 2024,
cordiform = 1645,
faction2 = 1560,
faction3 = 1561,
forum2 = 1707,
Gulf = 1700,
BotJail = 6001,
Dis City = 2039,
07/15/2009 19:45 Jay1029#12
Ok...now try making a guide on how to add an NPC that everyone doesn't already know how to add. I learned that the first day I got into this -.-
Make a guide on how to add the socket npc or something harder. Include detail like you did in this. It was very informative.
10/06/2009 21:30 ahnu#13
Good Job. Lets keep the tutorials going.
10/15/2009 20:43 onlyme64#14
When im making my pk tourny..whats the code to make the system check who the last player standing in the current pk map is and announce them as the winner and maybe even award them an item for winning. Thanks.
Note
Im new to coding and ive started to learn C# from scratch, the best i can do is Console.WriteLine(""); atm =x