Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 02:18

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help] Can i make this shorter?

Discussion on [Help] Can i make this shorter? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
[Help] Can i make this shorter?

Can any help me with the cps command

Quote:
case "cps":
{
if (Command.Length == 2 && CSocket.Client.isPM || CSocket.Client.isGM)
{
int Cps = Convert.ToInt32(Command[1]);
CSocket.Client.CPs += Cps;
CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "You now have " + CSocket.Client.CPs + " CPs.", Struct.ChatType.Top));
CSocket.Send(ConquerPacket.Status(CSocket, 2, CSocket.Client.CPs, Struct.StatusTypes.InvCPoints));
}
break;
}

How can i send cps to every registered users
nuhali is offline  
Old 07/08/2009, 11:54   #2
 
elite*gold: 0
Join Date: Dec 2007
Posts: 226
Received Thanks: 55
not sure about what you meant with every registered user.
a registered user or each char in the database or each char connected on the server.

the code below should work for each char in nano.clientspool
Code:
						
case "cps":
							{
								if(Command.Length == 2 && CSocket.Client.isPM || CSocket.Client.isGM)
								{
                                    [COLOR="Red"]foreach (KeyValuePair<int, ClientSocket> Clients in Nano.ClientPool)[/COLOR]
                                    {
                                        int Cps = Convert.ToInt32(Command[1]);
                                        Clients.Value.Client.CPs += Cps;
                                        Clients.Value.Send(ConquerPacket.Chat(0, "SYSTEM", Clients.Value.Client.Name, "You now have " + Clients.Value.Client.CPs + " CPs.", Struct.ChatType.Top));
                                        Clients.Value.Send(ConquerPacket.Status(Clients.Value, 2, Clients.Value.Client.CPs, Struct.StatusTypes.InvCPoints));
                                    }
								}
								break;
							}
if you want it for each char in the database you'll be better of with a little php else you'll have to select all chars in the source first which would be useless.
yuko is offline  
Thanks
1 User
Old 07/08/2009, 11:56   #3
 
elite*gold: 0
Join Date: May 2009
Posts: 52
Received Thanks: 3
Thanks for comprehensio
habbo245 is offline  
Old 07/08/2009, 12:46   #4
 
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
how can i make a timer that reset every day your cps to 1 cps
nuhali is offline  
Old 07/08/2009, 13:20   #5
 
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
Quote:
Originally Posted by yuko View Post
not sure about what you meant with every registered user.
a registered user or each char in the database or each char connected on the server.

the code below should work for each char in nano.clientspool
Code:
						
case "cps":
							{
								if(Command.Length == 2 && CSocket.Client.isPM || CSocket.Client.isGM)
								{
                                    [COLOR="Red"]foreach (KeyValuePair<int, ClientSocket> Clients in Nano.ClientPool)[/COLOR]
                                    {
                                        int Cps = Convert.ToInt32(Command[1]);
                                        Clients.Value.Client.CPs += Cps;
                                        Clients.Value.Send(ConquerPacket.Chat(0, "SYSTEM", Clients.Value.Client.Name, "You now have " + Clients.Value.Client.CPs + " CPs.", Struct.ChatType.Top));
                                        Clients.Value.Send(ConquerPacket.Status(Clients.Value, 2, Clients.Value.Client.CPs, Struct.StatusTypes.InvCPoints));
                                    }
								}
								break;
							}
if you want it for each char in the database you'll be better of with a little php else you'll have to select all chars in the source first which would be useless.

I need for all char in databse ofline or online
nuhali is offline  
Old 07/09/2009, 02:50   #6
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Quote:
Originally Posted by nuhali View Post
I need for all char in databse ofline or online
Command: (Gives it to all online players)
Code:
                        case "cps":
                            {
                                if (CSocket.Client.isGM || CSocket.Client.isPM)
                                {
                                    foreach (ClientSocket OSocket in Nano.ClientPool.Values)
                                    {
                                        OSocket.Client.CPs += Convert.ToInt32(Command[1]);
                                        OSocket.Send(ConquerPacket.Status(OSocket, 2, OSocket.Client.CPs, Struct.StatusTypes.InvCPoints));
                                        OSocket.Send(ConquerPacket.Chat(0, "SYSTEM", OSocket.Client.Name, "You gianed " + Command[1] + " CPs from " + CSocket.Client.Name + "!", Struct.ChatType.Center));
                                    }
                                    Database.Database.GiveCPs2All(CSocket, Convert.ToInt32(Command[1]));
                                }
                                break;
                            }
Database: (Gives it to all offline Players)
Code:
        public static void GiveCPs2All(ClientSocket CSocket, int Amount)
        {
            MySqlCommand Cmd = new MySqlCommand("SELECT * FROM `characters`", DatabaseConnection.NewConnection());
            MySqlDataReader DR = Cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (DR.Read())
            {
                if (!Nano.ClientPool.ContainsKey(Convert.ToInt32(DR["CharID"])))
                {
                    int Cps = Convert.ToInt32(DR["CPoints"]) + Amount;
                    MySqlCommand Cmd2 = new MySqlCommand("UPDATE `characters` SET `CPoints` = " + Cps + " WHERE `CharID` = " + CSocket.Client.ID + "", DatabaseConnection.NewConnection());
                    Cmd2.ExecuteNonQuery();
                    Cmd2.Connection.Close();
                    Cmd2.Connection.Dispose();
                    Cmd2.Dispose();
                }
            }
        }
kinshi88 is offline  
Thanks
1 User
Old 07/09/2009, 16:26   #7
 
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
tnx
nuhali is offline  
Old 07/10/2009, 02:59   #8
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Quote:
Originally Posted by nuhali View Post
tnx
Press Thanks, don't just say it.

P.s.
I noticed an error in the Database code, I'm sure you can figure it out tho.
kinshi88 is offline  
Thanks
1 User
Old 07/10/2009, 10:44   #9
 
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
kinshi i need help again

how can i make if i you kill a player in map 1000 you get cps
nuhali is offline  
Reply


Similar Threads Similar Threads
WTS 42 sosun dark staff on rsro server starts vith Aa(shorter one)
08/01/2010 - Silkroad Online Trading - 2 Replies
here, offer http://j.imagehost.org/0838/SRO_2010-08-01_02-50- 14_45.jpg
[rsro][server starts with Aa, shorter one] wtb 52 sos bow
07/17/2010 - Silkroad Online Trading - 1 Replies
as i said i want to buy 52 sos bow or maybe 52 +7 bow chinese. offer from here
Shorter DUN Abyss?
11/07/2009 - Dekaron - 7 Replies
Hi folks, Is there a way of shortening the Abyss dun? It takes 45 minutes to spawn the last boss. With speedhack I noticed the counter runs faster (45'/speed hack) but I think it's only on client side. Thanks!
Idea-modify packet like Frenzy skill so it can have shorter reusetime
11/25/2007 - Lineage 2 - 0 Replies
Hi, i have idea. What about when u use some buff(frenzy,zealot...) and u modify packet, so reuse this skill can be not 5min but 30sec? Or buff(frenzy) can be not 90sec but 120sec? I saw it in other mmorpg(Archlord), ppl modified packet and cooldown of skill was 0.... ---- ARCHLORD



All times are GMT +1. The time now is 02:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.