public override void OnSelfAction(string actionID) { List <LabelID> options = new List <LabelID>(); foreach (KeyValuePair <string, string> pair in requests) { ShItem i = SceneManager.Instance.GetEntity <ShItem>(pair.Value); if (i) { options.Add(new LabelID(pair.Key + " : " + i.itemName, pair.Key)); } } player.svPlayer.SendOptionMenu("Requests", player.ID, requestMenu, options.ToArray(), new LabelID[] { new LabelID("Accept", accept), new LabelID("Deny", deny) }); }
public void RequestAdd(int sourceID, string itemName) { if (!requestItems.Contains(itemName)) { Debug.LogError("[SVR] Item not valid: " + itemName); return; } ShItem item = SceneManager.Instance.GetEntity <ShItem>(itemName); if (!item) { Debug.LogError("[SVR] Item not found: " + itemName); return; } ShPlayer requester = EntityCollections.FindByID <ShPlayer>(sourceID); if (!requester) { Debug.LogError("[SVR] Requester not found"); return; } if (requester.HasItem(item.index)) { requester.svPlayer.SendGameMessage("Already own item"); } else if (requester.MyMoneyCount < item.value) { requester.svPlayer.SendGameMessage("Not enough money"); } else if (requests.ContainsKey(requester.username)) { requester.svPlayer.SendGameMessage("Previous request still pending"); } else { requests[requester.username] = itemName; requester.svPlayer.SendGameMessage("Request successfully sent"); ShPlayer mayor = info.members.FirstOrDefault(); if (mayor) { mayor.svPlayer.SendGameMessage(requester.username + " requesting a " + item.itemName); } } }
public override void OnEmployeeAction(ShPlayer target, string actionID) { List <LabelID> options = new List <LabelID>(); foreach (string s in requestItems) { ShItem item = SceneManager.Instance.GetEntity <ShItem>(s.GetPrefabIndex()); if (item) { options.Add(new LabelID(item.itemName + ": $" + item.value, s)); } } // Negative playerID means job action is called on the employer with that ID, not self target.svPlayer.SendOptionMenu("Items", -player.ID, itemMenu, options.ToArray(), new LabelID[] { new LabelID("Request", string.Empty) }); }
public void ResultHandle(string requesterName, string result) { if (!requests.TryGetValue(requesterName, out string itemName)) { Debug.LogError("[SVR] Requester invalid: " + requesterName); return; } if (EntityCollections.Accounts.TryGetValue(requesterName, out ShPlayer requester)) { if (result == accept) { ShItem item = SceneManager.Instance.GetEntity <ShItem>(itemName); if (item) { if (requester.MyMoneyCount >= item.value) { requester.TransferMoney(DeltaInv.RemoveFromMe, item.value); requester.TransferItem(DeltaInv.AddToMe, item); player.TransferMoney(DeltaInv.AddToMe, item.value); } else { player.svPlayer.SendGameMessage("Player missing funds"); requester.svPlayer.SendGameMessage("No funds for license"); } } } else if (result == deny) { requester.svPlayer.SendGameMessage("License Denied"); } } requests.Remove(requesterName); OnSelfAction(null); }