|
You last visited: Today at 02:18
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.
07/08/2009, 10:32
|
#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
|
|
|
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.
|
|
|
07/08/2009, 11:56
|
#3
|
elite*gold: 0
Join Date: May 2009
Posts: 52
Received Thanks: 3
|
Thanks for comprehensio
|
|
|
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
|
|
|
07/08/2009, 13:20
|
#5
|
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
|
Quote:
Originally Posted by yuko
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
|
|
|
07/09/2009, 02:50
|
#6
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by nuhali
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();
}
}
}
|
|
|
07/09/2009, 16:26
|
#7
|
elite*gold: 0
Join Date: Jun 2008
Posts: 97
Received Thanks: 16
|
tnx
|
|
|
07/10/2009, 02:59
|
#8
|
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
|
Quote:
Originally Posted by nuhali
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.
|
|
|
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
|
|
|
All times are GMT +1. The time now is 02:18.
|
|