|
You last visited: Today at 15:28
Advertisement
[Help CoEmu V2] Lil help on a code
Discussion on [Help CoEmu V2] Lil help on a code within the CO2 Private Server forum part of the Conquer Online 2 category.
07/07/2009, 17:38
|
#1
|
elite*gold: 0
Join Date: Aug 2007
Posts: 310
Received Thanks: 13
|
[Help CoEmu V2] Lil help on a code
Im still new to this but im creating an npc and i want to learn how to let it show text based on your level like:
Level 1 :
Hello lvl 1
Level 2:
Hello lvl 2
Level 3 :
Hello lvl 3
And no i dont want it like this:
Hello + CSocket.Client.Name
Question 2 :
I want it to check if its Level 1 or 2 or 3 or 4 or 5 etc...
and i already tried
if (CSocket.Client.Level == 1)
if (CSocket.Client.Level == 2)
if (CSocket.Client.Level == 3)
|
|
|
07/07/2009, 18:01
|
#2
|
elite*gold: 0
Join Date: Aug 2008
Posts: 780
Received Thanks: 255
|
Well if you mean like an NPC that tells what level you want then that'd be possible but just really really long.. (Depends on how many levels you have in your server)
Example
Code:
case Bla://LVL NPC
{
if (LinkBack == 0)
{
if (CSocket.Client.Level == 1) <--- not sure :p
{
Text("You are level 1", CSocket);
Link("Duhh", 1,CSocket);
End(CSocket);
}
if (LinkBack == 0)
{
if (CSocket.Client.Level == 2)
{
Text("You are level 2", CSocket);
Link("Duhh", 2, CSocket);
End(CSocket);
}
break;
}
if that's what you mean.. I made that in like a second.. I'm sure there's a lot easier way like "You are CHARLEVEL" but don't feel like figuring it out..
|
|
|
07/07/2009, 18:41
|
#3
|
elite*gold: 0
Join Date: Aug 2007
Posts: 310
Received Thanks: 13
|
Quote:
Originally Posted by n0mansland
Well if you mean like an NPC that tells what level you want then that'd be possible but just really really long.. (Depends on how many levels you have in your server)
Example
Code:
case Bla://LVL NPC
{
if (LinkBack == 0)
{
if (CSocket.Client.Level == 1) <--- not sure :p
{
Text("You are level 1", CSocket);
Link("Duhh", 1,CSocket);
End(CSocket);
}
if (LinkBack == 0)
{
if (CSocket.Client.Level == 2)
{
Text("You are level 2", CSocket);
Link("Duhh", 2, CSocket);
End(CSocket);
}
break;
}
if that's what you mean.. I made that in like a second.. I'm sure there's a lot easier way like "You are CHARLEVEL" but don't feel like figuring it out..
|
Nope it's for the db lvler:P
|
|
|
07/07/2009, 18:59
|
#4
|
elite*gold: 0
Join Date: Aug 2008
Posts: 780
Received Thanks: 255
|
I'm not really sure how to do Unknown man yet.. I mean I could if I sat down and worked on it..
|
|
|
07/07/2009, 19:50
|
#5
|
elite*gold: 0
Join Date: Jun 2009
Posts: 361
Received Thanks: 99
|
I tried making an Npc like that using your example n0mansland, when I finished everything looked good except the word default; on the line below it was underlined in red and idk why. Maybe my code is not positioned right or something?
|
|
|
07/07/2009, 21:03
|
#6
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Quote:
Originally Posted by n0mansland
I'm not really sure how to do Unknown man yet.. I mean I could if I sat down and worked on it..
|
I have it done, and as for your script you listed you could do it without an if for each level
simply use
Text("You are level" + CSocket.Client.Level + " currently", CSocket);
close your quotes, put in a + and you can add the function directly into the npc script
Then instead of using a 'if level == number (you have to use ==, that's saying is equal to, = means you are saying this = this (setting it as something)) you can also use a
if (CSocket.Client.Level >= 1 && CSocket.Client.Level <= 100)
&& means and also
so if level is between 1 and 100 then the section below runs, you can use segments like that instead of coding for each level
Also fyi you could use
if (CSocket.Client.Level == 1 || CSocket.Client.Level == 2)
|| means or basically or, so if EITHER of those are true it does section below.
Hope that helps you with some of your functions
|
|
|
07/07/2009, 21:22
|
#7
|
elite*gold: 20
Join Date: Mar 2008
Posts: 958
Received Thanks: 494
|
in loft
Quote:
SendPacket(General.MyPackets.NPCSay("Hello " + MyChar.Name + " You are level " + MyChar.Level + " .. Stop Posting threads"));
SendPacket(General.MyPackets.NPCLink("Ok .. .", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
|
|
|
|
07/07/2009, 21:58
|
#8
|
elite*gold: 0
Join Date: Aug 2007
Posts: 310
Received Thanks: 13
|
You all understand me wrong i just wanted an example so i could work on the db lvler.
BUT! Now who can help me on question 2?
|
|
|
07/07/2009, 22:40
|
#9
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Quote:
Originally Posted by xellios
You all understand me wrong i just wanted an example so i could work on the db lvler.
BUT! Now who can help me on question 2?
|
What I posted is what you would use for a db lvler
You simply have it check inventory for an item, if it does then have it take the item and add a level
If you want other checks such as level being less then something just use
if (CSocket.Client.Level <= level you want less then)
For db check I suggest you look at the metbank npc, it checks for mets/db's in it's script so just look for where it counts how many there are
+ it's a good script to learn from cause it does a few different things including storing a new value under character data, loading that data, using/checking/saving it in a npc command, counting/removing/checking items in inventory and a few other things.
All very useful sections of code that can be applied to just about any npc idea you have
All you have to do is read it/understand what the coding means and you can alter it to apply to just about anything, that thread is a great place to start for that.
Thanks if it helps :O
|
|
|
07/07/2009, 22:43
|
#10
|
elite*gold: 0
Join Date: Aug 2007
Posts: 310
Received Thanks: 13
|
Ok but now question 1 is answered who can help me on question 2!
|
|
|
07/07/2009, 22:58
|
#11
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,379
|
Quote:
Originally Posted by xellios
Ok but now question 1 is answered who can help me on question 2!
|
oops, I didn't see question 2 srry.
Hmmm, for the php side I'd just google something to use php to add something to a mysql database (or just look at how it's done in a registration page)
For the client side that part I can do.
Personally I'd put it under characters (so it's saved to their character, not an individual table just for donation)
Add a field to character database calling it what you want, for example donation
Again, using sections from Metbank npc (credit to them obviously
bottom of chat.cs
Code:
public static void Donation(int value, ClientSocket CSocket)
{
CSocket.Client.Donation += value;
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.Donation, Struct.StatusTypes.Donation));
}
database.cs (where the other ones like it are, search for the wh money one just like in metbank
Code:
Client.Donation = Convert.ToInt32(DR["Donation"]);
database.cs
Code:
public static void SaveDonation(ClientSocket CSocket)
{
MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `Donation` = " + CSocket.Client.Donation + " WHERE `CharID` = " + CSocket.Client.ID + "", DatabaseConnection.NewConnection());
Cmd.ExecuteNonQuery();
Cmd.Connection.Close();
Cmd.Connection.Dispose();
Cmd.Dispose();
}
statustype.cs
character.cs
Code:
public int Donation = 0;
Then for the npctalk part just do something like
Code:
if (CSocket.Client.Donation = value wanted)
{ Text("You can claim your donation reward" , CSocket);
other options here (such as what is rewarded)
Donation(NumberRemoved, CSocket);
Database.Database.SaveDonation(CSocket);
}
else
Text("You do not have a donation to claim" , CSocket);
Obviously not a working npctalk but that's how you would do it, the php side just needs to add a value to the character table to set it to whatever it needs to be
|
|
|
07/08/2009, 10:01
|
#12
|
elite*gold: 0
Join Date: Aug 2007
Posts: 310
Received Thanks: 13
|
The client side is working now thanks but i cant work it out with the php side cuz im not that well at combining mysql&php like i told you
|
|
|
 |
Similar Threads
|
Guild deletion code error coemu...
03/03/2010 - CO2 Private Server - 0 Replies
this codes written perfectly but i keep getting an error message...
public static void DeleteGuild(int ID)
{
if (Nano.Guilds.ContainsKey(ID))
{
Struct.GuildInfo GuToDel = Nano.Guilds;
foreach (int ChId in GuToDel.GMems)
{
try
{
|
coemu unreachable code??
03/01/2010 - CO2 Private Server - 8 Replies
foreach (KeyValuePair<int, Struct.GuildInfo> Gui in Nano.Guilds)
i checked this and it all seems good 0.0
Warning 1 Unreachable code detected C:...\PacketProcessor.cs 494 85 CoEmu v2 GameServer
dame XD
|
[REQUEST] Someone with knowlege of how to code into coemu
10/27/2009 - CO2 Private Server - 14 Replies
Hey Guys, well i started CoEmu source, (the one andy released) iv implemented a hell of a lot of things, however i don't quite get some of the errors i encounter, i may pay somebody to teach me away around these codes, or how to just fix them, PM me please, it's very much appreciated.
|
[Tutorial][For who can't Code] Code Simple NPC (CoEmu)
10/15/2009 - CO2 Private Server - 13 Replies
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
default:
{
Text("NPC " + ID + "'s dialog is not coded.", CSocket);
|
Npc code help - CoEmu v2
06/14/2009 - CO2 Private Server - 6 Replies
This is just a nooby release for the Hairstyler npc and for hairdyes I just got working, I will add more on here as I finish them, be gentle this is my first release :).
//Edit: Changed the title since I got it finished/fixed it myself
Add in this block of code somewhere in NpcTalk.cs
Now to add Hairdyes, go to UseItem.cs and add this block of code.
That's all I have to offer at the moment sorry, I been kinda busy lately.
|
All times are GMT +1. The time now is 15:30.
|
|