public void OnLogout(SagaMap.Packets.Client.GwLogout p) { uint session = p.GetSessionId(); MapClient client = (MapClient)MapClientManager.Instance.Clients()[session]; client.OnDisconnect(); }
private void ProcessItem(MapClient client, string args) { if (args == "") { client.SendSystemMessage(LocalManager.Instance.Strings.ATCOMMAND_ITEM_PARA); } else { try { uint id = uint.Parse(args); Item item = ItemFactory.Instance.GetItem(id); if (item != null) { InventoryAddResult result = client.Character.Inventory.AddItem(ContainerType.BODY, item); client.SendItemAdd(item, ContainerType.BODY, result, 1); } else { client.SendSystemMessage(LocalManager.Instance.Strings.ATCOMMAND_ITEM_NO_SUCH_ITEM); } } catch (Exception) { } } }
public bool ProcessCommand(MapClient client, string command) { try { string[] args = command.Split(" ".ToCharArray(), 2); args[0] = args[0].ToLower(); if (this.commandTable.ContainsKey(args[0])) { CommandInfo cInfo = this.commandTable[args[0]]; if (client.Character.Account.GMLevel >= cInfo.level) { if (args.Length == 2) { cInfo.func(client, args[1]); } else { cInfo.func(client, ""); } } else { client.SendSystemMessage(LocalManager.Instance.Strings.ATCOMMAND_NO_ACCESS); } return(true); } } catch (Exception e) { Logger.ShowError(e, null); } return(false); }
public void OnPartyInviteCancel(SagaMap.Packets.Client.InviteCancel p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } try { MapClient client = (MapClient)MapClientManager.Instance.GetClient(this.Char.PartyTarget); if (client == null) { this.Char.PartyTarget = 0; return; } ActorPC target = client.Char; if (target != null) { target.PartyTarget = 0; this.Char.PartyTarget = 0; } } catch (Exception ex) { Logger.ShowError(ex, null); } }
// 0x03 Packets ========================================= /// <summary> /// Receive the packet from the client that demands for the mapid. /// </summary> public void OnSendDemandMapID(SagaMap.Packets.Client.SendDemandMapID p) { if (this.state != SESSION_STATE.IDENTIFIED) { return; } if (this.netIO == null) { MapClient client = null; for (uint i = 0xFFFFFFFF; i > 0xFFFFFF00; i--) { if (MapClientManager.Instance.Clients().ContainsKey(i)) { if (MapClientManager.Instance.Clients()[i].GetType() == typeof(MapClient)) { Logger.ShowWarning("NetIO==null,fixed"); client = (MapClient)MapClientManager.Instance.Clients()[i]; i = 1; } } } this.netIO = client.netIO; } Packets.Server.SendStart sendPacket = new SagaMap.Packets.Server.SendStart(); sendPacket.SetMapID(this.Char.mapID); sendPacket.SetLocation(this.Char.x, this.Char.y, this.Char.z); this.netIO.SendPacket(sendPacket, this.SessionID); this.state = SESSION_STATE.LOADING_MAP; }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { MapClientManager.Instance.check.Abort(); Exception ex = e.ExceptionObject as Exception; Logger.ShowError("Fatal: An unhandled exception is thrown, terminating..."); Logger.ShowError("Error Message:" + ex.Message); Logger.ShowError("Call Stack:" + ex.StackTrace); Logger.ShowError("Trying to save all player's data"); uint[] sessions; sessions = new uint[MapClientManager.Instance.Clients().Count]; MapClientManager.Instance.Clients().Keys.CopyTo(sessions, 0); foreach (uint i in sessions) { try { MapClient client = (MapClient)MapClientManager.Instance.Clients()[i]; if (client.Char == null) { continue; } client.Disconnect(); } catch (Exception) { } } }
public void OnMarketBuyItem(Packets.Client.MarketBuyItem p) { uint id = p.GetItemId(); MarketplaceItem item = MapServer.charDB.GetMarketItem(id); Packets.Server.MarketBuyItem p1 = new SagaMap.Packets.Server.MarketBuyItem(); if (item == null) { p1.SetResult(1); this.netIO.SendPacket(p1, this.SessionID); return; } if (this.Char.zeny < item.price) { p1.SetResult(1); this.netIO.SendPacket(p1, this.SessionID); return; } Mail mail = new Mail(); mail.content = "We are glad to inform you that your registered item at <Regenbogen> Market Place was bought by another Player" + ".\n Here is the money for the sold item.\n We are looking forward to see you at <Regenbogen> again!"; mail.date = DateTime.Now; mail.read = 0; mail.receiver = item.owner; mail.sender = "<Regenbogen>"; mail.topic = "Your item at <Regenbogen> was sold"; mail.zeny = item.price; mail.valid = 30; MapServer.charDB.NewMail(mail); MapServer.charDB.DeleteMarketItem(item); MapClient receiver = MapClientManager.Instance.GetClient(item.owner); if (receiver != null) { receiver.CheckNewMail(); } this.Char.zeny -= item.price; this.SendZeny(); mail = new Mail(); mail.content = "We are glad to inform you that you've successfully bought an item at <Regenbogen> Market Place from another Player" + ".\n Here is the bought item.\n We are looking forward to see you at <Regenbogen> again!"; mail.date = DateTime.Now; mail.read = 0; mail.receiver = this.Char.Name; mail.sender = "<Regenbogen>"; mail.topic = "You've bought an item at <Regenbogen>"; mail.valid = 30; mail.creator = ""; mail.durability = item.item.durability; mail.item = (uint)item.item.id; mail.stack = item.item.stack; MapServer.charDB.NewMail(mail); this.CheckNewMail(); p1.SetResult(0); this.netIO.SendPacket(p1, this.SessionID); }
public void ProcessCommandList(MapClient client, string args) { int CommandCounter = 0; foreach (KeyValuePair <string, CommandInfo> kvp in this.commandTable) { if (kvp.Value.level <= client.Character.Account.GMLevel) { CommandCounter++; //client.SendMessage(_MasterName, "Command " + CommandCounter + ": " + kvp.Key); } } }
public void OnPartyAccept(SagaMap.Packets.Client.PartyAccept p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } if (this.Party != null) { return; } try { byte status = p.GetStatus(); MapClient target = (MapClient)MapClientManager.Instance.GetClient(this.Char.PartyTarget); if (target != null) { if (status == 1) { target.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.OK); SagaMap.Party.Party party; if (target.Party == null) { party = new SagaMap.Party.Party(); party.Leader = target; party.AddMember(target); target.Party = party; } else { party = target.Party; } party.AddMember(this); this.Party = party; //this.Char.PartyStatus = SagaDB.Actors.Party.IN_PARTY; } else // They didnt accept; { this.Char.PartyTarget = 0; target.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.DENIED); } } } catch (Exception ex) { Logger.ShowError(ex, null); } }
public void OnChat(bool Atcommand, SagaMap.Packets.Client.GetChat.MESSAGE_TYPE type, string message) { if (Atcommand) { if (AtCommand.Instance.ProcessCommand(this.client, message)) { return; } } switch (type) { case SagaMap.Packets.Client.GetChat.MESSAGE_TYPE.YELL: this.client.map.SendEventToAllActors(Map.TOALL_EVENT_TYPE.CHAT, new Map.ChatArgs(SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.YELL, message), this.Char, true); break; case SagaMap.Packets.Client.GetChat.MESSAGE_TYPE.PARTY: if (this.client.Party != null) { foreach (MapClient client in this.client.Party.Members) { client.SendMessage(this.Char.name, message, SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.PARTY); } } break; case SagaMap.Packets.Client.GetChat.MESSAGE_TYPE.CHANEL: foreach (Client i in MapClientManager.Instance.Clients().Values) { MapClient client; if (i.GetType() != typeof(MapClient)) { continue; } client = (MapClient)i; if (client.Char == null) { continue; } client.SendMessage(this.Char.name, message, SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.CHANEL); } break; default: this.client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHAT, new Map.ChatArgs(SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.NORMAL, message), this.Char, true); break; } }
// 0x0D / 0x0E Packets ================================== /// <summary> /// Will be called if a player sends a party invite packet /// </summary> /// <param name="p">packet instance containing the to be invited player's name</param> public void OnPartyInvite(SagaMap.Packets.Client.PartyInvite p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } try { string name = p.GetName(); if (name == this.Char.name)// Check if the player is already in a party { this.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.ALREADY_IN_PARTY); } MapClient client = MapClientManager.Instance.GetClient(name); if (client == null)//Check if player with that name exists { this.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.NOT_EXIST); } else { if (client.Party != null) { this.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.ALREADY_IN_PARTY); } else { if (this.Party != null) { if (this.Party.Members.Count == 5) { this.SendPartyInviteResult(SagaMap.Packets.Server.SendPartyInviteResult.Result.MAX_MEMBER); return; } } this.Char.PartyTarget = client.Char.id; this.Char.PartyStatus = SagaDB.Actors.Party.PENDING; client.Char.e.OnPartyInvite(this.Char); } } } catch (Exception ex) { Logger.ShowError(ex, null); } }
private static void ShutingDown(object sender, ConsoleCancelEventArgs args) { Logger.ShowInfo("Closing.....", null); uint[] sessions; sessions = new uint[MapClientManager.Instance.Clients().Count]; MapClientManager.Instance.Clients().Keys.CopyTo(sessions, 0); foreach (uint i in sessions) { try { MapClient client = (MapClient)MapClientManager.Instance.Clients()[i]; if (client.Char == null) { continue; } client.Disconnect(); } catch (Exception) { } } }
// 04 02 /// <summary> /// Receive the whisper from the client. Check if the recipient is online from the MapClientManager /// Send a whisper to the other player. /// </summary> public void OnSendWhisper(SagaMap.Packets.Client.GetWhisper p) { if (this.state != SESSION_STATE.MAP_LOADED) { return; } if (p.isValid()) { if ((byte)this.Char.muted == 0) { string name = p.GetName(); while (name.Substring(name.Length - 1) == "\0") { name = name.Substring(0, name.Length - 1); } MapClient client = MapClientManager.Instance.GetClient(name); if (client == null) { SendMessage("Saga", "This character is not online/doesn't exist"); return; } ActorPC target = client.Char; if (target != null) { target.e.OnSendWhisper(this.Char.name, p.GetMessage(), 2); this.Char.e.OnSendWhisper(name, p.GetMessage(), 0); } else { SendMessage("Saga", "This character is not online/doesn't exist"); } } else { this.SendMessage("Saga", "You have been muted for epic failure"); } } }
public void ProcessTime( MapClient client, string args ) { Packets.Server.SendTime sendPacket = new SagaMap.Packets.Server.SendTime(); string[] inputs = args.Split( " ".ToCharArray() ); int size = ( inputs.Length ); if( size != 3 ) { client.SendMessage( _MasterName, "invalid time (syntax: day hour min" ); return; } client.map.UpdateTime( byte.Parse( inputs[0] ), byte.Parse( inputs[1] ), byte.Parse( inputs[2] ) ); }
public void ProcessTReset( MapClient client, string args ) { client.Char.trading = Trading.NOT_TRADING; client.Char.TradeTarget = 0; client.SendMessage( _MasterName, "Trading status reset" ); }
public void ProcessRDie(MapClient client, string playername) { MapClient target = MapClientManager.Instance.GetClient(playername); if (target != null && (target.Char.stance != Global.STANCE.STAND || target.Char.stance != Global.STANCE.RUN)) { target.Char.HP = 0; target.Char.e.OnDie(); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); target.Char.e.OnActorChangesState(target.Char, arg); target.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, target.Char, false); } else { client.SendMessage(_MasterName, "Player doesn't exist, or isn't standing."); } }
public void ProcessRHeal(MapClient client, string username) { MapClient target = MapClientManager.Instance.GetClient(username); if (target != null) { target.Char.HP = target.Char.maxHP; target.Char.SP = target.Char.maxSP; target.SendCharStatus(0); } else { client.SendMessage(_MasterName, "Player is not online"); } }
private void ProcessMap( MapClient client, string args ) { string[] mapinfo = args.Split( " ".ToCharArray() ); byte mapid; float x, y, z; try { string smap = System.Convert.ToString( mapinfo[0] ); if( MapManager.Instance.GetMapId( smap ) != -1 ) mapid = (byte)MapManager.Instance.GetMapId( smap ); else mapid = System.Convert.ToByte( mapinfo[0] ); if( mapid < 1 || mapid > 33 ) throw new Exception( "wrong mapid" ); if( mapinfo.Length == 4 ) { x = float.Parse( mapinfo[1] ); y = float.Parse( mapinfo[2] ); z = float.Parse( mapinfo[3] ); } else { x = 0f; y = 0f; z = 0f; } } catch( Exception ) { return; } client.map.SendActorToMap( client.Char, mapid, x, y, z ); }
public void ProcessRaw(MapClient client, string args) { Packets.Server.GenericPacket sendPacket = new SagaMap.Packets.Server.GenericPacket(); string[] inputs = args.Split(" ".ToCharArray()); int size = (inputs.Length); for (int i = 0; i < size; i++) { sendPacket.SetData(Conversions.ToByte(inputs[i])); } client.netIO.SendPacket(sendPacket, client.SessionID); }
private void ProcessCash(MapClient client, string args) { }
private void ProcessGetHeight(MapClient client, string args) { client.SendMessage(_MasterName, "x: " + client.Char.x + " y: " + client.Char.y + " z: " + client.Char.z); float myZ = client.map.GetHeight(client.Char.x, client.Char.y); client.SendMessage(_MasterName, "should-z: " + myZ); }
private void ProcessPJump(MapClient client, string args) { }
private void ProcessBroadcast(MapClient client, string args) { }
public PC(MapClient client) { this.client = client; }
private void ProcessInfo(MapClient client, string args) { }
private void ProcessReloadScript(MapClient client, string args) { }
public void ProcessWhopp(MapClient client, string args) { MapClientManager.Instance.ListClientsAndInfo(client); client.SendMessage(_MasterName, "Total online Players:" + MapClientManager.Instance.Players.Count); }
private void ProcessLevel(MapClient client, string args) { }
private void ProcessCallMap(MapClient client, string args) { string[] arg = args.Split(' '); if (arg.Length != 1) { client.SendMessage("Saga", "You MUST supply a mapID"); return; } int map = int.Parse(arg[0]); foreach (MapClient player in MapClientManager.Instance.Players) { if (player.Char.mapID == map) { Map destmap; float destx; float desty; float destz; if (MapManager.Instance.GetMap(client.Char.mapID, out destmap)) { destx = client.Char.x + (float)Global.Random.Next(100, 1000); desty = client.Char.y + (float)Global.Random.Next(100, 1000); destz = destmap.GetHeight(destx, desty); } else { destx = client.Char.x + (float)Global.Random.Next(100,1000); desty = client.Char.y + (float)Global.Random.Next(100, 1000); destz = client.Char.z + 100; } if (client.Char.mapID == player.Char.mapID) client.map.TeleportActor(player.Char, destx, desty, destz); else client.map.SendActorToMap(player.Char, client.Char.mapID, destx, desty, destz); } } }
private void ProcessHeal(MapClient client, string args) { }
private void ProcessJump( MapClient client, string args ) { string[] ords = args.Split( " ".ToCharArray() ); float x, y, z; try { if( ords.Length > 3 ) throw new Exception( "Too many args" ); if( ords.Length == 3 ) { x = float.Parse( ords[0] ); y = float.Parse( ords[1] ); z = float.Parse( ords[2] ); } else { float[] newPos = client.map.GetRandomPos(); x = newPos[0]; y = newPos[1]; z = newPos[2]; } } catch( Exception ) { return; } client.map.TeleportActor( client.Char, x, y, z ); Logger.ShowInfo( "Sending " + client.Char.name + " to location " + x + " " + y + " " + z, null ); client.SendMessage( _MasterName, "You Jump to " + x + " " + y + " " + z ); }
private void ProcessKick(MapClient client, string playername) { }
private void ProcessReloadConfig(MapClient client, string args) { }
private void ProcessSpawn(MapClient client, string args) { }
public void ProcessRCash( MapClient client, string args ) { int tzeny, trufi; string[] inputs = args.Split( " ".ToCharArray() ); if( inputs.Length != 3 ) client.SendMessage( _MasterName, "To remote lootz use ~cash <name> <rufi> <zeny>" ); else { ActorPC remote = client.map.GetPC( inputs[0] ); if( remote == null ) client.SendMessage( _MasterName, "To remote lootz use ~cash <name> <rufi> <zeny>" ); else { trufi = int.Parse( inputs[1] ); tzeny = int.Parse( inputs[2] ); int total = ( tzeny * 10000 ) + trufi; uint modtotal = (uint)Math.Abs( total ); if( total > 0 ) { remote.zeny += modtotal; remote.e.OnSendMessage( "Cashier", "Your monies have been modified" ); } else { if( ( client.Char.zeny - modtotal ) >= 0 ) client.Char.zeny -= modtotal; else client.SendMessage( "Cashier", "Character doesn't have enough money" ); remote.e.OnSendMessage( "Cashier", "Your monies have been modified" ); } client.SendZeny(); } } }
//Be careful with this command private void ProcessCallAll(MapClient client, string args) { }
public void ProcessRes(MapClient client, string args) { if (client.Char.stance == Global.STANCE.DIE) { client.Char.HP = client.Char.maxHP; client.Char.stance = Global.STANCE.REBORN; client.Char.state = 0; client.SendBattleStatus(); client.SendCharStatus(0); Packets.Server.ActorChangeState p1 = new SagaMap.Packets.Server.ActorChangeState(); p1.SetActorID(client.Char.id); p1.SetBattleState(false); p1.SetStance(Global.STANCE.REBORN); client.netIO.SendPacket(p1, client.SessionID); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, client.Char, false); client.map.TeleportActor(client.Char, client.Char.x, client.Char.y, client.Char.z); } else { client.SendMessage(_MasterName, "You aren't dead >:["); } }
private void ProcessRaw(MapClient client, string args) { }
public void ProcessRRes(MapClient client, string playername) { MapClient target = MapClientManager.Instance.GetClient(playername); if (target != null && target.Char.stance == Global.STANCE.DIE) { target.Char.HP = target.Char.maxHP; target.Char.stance = Global.STANCE.REBORN; target.Char.state = 0; target.SendBattleStatus(); target.SendCharStatus(0); Packets.Server.ActorChangeState p1 = new SagaMap.Packets.Server.ActorChangeState(); p1.SetActorID(target.Char.id); p1.SetBattleState(false); p1.SetStance(Global.STANCE.REBORN); target.netIO.SendPacket(p1, target.SessionID); SagaMap.Map.SkillArgs arg = new Map.SkillArgs(); target.map.TeleportActor(target.Char, target.Char.x, target.Char.y, target.Char.z); target.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, arg, target.Char, false); } else { client.SendMessage(_MasterName, "Player doesn't exist or isn't dead."); } }
private void ProcessWhere(MapClient client, string args) { }
public void ProcessTinfo( MapClient client, string args ) { client.SendMessage( "You", "Target: " + client.Char.TradeTarget + " status: " + client.Char.trading ); ActorPC target = (ActorPC)client.map.GetActor( client.Char.TradeTarget ); if( target != null ) client.SendMessage( "Them", "Target: " + target.TradeTarget + " status: " + target.trading ); }
public void ProcessKick(MapClient client, string playername) { MapClient target = MapClientManager.Instance.GetClient(playername); if (target != null) { target.Char.e.OnKick(); client.SendMessage(_MasterName, "Player " + playername + " kicked!"); } else { client.SendMessage(_MasterName, "Player not found"); } }
public void ProcessWeather( MapClient client, string args ) { Global.WEATHER_TYPE newWeather = Global.WEATHER_TYPE.NO_WEATHER; args = args.ToLower(); if( args == "sunny" ) newWeather = Global.WEATHER_TYPE.SUNNY; else if( args == "partly cloudy" ) newWeather = Global.WEATHER_TYPE.PARTLY_CLOUDY; else if( args == "mostly cloudy" ) newWeather = Global.WEATHER_TYPE.MOSTLY_CLOUDY; else if( args == "cloudy" ) newWeather = Global.WEATHER_TYPE.CLOUDY; else if( args == "raining" ) newWeather = Global.WEATHER_TYPE.RAINING; else if( args == "shower" ) newWeather = Global.WEATHER_TYPE.SHOWER; else if( args == "snowing" ) newWeather = Global.WEATHER_TYPE.SNOWING; if( newWeather != Global.WEATHER_TYPE.NO_WEATHER ) { client.map.UpdateWeather( newWeather ); client.SendMessage( _MasterName, "Changed weather to " + newWeather.ToString() ); } else { client.SendMessage(_MasterName, "Invalid weather type, Possible values: "); client.SendMessage(_MasterName, "cloudy,raining,shower,sunny,snowing,partly cloudy,mostly cloudy"); } }
public void ProcessKickAll(MapClient client, string playername) { uint[] sessions; sessions = new uint[MapClientManager.Instance.Clients().Count]; MapClientManager.Instance.Clients().Keys.CopyTo(sessions, 0); foreach (uint i in sessions) { try { MapClient client_ = (MapClient)MapClientManager.Instance.Clients()[i]; if (client_.Char == null) continue; if (client_ == client) continue; client_.Disconnect(); } catch (Exception) { } } client.SendMessage(_MasterName, "All Player kicked"); }
//Be careful with this command private void ProcessCallAll(MapClient client, string args) { string[] arg = args.Split(' '); if (arg.Length != 1) { client.SendMessage("Idiot", "You MUST supply a limit"); return; } int limit = int.Parse(arg[0]); for (int i = 0; i < limit; i++) { MapClient target = MapClientManager.Instance.Players[i]; if (target.Char != null) { Map destmap; float destx; float desty; float destz; if (MapManager.Instance.GetMap(client.Char.mapID, out destmap)) { destx = client.Char.x + (float)Global.Random.Next(100, 1000); desty = client.Char.y + (float)Global.Random.Next(100, 1000); destz = destmap.GetHeight(destx, desty); } else { destx = client.Char.x + (float)Global.Random.Next(100, 1000); desty = client.Char.y + (float)Global.Random.Next(100, 1000); destz = client.Char.z + 100; } if (client.Char.mapID == target.Char.mapID) client.map.TeleportActor(target.Char, destx, desty, destz); else client.map.SendActorToMap(target.Char, client.Char.mapID, destx, desty, destz); } } }
private void ProcessReloadScript(MapClient client, string args) { ProcessBroadcast(null, "Saga is now reloading scripts"); ProcessBroadcast(null, "You may feel laggy"); MapServer.ScriptManager.ReloadScript(client); ProcessBroadcast(null, "Saga completed with reloading scripts"); }
private void ProcessGC(MapClient client, string args) { GC.Collect(); }
private void ProcessRJump( MapClient client, string args ) { string[] ords = args.Split( " ".ToCharArray() ); ActorPC remote = client.map.GetPC( ords[0] ); if( remote == null ) client.SendMessage( _MasterName, "Client does not exist. Useage: ~jump <name> [x,y,z]" ); else { float x, y, z; try { if( ords.Length > 4 ) throw new Exception( "Too many args" ); if( ords.Length == 4 ) { x = float.Parse( ords[1] ); y = float.Parse( ords[2] ); z = float.Parse( ords[3] ); } else { float[] newPos = client.map.GetRandomPos(); x = newPos[1]; y = newPos[2]; z = newPos[3]; } } catch( Exception ) { return; } client.map.TeleportActor( remote, x, y, z ); Logger.ShowInfo( "Sending " + remote.name + " to location " + x + " " + y + " " + z, null ); remote.e.OnSendMessage( _MasterName, "You have been warped to " + x + " " + y + " " + z ); } }
private void ProcessInfo( MapClient client, string args ) { client.SendMessage( _MasterName, "You are " + client.Char.name + " with ActorID: " + client.Char.id ); client.SendMessage( _MasterName, "cLevel: " + ( client.Char.cLevel + 1 ) + ", cExp: " + client.Char.cExp + ", jLevel: " + ( client.Char.jLevel + 1 ) + ", jExp: " + client.Char.jExp ); uint rufi = client.Char.zeny % 10000; uint zeny = client.Char.zeny / 10000; client.SendMessage( _MasterName, "Zeny: " + zeny + ", Rufi: " + rufi ); client.SendMessage(_MasterName, "State: " + client.Char.state + ", stance: " + client.Char.stance); }
public void OnMailSend(SagaMap.Packets.Client.MailSend p) { Mail mail = new Mail(); Item item; Packets.Server.MailSendAnswer p2 = new SagaMap.Packets.Server.MailSendAnswer(); if (!MapServer.charDB.CharExists(0, p.GetName())) { p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.CHARACTER_NAME_NOT_EXIST); this.netIO.SendPacket(p2, this.SessionID); return; } uint fee = p.GetZeny(); mail.content = p.GetContent(); mail.date = DateTime.Now; mail.read = 0; mail.receiver = p.GetName(); mail.sender = this.Char.name; mail.topic = p.GetTopic(); mail.zeny = p.GetZeny(); if (p.Unknown() != 0) { item = this.Char.inv.GetItem(CONTAINER_TYPE.INVENTORY, p.GetSlot()); if (item == null) { mail.valid = 7; } else { fee += 10; if (this.Char.zeny < fee) { p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.NOT_ENOUGH_ZENY); this.netIO.SendPacket(p2, this.SessionID); return; } mail.valid = 30; mail.creator = item.creatorName; mail.durability = item.durability; mail.item = (uint)item.id; mail.stack = item.stack; this.map.RemoveItemFromActorPC(this.Char, p.GetSlot(), item.id, item.stack, ITEM_UPDATE_REASON.SOLD); } } else { mail.valid = 7; } this.Char.zeny -= fee; this.SendZeny(); MapServer.charDB.NewMail(mail); MapClient receiver = MapClientManager.Instance.GetClient(p.GetName()); if (receiver != null) { Packets.Server.MailArrived p1 = new SagaMap.Packets.Server.MailArrived(); p1.SetAmount(1); receiver.netIO.SendPacket(p1, receiver.SessionID); } p2.SetResult(SagaMap.Packets.Server.MailSendAnswer.Results.OK); this.netIO.SendPacket(p2, this.SessionID); }
private void ProcessLie(MapClient client, string args) { client.Char.stance = Global.STANCE.LIE; client.map.SendEventToAllActorsWhoCanSeeActor(Map.EVENT_TYPE.CHANGE_STATE, null, client.Char, true); }
/// <summary> /// Receive the identity of the client. /// </summary> public void OnSendIdentity(SagaMap.Packets.Client.SendIdentity p) { MapClient client = new MapClient(p.GetSessionID()); ActorPC newChar; client.netIO = this.netIO; MapClientManager.Instance.Clients().Add(client.SessionID, client); if (client.state != SESSION_STATE.NOT_IDENTIFIED) { return; } uint charId = p.GetCharID(); Logger.ShowInfo("Got identity (0x010C) from client: " + charId, null); try { newChar = MapServer.charDB.GetChar(charId); if (newChar == null) { throw new Exception("cannot load char"); } } catch (Exception e) { Logger.ShowError(e, null); client.Disconnect(); return; } while ((MapClientManager.Instance.GetClient(newChar.Name) != null)) { Logger.ShowInfo("Character:" + newChar.Name + " already online, kicking...."); MapClientManager.Instance.GetClient(newChar.Name).Disconnect(); } client.Char = newChar; if (client.Char.validationKey != p.GetValidationKey()) { Logger.ShowError("Client " + this.netIO.sock.RemoteEndPoint.ToString() + " sent wrong validation key and got kicked.", null); this.Disconnect(); return; } #if Preview_Version if (MapClientManager.Instance.Players.Count > 10) { this.Disconnect(); return; } #endif if (client.Char.mapID == 0) { if (client.Char.save_map == 0) { client.Char.save_map = 3; client.Char.save_x = -4811.951f; client.Char.save_y = 15936.05f; client.Char.save_z = 3894f; } client.Char.mapID = client.Char.save_map; client.Char.x = client.Char.save_x; client.Char.y = client.Char.save_y; client.Char.z = client.Char.save_z; } if (!MapManager.Instance.GetMap(client.Char.mapID, out client.map)) { Logger.ShowError("Could not obtain map for client " + this.netIO.sock.RemoteEndPoint.ToString() + ".", null); this.Disconnect(); return; } client.CheckWeaponEXP(); client.Char.e = new ActorEventHandlers.PC_EventHandler(client.Char, client); client.Char.Tasks = new Dictionary <string, MultiRunTask>(); client.state = SESSION_STATE.IDENTIFIED; client.Char.invisble = true; client.map.RegisterActor(client.Char, p.GetSessionID()); client.Char.Online = 1; //client.taskHeartbeat.Activate(); //heartbeat service deactivated client.Pc = new PC(client); Logger.ShowInfo("Player:" + client.Char.name + " logged in"); Logger.ShowInfo("Total Player count:" + MapClientManager.Instance.Players.Count.ToString()); }
private void ProcessReloadConfig(MapClient client, string args) { Config.Instance.ReloadConfig(); client.SendMessage(_MasterName, "Configuration reloaded!", SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE); }
private void ProcessGetHeight(MapClient client, string args) { }
private void ProcessRInfo( MapClient client, string args ) { MapClient target = MapClientManager.Instance.GetClient(args); if( target == null ) client.SendMessage( _MasterName, "Client does not exist. Useage: ~info <name>" ); else { client.SendMessage(_MasterName, "Info for " + target.Char.name + " with ActorID: " + target.Char.id); client.SendMessage(_MasterName, "cLevel: " + (target.Char.cLevel + 1) + ", cExp: " + target.Char.cExp + ", jLevel: " + (target.Char.jLevel + 1) + ", jExp: " + target.Char.jExp); uint rufi = target.Char.zeny % 10000; uint zeny = target.Char.zeny / 10000; client.SendMessage( _MasterName, "Zeny: " + zeny + ", Rufi: " + rufi ); } }
public void ProcessMute(MapClient client, string args) { string[] inputs = args.Split(" ".ToCharArray()); if (inputs.Length != 1) { client.SendMessage("Saga", "Usage: !mute playername"); } else { MapClient tomute = MapClientManager.Instance.GetClient(args); if (tomute == null) { client.SendMessage("Saga", "Player does not exist"); } else { if (tomute.Char.muted == 1) tomute.Char.muted = 0; else tomute.Char.muted = 1; } } }
private void ProcessSpawn(MapClient client, string args) { string[] arg = args.Split(' '); if (arg.Length < 3) { client.SendMessage(_MasterName, "Invalid parameters!", SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE); return; } System.IO.FileStream fs = new System.IO.FileStream("autospawn.xml", System.IO.FileMode.Append); System.IO.StreamWriter sw = new System.IO.StreamWriter(fs); sw.WriteLine(" <spawn>"); sw.WriteLine(string.Format(" <id>{0}</id>", arg[0])); sw.WriteLine(string.Format(" <map>{0}</map>", MapManager.Instance.GetMapName(client.Char.mapID))); sw.WriteLine(string.Format(" <x>{0}</x>", (int)client.Char.x)); sw.WriteLine(string.Format(" <y>{0}</y>", (int)client.Char.y)); if (arg.Length == 4) sw.WriteLine(string.Format(" <z>{0}</z>", (int)client.Char.z)); sw.WriteLine(string.Format(" <amount>{0}</amount>", arg[1])); sw.WriteLine(string.Format(" <range>{0}</range>", arg[2])); sw.WriteLine(" </spawn>"); sw.Flush(); fs.Flush(); fs.Close(); client.SendMessage(_MasterName, string.Format("Spawn:{0} amount:{1} range:{2} added", arg[0], arg[1], arg[2]), SagaMap.Packets.Server.SendChat.MESSAGE_TYPE.SYSTEM_MESSAGE); }
public void ProcessNPC( MapClient client, string args ) { uint npcID; try { npcID = uint.Parse( args ); } catch( Exception ) { npcID = 1; } ActorNPC newNPC = new ActorNPC( npcID, 100, 100, 100, 100 ); if( npcID < 10000 ) { //newNPC.e = new ActorEventHandlers.NPC_EventHandler(newNPC, client.map); newNPC.e = new Npc( newNPC, client.map ); } else//Activate AI for sommoned Mobs { Mob mob = MobFactory.GetMob( newNPC.npcType, ref newNPC ); if (mob == null) { client.SendMessage(_MasterName, "Error, Cannot find mob with ID:" + newNPC.npcType); return; } mob.Map = client.map; mob.ai = new SagaMap.Tasks.MobAI( mob ); mob.ai.Start(); newNPC.e = mob; } newNPC.x = client.Char.x + Global.Random.Next( 100 ); ; newNPC.y = client.Char.y + Global.Random.Next( 100 ); newNPC.z = client.Char.z; newNPC.sightRange = Global.MakeSightRange( 100000 ); newNPC.name = "NPC" + Global.Random.Next().ToString(); if( client.map.RegisterActor( newNPC ) ) client.SendMessage( _MasterName, "Spawned NPC with ID " + npcID ); else client.SendMessage( _MasterName, "Error, cannot spawn the npc" ); }
public void ProcessLevel( MapClient client, string args ) { string[] inputs = args.Split(' '); uint cdifference; uint jdifference; args = args.ToLower(); uint level = 1; if( inputs.Length >= 2 ) { uint secondVal; if( uint.TryParse( inputs[1], out secondVal ) ) level = secondVal; } switch (inputs[0]) { case "c": case "char": cdifference = ExperienceManager.Instance.GetExpForLevel((client.Char.cLevel + level - 1), ExperienceManager.LevelType.CLEVEL) - client.Char.cExp; client.Char.cExp = client.Char.cExp + cdifference + 1; ExperienceManager.Instance.CheckExp(client, ExperienceManager.LevelType.CLEVEL); break; case "j": case "job": jdifference = ExperienceManager.Instance.GetExpForLevel((client.Char.jLevel + level - 1), ExperienceManager.LevelType.JLEVEL) - client.Char.jExp; client.Char.jExp = client.Char.jExp + jdifference + 1; ExperienceManager.Instance.CheckExp(client, ExperienceManager.LevelType.JLEVEL); break; case "reset": client.Char.cExp = 1; client.Char.jExp = 1; client.Char.cLevel = 1; client.Char.jLevel = 1; client.SendCharStatus(36); break; default: cdifference = ExperienceManager.Instance.GetExpForLevel((client.Char.cLevel), ExperienceManager.LevelType.CLEVEL) - client.Char.cExp; jdifference = ExperienceManager.Instance.GetExpForLevel((client.Char.jLevel), ExperienceManager.LevelType.JLEVEL) - client.Char.jExp; client.Char.cExp = client.Char.cExp + cdifference + 1; client.Char.jExp = client.Char.jExp + jdifference + 1; ExperienceManager.Instance.CheckExp(client, ExperienceManager.LevelType.CLEVEL); ExperienceManager.Instance.CheckExp(client, ExperienceManager.LevelType.JLEVEL); break; } }
public void ProcessPJump( MapClient client, string args ) { string[] inputs = args.Split( " ".ToCharArray() ); Dictionary<uint, Client> clients = MapClientManager.Instance.Clients(); foreach( Client i in clients.Values ) { MapClient target; if (i.GetType() != typeof(MapClient)) continue; target = (MapClient)i; if (target.Char == null) continue; if( target.Char.name == inputs[0] && client.Char.name != inputs[0] ) { if( inputs.Length != 1 ) { client.SendMessage( _MasterName, "Usage: !pjump <name>" ); } Map destmap; float destx; float desty; float destz; if( MapManager.Instance.GetMap( target.Char.mapID, out destmap ) ) { destx = target.Char.x + 100; desty = target.Char.y + 100; destz = destmap.GetHeight( destx, desty ); } else { destx = target.Char.x; desty = target.Char.y; destz = target.Char.z + 100; } if( client.Char.mapID == target.Char.mapID ) client.map.TeleportActor( client.Char, destx, desty, destz ); else client.map.SendActorToMap( client.Char, target.Char.mapID, destx, desty, destz ); } } }