예제 #1
0
 public void TakeContract()
 {
     if (TruckingPlugin.getActiveContract(Context.Player.SteamUserId) != null)
     {
         Context.Respond("You cannot take another contract while you have an active one. To quit a contract use !contract quit", "The Boss");
     }
     else
     {
         TruckingPlugin.GenerateContract(Context.Player.SteamUserId, Context.Player.IdentityId);
     }
 }
예제 #2
0
        public static Boolean StorePatchMethod(MyStoreBlock __instance, long id, int amount, long targetEntityId, MyPlayer player, MyAccountInfo playerAccountInfo)
        {
            MyStoreItem storeItem = (MyStoreItem)null;
            bool        proceed   = false;

            foreach (MyStoreItem playerItem in __instance.PlayerItems)
            {
                MyCubeGrid grid = __instance.CubeGrid;
                if (FacUtils.GetFactionTag(FacUtils.GetOwner(grid)) != null && FacUtils.GetFactionTag(FacUtils.GetOwner(grid)).Length > 3 && TruckingPlugin.config.NPCGridContracts)
                {
                    proceed = true;
                }
                if (!grid.Editable || !grid.DestructibleBlocks)
                {
                    proceed = true;
                }

                if (__instance.DisplayNameText != null && __instance.DisplayNameText.ToLower().Contains("hauling contracts") && proceed)
                {
                    if (playerItem.Id == id)
                    {
                        storeItem = playerItem;
                        break;
                    }
                }
            }
            //this does things
            if (storeItem != null && proceed)
            {
                if (MyBankingSystem.GetBalance(player.Identity.IdentityId) >= storeItem.PricePerUnit)
                {
                    //if it cant generate a contract, return false
                    if (!TruckingPlugin.GenerateContract(player.Id.SteamId, player.Identity.IdentityId))
                    {
                        return(false);
                    }
                    else
                    {
                        //do the money transfers then return false so the item stays in the store
                        MyBankingSystem.ChangeBalance(player.Identity.IdentityId, (storeItem.PricePerUnit * -1));
                        MyBankingSystem.ChangeBalance(__instance.OwnerId, storeItem.PricePerUnit);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }