void impactLock(BaseLock baseLock, BasePlayer player, bool Result) { var locker = baseLock.GetComponent <CodeLock>(); if (Result) { locker.whitelistPlayers.Add(player.userID); locker.SetFlag(CodeLock.Flags.Locked, false); Effect.server.Run(locker.effectUnlocked.resourcePath, baseLock.GetComponent <CodeLock>(), 0u, Vector3.zero, Vector3.forward, null, false); Effect.server.Run("assets/prefabs/deployable/research table/effects/research-success.prefab", player, 0u, Vector3.zero, Vector3.forward, null, false); } else { Effect.server.Run(locker.effectShock.resourcePath, baseLock.GetComponent <CodeLock>(), 0u, Vector3.zero, Vector3.forward, null, false); Effect.server.Run("assets/prefabs/deployable/research table/effects/research-fail.prefab", player, 0u, Vector3.zero, Vector3.forward, null, false); } }
void RobBox(BasePlayer player) { if (!permission.UserHasPermission(player.UserIDString, crackeryUse)) { SendReply(player, msg("Permission", player.UserIDString)); return; } RaycastHit hitinfo; if (Physics.Raycast(player.eyes.position, Quaternion.Euler(player.GetNetworkRotation()) * Vector3.forward, out hitinfo, 5f, LayerMask.GetMask(new string[] { "Deployed" }))) { if ((hitinfo.GetEntity().PrefabName == sBoxName || hitinfo.GetEntity().PrefabName == BoxName || (hitinfo.GetEntity().PrefabName == CupName && cupAllowed)) && hitinfo.GetEntity().HasSlot(BaseEntity.Slot.Lock)) { BaseLock baseLock = hitinfo.GetEntity().children[0].GetComponent <BaseLock>(); if (!baseLock.GetComponent <CodeLock>().whitelistPlayers.Contains(player.userID)) { if (!playerTimers.ContainsKey(player.userID)) { playerTimers.Add(player.userID, new Cracker()); } if (!playerTimers[player.userID].isUnlocking) { if (unlockItem != 0) { if (player.inventory.containerMain.FindItemsByItemID(unlockItem).Count != 0) { player.inventory.containerMain.Take(null, unlockItem, 1); } else { SendReply(player, msg("Item", player.UserIDString), ItemManager.CreateByItemID(unlockItem).info.displayName.english); return; } } SendReply(player, msg("Start", player.UserIDString)); var dPos = player.transform.position; Vector3 cPos; playerTimers[player.userID].isUnlocking = true; playerTimers[player.userID].AtAll = timer.Once(unlockTime, () => { FinishCrack(player, baseLock); }); playerTimers[player.userID].GUI = timer.Every(1, () => { playerTimers[player.userID].amountGUI += (double)1 / unlockTime; cPos = player.transform.position; if (Vector3.Distance(dPos, cPos) > moveAmount) { StopUnlocking(player); SendReply(player, msg("Moved", player.UserIDString)); Effect.server.Run("assets/prefabs/deployable/research table/effects/research-fail.prefab", player, 0u, Vector3.zero, Vector3.forward, null, false); return; } CuiHelper.DestroyUi(player, "UnlockGUI"); UnlockGUI(player, playerTimers[player.userID].amountGUI); }); playerTimers[player.userID].Effects = timer.Every(11, () => { Effect.server.Run("assets/prefabs/deployable/research table/effects/research-start.prefab", player, 0u, Vector3.zero, Vector3.forward, null, false); if (unlockEffects) { Effect.server.Run(EffectName, baseLock.GetComponent <CodeLock>(), 0u, Vector3.zero, Vector3.forward, null, false); } }); playerTimers[player.userID].Effects.Callback(); } else { SendReply(player, msg("Locking", player.UserIDString)); } } else { SendReply(player, msg("WhiteList", player.UserIDString)); } } else { SendReply(player, msg("Object", player.UserIDString)); } } else { SendReply(player, msg("Look", player.UserIDString)); } }