From e6a0135724373c4183e727d69cdb094904fd0b5c Mon Sep 17 00:00:00 2001 From: Bara Date: Fri, 6 Jan 2023 13:20:53 +0100 Subject: [PATCH] Init --- dice.sp | 1005 +++++++++++++++++++++++++++++++++++++++++++++ dice/autodice.sp | 93 +++++ dice/functions.sp | 624 ++++++++++++++++++++++++++++ dice/options.sp | 655 +++++++++++++++++++++++++++++ 4 files changed, 2377 insertions(+) create mode 100644 dice.sp create mode 100644 dice/autodice.sp create mode 100644 dice/functions.sp create mode 100644 dice/options.sp diff --git a/dice.sp b/dice.sp new file mode 100644 index 0000000..2ce7d50 --- /dev/null +++ b/dice.sp @@ -0,0 +1,1005 @@ +#pragma semicolon 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef REQUIRE_PLUGIN +#include +#include +#include + +#pragma newdecls required + +#define DICE_SOUND "outbreak/jail/dice/dice.mp3" +#define NEGATIVE_SOUND "outbreak/jail/dice/negative.mp3" +#define NEUTRAL_SOUND "outbreak/jail/dice/neutral.mp3" +#define POSITIVE_SOUND "outbreak/jail/dice/positive.mp3" +#define JIHAD_SOUND "outbreak/jail/dice/jihad/jihad.mp3" +#define EXPLOSION_SOUND "outbreak/jail/dice/jihad/explosion.mp3" + +// Auto Dice +Handle g_hAutoCTDice = null; +bool g_bAutoCTDice[MAXPLAYERS + 1] = { false, ... }; +Handle g_hAutoT1Dice = null; +bool g_bAutoT1Dice[MAXPLAYERS + 1] = { false, ... }; +Handle g_hAutoT2Dice = null; +bool g_bAutoT2Dice[MAXPLAYERS + 1] = { false, ... }; + +int g_iClip1 = -1; + +int g_iCount[MAXPLAYERS + 1] = { 0, ... }; +int g_iNoclipCounter[MAXPLAYERS + 1] = {5, ...}; +int g_iFroggyAir[MAXPLAYERS + 1] = { 0, ... }; + +bool g_bInWater[MAXPLAYERS + 1] = {false, ...}; +bool g_bFroggyjump[MAXPLAYERS + 1] = { false, ... }; +bool g_bFroggyPressed[MAXPLAYERS + 1] = { false, ... }; +bool g_bLongjump[MAXPLAYERS + 1] = { false, ... }; +bool g_bBhop[MAXPLAYERS + 1] = { false, ... }; +bool g_bAssassine[MAXPLAYERS + 1] = { false, ... }; +bool g_bTollpatsch[MAXPLAYERS + 1] = { false, ... }; +bool g_bLose[MAXPLAYERS + 1] = { false, ... }; +bool g_bMirrorMovement[MAXPLAYERS + 1] = { false, ... }; +bool g_bZombie[MAXPLAYERS + 1] = { false, ... }; +bool g_bDecoy[MAXPLAYERS + 1] = { false, ... }; +bool g_bJihad[MAXPLAYERS + 1] = { false, ... }; +bool g_bNoFallDamage[MAXPLAYERS + 1] = { false, ... }; +bool g_bRentner[MAXPLAYERS + 1] = { false, ... }; +bool g_bAWP[MAXPLAYERS + 1] = { false, ... }; +int g_iLover[MAXPLAYERS + 1] = { -1, ... }; +Handle g_hDrugsTimer[MAXPLAYERS + 1] = { null, ... }; +Handle g_hDrunkTimer[MAXPLAYERS + 1] = { null, ... }; +Handle g_hDelayedSlay[MAXPLAYERS + 1] = { null, ... }; +DecoyMode g_dmFuturistic[MAXPLAYERS + 1] = { DecoyMode_Normal, ... }; +float g_fDamage[MAXPLAYERS + 1] = {0.0, ...}; +bool g_bMoreDamage[MAXPLAYERS + 1] = {false, ...}; +bool g_bLessDamage[MAXPLAYERS + 1] = {false, ...}; +bool g_bHeadshot[MAXPLAYERS + 1] = {false, ...}; +bool g_bRespawn[MAXPLAYERS + 1] = {false, ...}; +Handle g_hBitchSlap[MAXPLAYERS + 1] = { null, ... }; +int g_iBSCount[MAXPLAYERS + 1] = { -1, ... }; +Handle g_hLowGravity[MAXPLAYERS + 1] = { null, ... }; +Handle g_hHighGravity[MAXPLAYERS + 1] = { null, ... }; +Handle g_hNoclip[MAXPLAYERS + 1] = { null, ... }; + +Database g_dDB = null; + +bool g_bHosties = false; +bool g_bJail = false; +bool g_bKnockout = false; + +// Pots +bool g_bReady = false; +ArrayList g_aT1Pot = null; +ArrayList g_aT2Pot = null; +ArrayList g_aCTPot = null; + +bool g_bBusy[MAXPLAYERS + 1] = {false, ...}; +Handle g_hDiceTimer[MAXPLAYERS + 1] = {null, ...}; + +ConVar g_cDebug = null; + +bool g_bLateLoad = false; + +enum struct DiceOption { + char Name[32]; + bool Delete; + bool Debug; +} + +#include "dice/sql.sp" +#include "dice/functions.sp" +#include "dice/configs.sp" +#include "dice/options.sp" +#include "dice/autodice.sp" + +public Plugin myinfo = +{ + name = "Dice - Dice that includes CT and 2 T dices", + author = "Bara", + description = "", + version = "1.0", + url = "github.com/Bara" +}; + +public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max) +{ + CreateNative("Dice_IsClientAssassine", Native_IsAssassine); + CreateNative("Dice_HasClientBhop", Native_HasClientBhop); + CreateNative("Dice_LoseAll", Native_LoseAll); + + RegPluginLibrary("dice"); + + g_bLateLoad = late; + + return APLRes_Success; +} + +public void OnPluginStart() +{ + RegConsoleCmd("sm_w", Command_Dice); + RegConsoleCmd("sm_autow", Command_AutoDice); + + HookEvent("player_jump", Event_PlayerJump); + HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre); + HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Pre); + HookEvent("round_start", Event_RoundStart); + HookEvent("round_end", Event_RoundEnd); + HookEvent("smokegrenade_detonate", Event_SmokeDetonate, EventHookMode_Post); + HookEvent("decoy_started", Event_DecoyStarted, EventHookMode_Pre); + + AutoExecConfig_SetCreateFile(true); + AutoExecConfig_SetFile("plugin.dice"); + g_cDebug = AutoExecConfig_CreateConVar("dice_debug", "0", "Enable/Disable debug mode for dice", _, true, 0.0, true, 1.0); + AutoExecConfig_ExecuteFile(); + AutoExecConfig_CleanFile(); + + CSetPrefix("{green}[Dice]{default}"); + + g_bHosties = LibraryExists("hosties"); + g_bJail = LibraryExists("jail"); + g_bKnockout = LibraryExists("knockout"); + + if (g_bLateLoad) + { + g_bReady = ReadDiceOptions(); + } + + g_iClip1 = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1"); + if (g_iClip1 == -1) + { + SetFailState("Unable to find offset for clip."); + } + + g_hAutoCTDice = RegClientCookie("dice_auto_ct_dice", "Auto for T-Dice", CookieAccess_Private); + g_hAutoT1Dice = RegClientCookie("dice_auto_t1_dice", "Auto for T-Dice", CookieAccess_Private); + g_hAutoT2Dice = RegClientCookie("dice_auto_t2_dice", "Auto for T-Dice", CookieAccess_Private); + + LoopClients(i) + { + if (!AreClientCookiesCached(i)) + { + continue; + } + + SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive); + OnClientCookiesCached(i); + } +} + +public void OnClientCookiesCached(int client) +{ + char sBuffer[4]; + + GetClientCookie(client, g_hAutoCTDice, sBuffer, sizeof(sBuffer)); + g_bAutoCTDice[client] = view_as(StringToInt(sBuffer)); + + GetClientCookie(client, g_hAutoT1Dice, sBuffer, sizeof(sBuffer)); + g_bAutoT1Dice[client] = view_as(StringToInt(sBuffer)); + + GetClientCookie(client, g_hAutoT2Dice, sBuffer, sizeof(sBuffer)); + g_bAutoT2Dice[client] = view_as(StringToInt(sBuffer)); +} + +public void OnAllPluginsLoaded() +{ + if (LibraryExists("hosties")) + { + g_bHosties = true; + } + else if (LibraryExists("jail")) + { + g_bJail = true; + } + else if (LibraryExists("knockout")) + { + g_bKnockout = true; + } + + if (!STAMM_IsAvailable()) + { + SetFailState("Can't Load Feature, Stamm is not installed!"); + } + + STAMM_RegisterFeature("VIP SecondDice"); +} + +public int STAMM_OnClientRequestFeatureInfo(int client, int block, Handle &array) +{ + PushArrayString(array, "Zugang zum 2. T-Würfel"); +} + +public void OnLibraryAdded(const char[] name) +{ + if (StrEqual(name, "hosties")) + { + g_bHosties = true; + } + else if (StrEqual(name, "jail")) + { + g_bJail = true; + } + else if (StrEqual(name, "knockout")) + { + g_bKnockout = true; + } +} + +public void OnLibraryRemoved(const char[] name) +{ + if (StrEqual(name, "hosties")) + { + g_bHosties = false; + } + else if (StrEqual(name, "jail")) + { + g_bJail = false; + } + else if (StrEqual(name, "knockout")) + { + g_bKnockout = false; + } +} + +public void OnMapStart() +{ + PrecacheSoundAny(DICE_SOUND); + AddFileToDownloadsTable("sound/" ... DICE_SOUND); + + PrecacheSoundAny(NEGATIVE_SOUND); + AddFileToDownloadsTable("sound/" ... NEGATIVE_SOUND); + + PrecacheSoundAny(NEUTRAL_SOUND); + AddFileToDownloadsTable("sound/" ... NEUTRAL_SOUND); + + PrecacheSoundAny(POSITIVE_SOUND); + AddFileToDownloadsTable("sound/" ... POSITIVE_SOUND); + + PrecacheSoundAny(JIHAD_SOUND, true); + AddFileToDownloadsTable("sound/" ... JIHAD_SOUND); + + PrecacheSoundAny(EXPLOSION_SOUND, true); + AddFileToDownloadsTable("sound/" ... EXPLOSION_SOUND); + + // g_bReady = false; + + // Create hostage zone to fix for shield option + int iEntity = -1; + if((iEntity = FindEntityByClassname(iEntity, "func_hostage_rescue")) == -1) { + int iHostageRescueEnt = CreateEntityByName("func_hostage_rescue"); + DispatchKeyValue(iHostageRescueEnt, "targetname", "fake_hostage_rescue"); + DispatchKeyValue(iHostageRescueEnt, "origin", "-3141 -5926 -5358"); + DispatchSpawn(iHostageRescueEnt); + } +} + +public int Native_IsAssassine(Handle plugin, int numParams) +{ + return g_bAssassine[GetNativeCell(1)]; +} + +public int Native_HasClientBhop(Handle plugin, int numParams) +{ + return g_bBhop[GetNativeCell(1)]; +} + +public int Native_LoseAll(Handle plugin, int numParams) +{ + return g_bLose[GetNativeCell(1)]; +} + +public void OnClientPutInServer(int client) +{ + SDKHook(client, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive); +} + +public void OnClientDisconnect(int client) +{ + ResetDice(client); +} + +public Action OnTakeDamageAlive(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &ammotype, int hitbox, int HitGroup) +{ + if (!IsClientValid(victim)) + { + return Plugin_Continue; + } + + if (g_bNoFallDamage[victim] && damagetype & DMG_FALL) + { + return Plugin_Handled; + } + + if (IsClientValid(attacker)) + { + if (g_bHosties) + { + if (IsClientInLastRequest(attacker) || IsClientInLastRequest(victim)) + { + return Plugin_Continue; + } + } + + if (g_bTollpatsch[attacker]) + { + bool bDamage = view_as(GetRandomInt(0, 1)); + + if (!bDamage) + { + damage = 0.0; + return Plugin_Changed; + } + } + + if (g_bMoreDamage[attacker]) + { + damage *= g_fDamage[attacker]; + return Plugin_Changed; + } + + if (g_bLessDamage[victim]) + { + damage /= g_fDamage[victim]; + return Plugin_Changed; + } + + if (g_bHeadshot[victim] && damagetype & CS_DMG_HEADSHOT) + { + return Plugin_Handled; + } + + if (g_bAWP[attacker]) + { + int iEntity = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon"); + + if (!IsValidEntity(iEntity)) + { + return Plugin_Continue; + } + + char sClass[32]; + GetEntityClassname(iEntity, sClass, sizeof(sClass)); + + if (StrContains(sClass, "awp", false) != -1) + { + g_bAWP[attacker] = false; + + damage = 0.0; + return Plugin_Changed; + } + } + } + return Plugin_Continue; +} + +public Action FGrenades_OnSwitchMode(int client, DecoyMode previousmode, DecoyMode &newmode, int weapon) +{ + if (newmode != g_dmFuturistic[client]) + { + newmode = g_dmFuturistic[client]; + return Plugin_Handled; + } + + return Plugin_Continue; +} + +public Action Command_Dice(int client, int args) +{ + if (Outbreak_IsHideActive() || IsWarActive()) + { + CReplyToCommand(client, "Dice ist im %s deaktiviert.", Outbreak_IsHideActive() ? "Hide&Seek" : "Krieg"); + return Plugin_Handled; + } + + if (!g_bReady) + { + CReplyToCommand(client, "Die Würfel sind noch nicht gezinkt."); + return Plugin_Handled; + } + + char sOption[32]; + if (g_cDebug.BoolValue) + { + GetCmdArg(1, sOption, sizeof(sOption)); + + bool bReset = false; + if (!CheckCommandAccess(client, "sm_admin", ADMFLAG_ROOT, true)) + { + sOption[0] = '\0'; + } + + if (bReset || strlen(sOption) < 2) + { + sOption[0] = '\0'; + } + } + + if (IsClientValid(client)) + { + if (IsPlayerAlive(client)) + { + if ((g_bJail && Jail_IsClientCapitulate(client)) || (g_bKnockout && IsClientKnockout(client))) + { + return Plugin_Handled; + } + + int team = GetClientTeam(client); + + bool bAccess = false; + + if (team == CS_TEAM_CT && g_iCount[client] == 0) + { + bAccess = true; + } + else if (team == CS_TEAM_T) + { + if (g_iCount[client] == 0) + { + bAccess = true; + } + else if (g_iCount[client] == 1) + { + if (STAMM_HaveClientFeature(client)) + { + bAccess = true; + } + else + { + CReplyToCommand(client, "Sie haben nicht den nötigen Stamm Rank um ein zweites mal zu würfeln."); + } + } + } + + if (bAccess) + { + if (!g_bBusy[client] && g_hDiceTimer[client] == null) + { + g_bBusy[client] = true; + + EmitSoundToClientAny(client, DICE_SOUND); + + Panel panel = new Panel(); + panel.SetTitle("Der Würfel rollt..."); + panel.DrawText("(Glücksspiel kann süchtig machen!)"); + panel.Send(client, Panel_Nothing, 3); + delete panel; + + DataPack pack = new DataPack(); + pack.WriteCell(GetClientUserId(client)); + pack.WriteCell(team); + pack.WriteString(sOption); + g_hDiceTimer[client] = CreateTimer(2.0, Timer_Dice, pack); + } + else + { + CReplyToCommand(client, "Der Würfel rollt gerade..."); + } + } + else + { + CReplyToCommand(client, "Du hast schon %s%dx %sgewürfelt.", SPECIAL, g_iCount[client], TEXT); + } + } + else + { + CReplyToCommand(client, "Das macht kein Sinn..."); + } + + } + + return Plugin_Handled; +} + +public Action Timer_Dice(Handle timer, DataPack pack) +{ + pack.Reset(); + int client = GetClientOfUserId(pack.ReadCell()); + int team = pack.ReadCell(); + char sOption[32]; + pack.ReadString(sOption, sizeof(sOption)); + delete pack; + + if (IsClientValid(client)) + { + if (IsPlayerAlive(client)) + { + // Types: 0 - Negative, 1 - Neutral, 2 - Positive + int type = -1; + + Panel panel = new Panel(); + + if (g_iCount[client] == 0) + { + if (team == CS_TEAM_T) + { + g_iCount[client]++; + + int iIndex = GetRandomInt(0, g_aT1Pot.Length - 1); + + DiceOption Option; + g_aT1Pot.GetArray(iIndex, Option, sizeof(Option)); + + int iCount = 0; + + for (int i = 0; i < g_aT1Pot.Length; i++) + { + DiceOption tmp; + g_aT1Pot.GetArray(i, tmp, sizeof(tmp)); + + if (StrEqual(tmp.Name, Option.Name, false)) + { + iCount++; + } + } + + float fChance = float(g_aT1Pot.Length) / float(100) * float (iCount); + + if (Option.Delete) + { + g_aT1Pot.Erase(iIndex); + } + + g_aT1Pot.Sort(Sort_Random, Sort_Integer); + + if (strlen(sOption) > 2) + { + strcopy(Option.Name, sizeof(DiceOption::Name), sOption); + Option.Debug = true; + } + + type = GiveDiceOption(client, Option, CS_TEAM_T, 1, panel, fChance); + } + else if (team == CS_TEAM_CT) + { + g_iCount[client]++; + + int iIndex = GetRandomInt(0, g_aCTPot.Length - 1); + + DiceOption Option; + g_aCTPot.GetArray(iIndex, Option, sizeof(Option)); + + int iCount = 0; + + for (int i = 0; i < g_aCTPot.Length; i++) + { + DiceOption tmp; + g_aCTPot.GetArray(i, tmp, sizeof(tmp)); + + if (StrEqual(tmp.Name, Option.Name, false)) + { + iCount++; + } + } + + float fChance = float(g_aCTPot.Length) / float(100) * float (iCount); + + if (Option.Delete) + { + g_aCTPot.Erase(iIndex); + } + + g_aCTPot.Sort(Sort_Random, Sort_Integer); + + if (strlen(sOption) > 2) + { + strcopy(Option.Name, sizeof(DiceOption::Name), sOption); + Option.Debug = true; + } + + type = GiveDiceOption(client, Option, CS_TEAM_CT, 1, panel, fChance); + } + } + else + { + if (GetClientTeam(client) == CS_TEAM_T) + { + g_iCount[client]++; + + int iIndex = GetRandomInt(0, g_aT2Pot.Length - 1); + + DiceOption Option; + g_aT2Pot.GetArray(iIndex, Option, sizeof(Option)); + + int iCount = 0; + + for (int i = 0; i < g_aT2Pot.Length; i++) + { + DiceOption tmp; + g_aT2Pot.GetArray(i, tmp, sizeof(tmp)); + + if (StrEqual(tmp.Name, Option.Name, false)) + { + iCount++; + } + } + + float fChance = float(g_aT2Pot.Length) / float(100) * float (iCount); + + if (Option.Delete) + { + g_aT2Pot.Erase(iIndex); + } + + g_aT2Pot.Sort(Sort_Random, Sort_Integer); + + if (strlen(sOption) > 2) + { + strcopy(Option.Name, sizeof(DiceOption::Name), sOption); + Option.Debug = true; + } + + type = GiveDiceOption(client, Option, CS_TEAM_T, 2, panel, fChance); + } + } + + panel.Send(client, Panel_Nothing, 4); + delete panel; + + if (type == 0) + { + EmitSoundToClientAny(client, NEGATIVE_SOUND); + } + else if (type == 1) + { + EmitSoundToClientAny(client, NEUTRAL_SOUND); + } + else if (type == 2) + { + EmitSoundToClientAny(client, POSITIVE_SOUND); + } + + if (team == CS_TEAM_T && g_iCount[client] == 1 && g_bAutoT2Dice[client]) + { + CPrintToChat(client, "Dein 2. Würfel rollt in 3 Sekunden..."); + CreateTimer(3.0, Timer_AutoDice, GetClientUserId(client)); + } + } + else + { + CPrintToChat(client, "Das macht keinen Sinn mehr..."); + } + + g_bBusy[client] = false; + g_hDiceTimer[client] = null; + } + + return Plugin_Stop; +} + +// Events +public Action Event_PlayerJump(Event event, const char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(event.GetInt("userid")); + + if (IsClientValid(client) && IsPlayerAlive(client) && g_bLongjump[client]) + { + Longjump(client); + } + + return Plugin_Handled; +} + +public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast) +{ + + if (GetAliveTPlayers() == 1 && GetAliveCTPlayers() >= 1) + { + LoopClients(client) + { + if (IsPlayerAlive(client)) + { + SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 1); + } + } + } + + int client = GetClientOfUserId(event.GetInt("userid")); + + if (!IsClientValid(client)) + { + return Plugin_Continue; + } + + LoopClients(i) + { + if (IsClientInGame(i) && IsPlayerAlive(i) && g_iLover[i] == client) + { + CPrintToChat(i, "Dein Liebling ist gefallen, dein Herz gebrochen und nun fällst auch du."); + ForcePlayerSuicide(i); + } + } + + if (GetAliveTPlayers() >= 1 && GetAliveCTPlayers() >= 1) + { + if (g_bRespawn[client]) + { + if (GetRandomInt(1, 2) == 1) + { + CPrintToChat(client, "Du hast durch den Würfel eine 2. Chance verdient! Respawn in 2 Sekunden..."); + CreateTimer(2.0, Timer_RespawnPlayer, GetClientUserId(client)); + } + } + } + + int attacker = GetClientOfUserId(event.GetInt("attacker")); + char sWeapon[32]; + event.GetString("weapon", sWeapon, sizeof(sWeapon)); + + if (IsClientValid(attacker)) + { + if (g_bAssassine[attacker] && (StrContains(sWeapon, "awp", false) == -1)) + { + event.BroadcastDisabled = true; + return Plugin_Changed; + } + } + + return Plugin_Continue; +} + +public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(event.GetInt("userid")); + + if (IsClientValid(client)) + { + CreateTimer(0.5, Timer_AutoDice, GetClientUserId(client)); + + SetEntityGravity(client, 1.0); + + ResetDice(client); + } + + return Plugin_Handled; +} + +public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast) +{ + g_bReady = ReadDiceOptions(); + + return Plugin_Continue; +} + +public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast) +{ + LoopClients(client) + { + if (IsPlayerAlive(client)) + { + SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 1); + } + } + + return Plugin_Handled; +} + +public Action Event_SmokeDetonate(Event event, const char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(event.GetInt("userid")); + int entity = event.GetInt("entityid"); + + if (!IsClientValid(client) || !IsValidEntity(entity)) + { + return Plugin_Continue; + } + + DataPack pack = new DataPack(); + CreateDataTimer(1.0, Timer_CheckPlayers, pack, TIMER_FLAG_NO_MAPCHANGE); + pack.WriteCell(GetClientUserId(client)); + pack.WriteCell(EntIndexToEntRef(entity)); + + return Plugin_Continue; +} + +public Action Event_DecoyStarted(Event event, const char[] name, bool dontBroadcast) +{ + int client = GetClientOfUserId(event.GetInt("userid")); + int entity = event.GetInt("entityid"); + + if (!IsClientValid(client)) + { + return Plugin_Continue; + } + + FGrenades_SwitchMode(client, DecoyMode_Normal); + + if (!g_bDecoy[client] || !IsValidEntity(entity)) + { + return Plugin_Continue; + } + + AcceptEntityInput(entity, "kill"); + + float fOldPos[3]; + GetClientAbsOrigin(client, fOldPos); + + float fPos[3]; + fPos[0] = event.GetFloat("x"); + fPos[1] = event.GetFloat("y"); + fPos[2] = (event.GetFloat("z") + 5.0); + + TeleportEntity(client, fPos, NULL_VECTOR, NULL_VECTOR); + + bool stuck = WillClientStuck(client); + + if (stuck) + { + TeleportEntity(client, fOldPos, NULL_VECTOR, NULL_VECTOR); + CPrintToChat(client, "Du wurdest zurück teleportiert, weil du sonst stucken würdest."); + } + + g_bDecoy[client] = false; + + return Plugin_Continue; +} + +public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon) +{ + if (IsClientValid(client) && IsPlayerAlive(client)) + { + if (g_bJihad[client]) + { + if (buttons & IN_USE) + { + int iEntity = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); + + if (!IsValidEntity(iEntity)) + { + return Plugin_Continue; + } + + char sClassname[32]; + GetEntityClassname(iEntity, sClassname, sizeof(sClassname)); + + if (StrContains(sClassname, "c4", false) == -1) + { + return Plugin_Continue; + } + + StartJihad(client); + g_bJihad[client] = false; + } + } + + if (g_bRentner[client]) + { + if (buttons & IN_JUMP) + { + if (GetEntityFlags(client) & FL_ONGROUND && GetEntityMoveType(client) != MOVETYPE_LADDER) + { + buttons &= ~IN_JUMP; + } + } + } + + if (g_bFroggyjump[client]) + { + if (GetEntityFlags(client) & FL_ONGROUND) + { + g_iFroggyAir[client] = 0; + g_bFroggyPressed[client] = false; + } + else + { + if (buttons & IN_JUMP) + { + if (!g_bFroggyPressed[client]) + { + if (g_iFroggyAir[client]++ == 1) + { + Froggyjump(client); + } + } + + g_bFroggyPressed[client] = true; + } + else + { + g_bFroggyPressed[client] = false; + } + } + } + + if (g_bBhop[client]) + { + if (buttons & IN_JUMP) + { + if (!(GetEntityMoveType(client) & MOVETYPE_LADDER)) + { + SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0); + + if (!(GetEntityFlags(client) & FL_ONGROUND)) + { + buttons &= ~IN_JUMP; + } + } + } + } + + if (g_bMirrorMovement[client]) + { + vel[1] = -vel[1]; + + if (buttons & IN_MOVELEFT) { + buttons &= ~IN_MOVELEFT; + buttons |= IN_MOVERIGHT; + } else if (buttons & IN_MOVERIGHT) { + buttons &= ~IN_MOVERIGHT; + buttons |= IN_MOVELEFT; + } + + vel[2] = -vel[2]; + + if (buttons & IN_DUCK) { + buttons &= ~IN_DUCK; + buttons |= IN_JUMP; + } else if (buttons & IN_JUMP) { + buttons &= ~IN_JUMP; + buttons |= IN_DUCK; + } + + vel[0] = -vel[0]; + + if (buttons & IN_FORWARD) { + buttons &= ~IN_FORWARD; + buttons |= IN_BACK; + } else if (buttons & IN_BACK) { + buttons &= ~IN_BACK; + buttons |= IN_FORWARD; + } + } + + if (g_bZombie[client]) + { + if (buttons & IN_JUMP) + { + if (GetEntityFlags(client) & FL_ONGROUND && GetEntityMoveType(client) != MOVETYPE_LADDER) + { + buttons &= ~IN_JUMP; + } + } + + if (!(buttons & IN_DUCK)) + { + buttons ^= IN_DUCK; + } + + return Plugin_Changed; + } + + // Remove fire with water contact + if (GetEntityFlags(client) & FL_INWATER) + { + int iFire = GetEntPropEnt(client, Prop_Data, "m_hEffectEntity"); + + if (IsValidEdict(iFire)) + { + SetEntPropFloat(iFire, Prop_Data, "m_flLifetime", 0.0); + } + + if (g_hHighGravity[client] != null) + { + SetEntityGravity(client, 1.0); + g_bInWater[client] = true; + } + } + else if (g_bInWater[client] && GetEntityFlags(client) & FL_ONGROUND || GetEntityFlags(client) & FL_DUCKING) + { + CreateTimer(0.5, Timer_ResetInWater, GetClientUserId(client)); + } + } + + return Plugin_Changed; +} diff --git a/dice/autodice.sp b/dice/autodice.sp new file mode 100644 index 0000000..0fbef02 --- /dev/null +++ b/dice/autodice.sp @@ -0,0 +1,93 @@ +public Action Command_AutoDice(int client, int args) +{ + ShowAutoDiceMenu(client); + + return Plugin_Continue; +} + +void ShowAutoDiceMenu(int client) +{ + if (client < 1) + { + return; + } + + char sBuffer[32]; + + Panel panel = new Panel(); + panel.SetTitle("Auto Dice Settings"); + panel.DrawText("Möchtest du automatisch Würfeln?"); + panel.DrawText(" "); + + FormatEx(sBuffer, sizeof(sBuffer), "[%s] CT-Würfel", (g_bAutoCTDice[client]) ? "X" : " "); + panel.DrawItem(sBuffer); + + FormatEx(sBuffer, sizeof(sBuffer), "[%s] 1. T-Würfel", (g_bAutoT1Dice[client]) ? "X" : " "); + panel.DrawItem(sBuffer); + + FormatEx(sBuffer, sizeof(sBuffer), "[%s] 2. T-Würfel", (g_bAutoT2Dice[client]) ? "X" : " "); + panel.DrawItem(sBuffer); + + panel.DrawText(" "); + panel.DrawItem("Schließen"); + panel.Send(client, Panel_AutoDice, 30); + + delete panel; +} + +public int Panel_AutoDice(Menu menu, MenuAction action, int client, int param) +{ + if (action == MenuAction_Select) + { + if (param == 1) + { + g_bAutoCTDice[client] = !g_bAutoCTDice[client]; + SetDiceSetting(client, g_hAutoCTDice, g_bAutoCTDice[client]); + } + else if (param == 2) + { + g_bAutoT1Dice[client] = !g_bAutoT1Dice[client]; + SetDiceSetting(client, g_hAutoT1Dice, g_bAutoT1Dice[client]); + } + else if (param == 3) + { + g_bAutoT2Dice[client] = !g_bAutoT2Dice[client]; + SetDiceSetting(client, g_hAutoT2Dice, g_bAutoT2Dice[client]); + } + } + + return 0; +} + +void SetDiceSetting(int client, Handle cookie, bool value) +{ + char sBuffer[4]; + IntToString(value, sBuffer, sizeof(sBuffer)); + SetClientCookie(client, cookie, sBuffer); + + ShowAutoDiceMenu(client); +} + +public Action Timer_AutoDice(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + int team = GetClientTeam(client); + + if (g_bReady && client && IsPlayerAlive(client) && (team == CS_TEAM_T || team == CS_TEAM_CT) && !g_bBusy[client] && g_hDiceTimer[client] == null) + { + if (team == CS_TEAM_CT && g_iCount[client] == 0 && g_bAutoCTDice[client]) + { + ClientCommand(client, "sm_w"); + } + else if (team == CS_TEAM_T && g_iCount[client] == 0 && g_bAutoT1Dice[client]) + { + ClientCommand(client, "sm_w"); + } + else if (team == CS_TEAM_T && g_iCount[client] == 1 && STAMM_HaveClientFeature(client) && g_bAutoT2Dice[client]) + { + ClientCommand(client, "sm_w"); + } + } + + return Plugin_Stop; +} diff --git a/dice/functions.sp b/dice/functions.sp new file mode 100644 index 0000000..bcd61f5 --- /dev/null +++ b/dice/functions.sp @@ -0,0 +1,624 @@ +void ResetDice(int client) +{ + g_iCount[client] = 0; + g_iNoclipCounter[client] = 5; + g_iFroggyAir[client] = 0; + + g_bInWater[client] = false; + g_bFroggyjump[client] = false; + g_bFroggyPressed[client] = false; + g_bLongjump[client] = false; + g_bBhop[client] = false; + g_bAssassine[client] = false; + g_bTollpatsch[client] = false; + g_bLose[client] = false; + g_bMirrorMovement[client] = false; + g_bZombie[client] = false; + g_bDecoy[client] = false; + g_bJihad[client] = false; + g_bNoFallDamage[client] = false; + g_bRentner[client] = false; + g_dmFuturistic[client] = DecoyMode_Normal; + g_fDamage[client] = 0.0; + g_bMoreDamage[client] = false; + g_bLessDamage[client] = false; + g_bHeadshot[client] = false; + g_bRespawn[client] = false; + g_bBusy[client] = false; + g_bAWP[client] = false; + g_iLover[client] = -1; + + if (IsClientValid(client)) + { + if (IsPlayerAlive(client)) + { + SetEntityMoveType(client, MOVETYPE_WALK); + SetEntityRenderMode(client, RENDER_TRANSCOLOR); + SetEntityRenderColor(client, 255, 255, 255); + } + + SetGohanMode(client, false); + FGrenades_SwitchMode(client, DecoyMode_Normal); + ResetBitchSlap(client); + + delete g_hDrugsTimer[client]; + delete g_hDelayedSlay[client]; + delete g_hNoclip[client]; + delete g_hLowGravity[client]; + delete g_hHighGravity[client]; + delete g_hDiceTimer[client]; + g_hDrunkTimer[client] = null; + } +} + +void SetHealth(int client, int hp, bool addHP) +{ + int health = GetClientHealth(client); + + if (addHP) + { + // Plus HP + SetEntityHealth(client, health + hp); + } + else + { + // Minus HP + health -= hp; + + if (health <= 0) + { + ForcePlayerSuicide(client); + } + else + { + SetEntityHealth(client, health); + } + } +} + +void Froggyjump(int client) +{ + float velocity[3]; + float velocity0; + float velocity1; + float velocity2; + float velocity2_new; + + velocity0 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]"); + velocity1 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]"); + velocity2 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[2]"); + + velocity2_new = 260.0; + + if (velocity2 < 150.0) + { + velocity2_new = 270.0; + } + + if (velocity2 < 100.0) + { + velocity2_new = 300.0; + } + + if (velocity2 < 50.0) + { + velocity2_new = 330.0; + } + + if (velocity2 < 0.0) + { + velocity2_new = 380.0; + } + + if (velocity2 < -50.0) + { + velocity2_new = 400.0; + } + + if (velocity2 < -100.0) + { + velocity2_new = 430.0; + } + + if (velocity2 < -150.0) + { + velocity2_new = 450.0; + } + + if (velocity2 < -200.0) + { + velocity2_new = 470.0; + } + + + velocity[0] = velocity0 * 0.1; + velocity[1] = velocity1 * 0.1; + velocity[2] = velocity2_new; + + SetEntPropVector(client, Prop_Send, "m_vecBaseVelocity", velocity); +} + +void Longjump(int client) +{ + float velocity[3]; + float velocity0; + float velocity1; + + velocity0 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[0]"); + velocity1 = GetEntPropFloat(client, Prop_Send, "m_vecVelocity[1]"); + + velocity[0] = (7.0 * velocity0) * (1.0 / 4.1); + velocity[1] = (7.0 * velocity1) * (1.0 / 4.1); + velocity[2] = 0.0; + + SetEntPropVector(client, Prop_Send, "m_vecBaseVelocity", velocity); +} + +bool IsClientStuck(int client) +{ + float vOrigin[3], vMins[3], vMaxs[3]; + + GetClientAbsOrigin(client, vOrigin); + + GetEntPropVector(client, Prop_Send, "m_vecMins", vMins); + GetEntPropVector(client, Prop_Send, "m_vecMaxs", vMaxs); + + TR_TraceHullFilter(vOrigin, vOrigin, vMins, vMaxs, MASK_ALL, FilterOnlyPlayers, client); + + return TR_DidHit(); +} + +public bool FilterOnlyPlayers(int entity, int contentsMask, any data) +{ + if (entity != data && IsClientValid(entity) && IsClientValid(data)) + { + return false; + } + else if (entity != data) + { + return true; + } + else + { + return false; + } +} + +float GetClientSpeed(int client) +{ + return GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue"); +} + +float SetClientSpeed(int client, float speed) +{ + SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", speed); + + return GetClientSpeed(client); +} + +public void Frame_GiveTaser(any userid) +{ + int client = GetClientOfUserId(userid); + + if (IsClientValid(client)) + { + GivePlayerItem(client, "weapon_taser"); + } +} + +bool WillClientStuck(int client) +{ + float vOrigin[3]; + float vMins[3]; + float vMaxs[3]; + + GetClientAbsOrigin(client, vOrigin); + GetEntPropVector(client, Prop_Send, "m_vecMins", vMins); + GetEntPropVector(client, Prop_Send, "m_vecMaxs", vMaxs); + + TR_TraceHullFilter(vOrigin, vOrigin, vMins, vMaxs, MASK_ALL, OnlyPlayers, client); + + return TR_DidHit(); +} + +public bool OnlyPlayers(int entity, int contentsMask, any data) +{ + if (entity != data && entity > 0 && entity <= MaxClients) + { + return true; + } + return false; +} + + +public Action Timer_ResetInWater(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (IsClientValid(client)) + { + g_bInWater[client] = false; + + if (IsPlayerAlive(client) && g_hHighGravity[client] != null) + { + SetEntityGravity(client, 1.8); + } + } + + return Plugin_Stop; +} + +public Action Timer_ResetInvisible(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (IsClientValid(client)) + { + SetEntityRenderMode(client, RENDER_TRANSCOLOR); + SetEntityRenderColor(client, 255, 255, 255); + + CPrintToChat(client, "Du bist jetzt wieder sichtbar."); + } + + return Plugin_Stop; +} + +public Action Timer_Unfreeze(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (IsClientValid(client) && IsPlayerAlive(client)) + { + SetEntityMoveType(client, MOVETYPE_WALK); + CPrintToChat(client, "Du kannst nun wieder laufen."); + } + + return Plugin_Stop; +} + +public Action Timer_Drugs(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (!IsClientInGame(client)) + return Plugin_Stop; + + float fDrugAngles[20] = {0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 20.0, 15.0, 10.0, 5.0, 0.0, -5.0, -10.0, -15.0, -20.0, -25.0, -20.0, -15.0, -10.0, -5.0}; + + if (!IsPlayerAlive(client)) + { + float fPosition[3]; + float fAngles[3]; + + GetClientAbsOrigin(client, fPosition); + GetClientEyeAngles(client, fAngles); + + fAngles[2] = 0.0; + + TeleportEntity(client, fPosition, fAngles, NULL_VECTOR); + + Handle hMessage = StartMessageOne("Fade", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS); + + if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) + { + PbSetInt(hMessage, "duration", 1536); + PbSetInt(hMessage, "hold_time", 1536); + PbSetInt(hMessage, "flags", (0x0001 | 0x0010)); + PbSetColor(hMessage, "clr", {0, 0, 0, 0}); + } + else + { + BfWriteShort(hMessage, 1536); + BfWriteShort(hMessage, 1536); + BfWriteShort(hMessage, (0x0001 | 0x0010)); + BfWriteByte(hMessage, 0); + BfWriteByte(hMessage, 0); + BfWriteByte(hMessage, 0); + BfWriteByte(hMessage, 0); + } + + EndMessage(); + + g_hDrugsTimer[client] = null; + return Plugin_Stop; + } + + float fPosition[3]; + float fAngles[3]; + int coloring[4]; + + coloring[0] = GetRandomInt(0,255); + coloring[1] = GetRandomInt(0,255); + coloring[2] = GetRandomInt(0,255); + coloring[3] = 128; + + GetClientAbsOrigin(client, fPosition); + GetClientEyeAngles(client, fAngles); + + fAngles[2] = fDrugAngles[GetRandomInt(0,100) % 20]; + + TeleportEntity(client, fPosition, fAngles, NULL_VECTOR); + + Handle hMessage = StartMessageOne("Fade", client); + + if (GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf) + { + PbSetInt(hMessage, "duration", 255); + PbSetInt(hMessage, "hold_time", 255); + PbSetInt(hMessage, "flags", (0x0002)); + PbSetColor(hMessage, "clr", coloring); + } + else + { + BfWriteShort(hMessage, 255); + BfWriteShort(hMessage, 255); + BfWriteShort(hMessage, (0x0002)); + BfWriteByte(hMessage, GetRandomInt(0,255)); + BfWriteByte(hMessage, GetRandomInt(0,255)); + BfWriteByte(hMessage, GetRandomInt(0,255)); + BfWriteByte(hMessage, 128); + } + + EndMessage(); + + return Plugin_Handled; +} + +public Action Timer_Drunk(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (!IsClientInGame(client)) + { + return Plugin_Stop; + } + + if (g_hDrunkTimer[client] == null) + { + return Plugin_Continue; + } + + if (!IsPlayerAlive(client)) + { + SetRandomAngles(client); + + g_hDrugsTimer[client] = null; + return Plugin_Stop; + } + + SetRandomAngles(client); + + return Plugin_Continue; +} + +public Action Timer_DelayedSlay(Handle timer, int userid) +{ + int client = GetClientOfUserId(userid); + + if (!IsClientInGame(client)) + { + return Plugin_Stop; + } + + if (!IsPlayerAlive(client)) + { + g_hDelayedSlay[client] = null; + return Plugin_Stop; + } + + ForcePlayerSuicide(client); + CPrintToChat(client, "Die Zeit ist verstrichen und wurdest einfach erschlagen."); + + g_hDelayedSlay[client] = null; + return Plugin_Stop; +} + +void StartJihad(int client) +{ + float fPos[3]; + GetClientEyePosition(client, fPos); + + EmitAmbientSoundAny(JIHAD_SOUND, fPos, SOUND_FROM_PLAYER, .vol=0.8); + + CreateTimer(2.0, Timer_Detonate, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE); +} + +public Action Timer_Detonate(Handle timer, any userid) +{ + int client = GetClientOfUserId(userid); + + if (client > 0 && IsPlayerAlive(client)) + { + int iExplosion = CreateEntityByName("env_explosion"); + if (iExplosion != -1) + { + SetEntProp(iExplosion, Prop_Data, "m_spawnflags", 16384); + SetEntProp(iExplosion, Prop_Data, "m_iMagnitude", 666); + SetEntProp(iExplosion, Prop_Data, "m_iRadiusOverride", 333); + DispatchKeyValue(iExplosion, "targetname", "jihad"); + + DispatchSpawn(iExplosion); + ActivateEntity(iExplosion); + + float fPosition[3]; + GetClientEyePosition(client, fPosition); + + TeleportEntity(iExplosion, fPosition, NULL_VECTOR, NULL_VECTOR); + SetEntPropEnt(iExplosion, Prop_Send, "m_hOwnerEntity", client); + + EmitAmbientSoundAny(EXPLOSION_SOUND, fPosition, SOUND_FROM_PLAYER, SNDLEVEL_RAIDSIREN); + + + AcceptEntityInput(iExplosion, "Explode"); + + AcceptEntityInput(iExplosion, "Kill"); + + // Slay players + ForcePlayerSuicide(client); + } + } + + return Plugin_Handled; +} + +void SetRandomAngles(int client) +{ + float fAngles[3]; + fAngles[0] = GetRandomFloat(-89.0, 89.0); + fAngles[1] = GetRandomFloat(-179.0, 179.0); + TeleportEntity(client, .angles=fAngles); +} + +public Action Timer_BitchSlap(Handle timer, DataPack pack) +{ + pack.Reset(); + int client = pack.ReadCell(); + int damage = pack.ReadCell(); + bool sound = view_as(pack.ReadCell()); + + if(IsClientValid(client)) + { + if(g_iBSCount[client] >= 0) + { + SlapPlayer(client, damage, sound); + g_iBSCount[client]--; + + if(g_iBSCount[client] == 0) + { + ResetBitchSlap(client); + return Plugin_Stop; + } + } + } + return Plugin_Continue; +} + +void ResetBitchSlap(int client) +{ + g_iBSCount[client] = 0; + if(g_hBitchSlap[client] != null) + KillTimer(g_hBitchSlap[client], false); + g_hBitchSlap[client] = null; +} + +public Action Timer_CheckPlayers(Handle timer, DataPack pack) +{ + pack.Reset(); + + int client = GetClientOfUserId(pack.ReadCell()); + int entity = EntRefToEntIndex(pack.ReadCell()); + + if (IsClientValid(client) && IsValidEntity(entity)) + { + float fEOrigin[3], fCOrigin[3], fDistance; + GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fEOrigin); + + LoopClients(victim) + { + if (GetClientTeam(client) == GetClientTeam(victim) && IsPlayerAlive(victim)) + { + GetClientAbsOrigin(victim, fCOrigin); + fDistance = GetVectorDistance(fEOrigin, fCOrigin); + + if (fDistance <= 145.0) + { + int iFire = GetEntPropEnt(victim, Prop_Data, "m_hEffectEntity"); + + if (IsValidEdict(iFire)) + { + SetEntPropFloat(iFire, Prop_Data, "m_flLifetime", 0.0); + } + } + } + } + + DataPack pack2 = new DataPack(); + CreateDataTimer(1.0, Timer_CheckPlayers, pack2, TIMER_FLAG_NO_MAPCHANGE); + pack2.WriteCell(GetClientUserId(client)); + pack2.WriteCell(EntIndexToEntRef(entity)); + } + + return Plugin_Stop; +} + +public Action NoclipTimer(Handle timer, any client) +{ + if (IsClientValid(client) && IsPlayerAlive(client)) + { + if (g_iNoclipCounter[client] > 0) + { + CPrintToChat(client, "Noclip endet in: %s%i", SPECIAL, g_iNoclipCounter[client]); + + g_iNoclipCounter[client]--; + + return Plugin_Continue; + } + else + { + SetEntityMoveType(client, MOVETYPE_WALK); + + if (IsClientStuck(client)) + { + ForcePlayerSuicide(client); + } + } + } + + g_hNoclip[client] = null; + + return Plugin_Stop; +} + +public Action LowGravityTimer(Handle timer, any client) +{ + if (IsClientValid(client) && IsPlayerAlive(client)) + { + SetEntityGravity(client, 0.5); + + return Plugin_Continue; + } + + g_hLowGravity[client] = null; + + return Plugin_Stop; +} + +public Action HighGravityTimer(Handle timer, any client) +{ + if (IsClientValid(client) && IsPlayerAlive(client)) + { + if (!g_bInWater[client]) + { + SetEntityGravity(client, 1.8); + } + + return Plugin_Continue; + } + + g_hHighGravity[client] = null; + + return Plugin_Stop; +} + +public Action Timer_RespawnPlayer(Handle timer, any userid) +{ + int client = GetClientOfUserId(userid); + + if (IsClientValid(client)) + { + CS_RespawnPlayer(client); + g_bRespawn[client] = false; + } + + return Plugin_Stop; +} + +public int Panel_Nothing(Menu menu, MenuAction action, int client, int param) +{ + if (action == MenuAction_End) + { + delete menu; + } + + return 0; +} diff --git a/dice/options.sp b/dice/options.sp new file mode 100644 index 0000000..5fa4ac7 --- /dev/null +++ b/dice/options.sp @@ -0,0 +1,655 @@ +int GiveDiceOption(int client, DiceOption Option, int team, int dice, Panel panel, float chance) +{ + char sDice[24], sText[MAX_MESSAGE_LENGTH], sText1[MAX_MESSAGE_LENGTH], sText2[MAX_MESSAGE_LENGTH]; + int type = -1; + + if (team == CS_TEAM_CT) + { + FormatEx(sDice, sizeof(sDice), "CT-Würfel"); + } + else + { + FormatEx(sDice, sizeof(sDice), "%d. T-Würfel", dice); + } + + + if (StrEqual(Option.Name, "nothing", false)) + { + Format(sText, sizeof(sText), "Du hast beim %s %snichts%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 1; + } + else if (StrEqual(Option.Name, "shield", false)) + { + bool bSkip = false; + + int iWeapon = GetPlayerWeaponSlot(client, 11); + if (iWeapon != -1) + { + if (IsValidEdict(iWeapon) && IsValidEntity(iWeapon)) + { + char sClass[128]; + GetEntityClassname(iWeapon, sClass, sizeof(sClass)); + + if (StrEqual(sClass, "weapon_shield", false)) + { + Format(sText, sizeof(sText), "Du hast beim %s %snichts%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + + type = 1; + + bSkip = true; + } + } + } + + if (!bSkip) + { + GivePlayerItem(client, "weapon_shield"); + + Format(sText, sizeof(sText), "Du hast durch den %s %sein Schield%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else + { + Format(sText, sizeof(sText), "Du hast durch den %s %sein Schield%s gewürfelt...", sDice, SPECIAL, TEXT); + Format(sText1, sizeof(sText1), "Leider konnten wir dir dein Schild geben."); + type = 1; + } + } + else if (StrEqual(Option.Name, "reroll", false)) + { + g_iCount[client] = 0; + + Format(sText, sizeof(sText), "Du hast beim %s %sErneut Würfeln%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "helm", false)) + { + SetEntProp(client, Prop_Send, "m_bHasHelmet", 1); + + Format(sText, sizeof(sText), "Du hast beim %s %sein Helm%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "respawn", false)) + { + g_bRespawn[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sRespawn (50% Chance)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "speed", false)) + { + int iSpeed = GetRandomInt(1, 3); + float fSpeed = iSpeed / 10.0; + + SetClientSpeed(client, (GetClientSpeed(client) + fSpeed)); + + Format(sText, sizeof(sText), "Du hast beim %s %sSpeed (%.0f%)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, (fSpeed * 100), TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "noHeadshot", false)) + { + g_bHeadshot[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %skein Headshot Schaden (bekommen)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "lessDamage", false)) + { + float fDamage = GetRandomFloat(5.0, 15.0); + g_fDamage[client] = 1.0 + (fDamage / 100.0); + + g_bLessDamage[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sweniger Schaden (%.2f weniger bekommen)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, g_fDamage[client], TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "healthshot", false)) + { + GivePlayerItem(client, "weapon_healthshot"); + + Format(sText, sizeof(sText), "Du hast beim %s %seine Heilspritze%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "moreDamage", false)) + { + float fDamage = GetRandomFloat(10.0, 30.0); + g_fDamage[client] = 1.0 + (fDamage / 100.0); + + g_bMoreDamage[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %smehr Schaden (%.2f mehr geben)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, g_fDamage[client], TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "tagrenade", false)) + { + GivePlayerItem(client, "weapon_tagrenade"); + + Format(sText, sizeof(sText), "Du hast beim %s %seine TA-Grenade%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "+50hp", false)) + { + // +50 hp + SetHealth(client, 50, true); + + Format(sText, sizeof(sText), "Du hast beim %s %s+50 HP%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "lowGravity", false)) + { + // low grav + SetEntityGravity(client, 0.5); + g_hLowGravity[client] = CreateTimer(1.0, LowGravityTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + + Format(sText, sizeof(sText), "Du hast beim %s %slow Gravity%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "taser", false)) + { + // taser + RequestFrame(Frame_GiveTaser, GetClientUserId(client)); + + Format(sText, sizeof(sText), "Du hast beim %s %seinen Taser%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "drugs", false)) + { + // drugs + g_hDrugsTimer[client] = CreateTimer(1.0, Timer_Drugs, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + + Format(sText, sizeof(sText), "Du hast beim %s %sDrogen%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "froggyjump", false)) + { + // froggy + g_bFroggyjump[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sFroggyjump%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "-45hp", false)) + { + // -45 hp + SetHealth(client, 45, false); + + Format(sText, sizeof(sText), "Du hast beim %s %s-45 HP%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "futuristicGrenade", false)) + { + // futuristic grenade + GivePlayerItem(client, "weapon_decoy"); + + DecoyMode dmMode = view_as(GetRandomInt(view_as(DecoyMode_Normal), view_as(DecoyMode_ForceImplosion))); + char sPanelOption[32]; + + if (dmMode == DecoyMode_Normal) + { + FormatEx(sPanelOption, sizeof(sPanelOption), "Normal"); + Format(Option.Name, sizeof(DiceOption::Name), "normalDecoy"); + } + else if (dmMode == DecoyMode_Blackhole) + { + FormatEx(sPanelOption, sizeof(sPanelOption), "Blackhole"); + Format(Option.Name, sizeof(DiceOption::Name), "blackholeDecoy"); + } + else if (dmMode == DecoyMode_Forcefield) + { + dmMode = DecoyMode_Normal; + + FormatEx(sPanelOption, sizeof(sPanelOption), "Normal"); + Format(Option.Name, sizeof(DiceOption::Name), "normalDecoy"); + } + else if (dmMode == DecoyMode_ForceExplosion) + { + FormatEx(sPanelOption, sizeof(sPanelOption), "Explosion"); + Format(Option.Name, sizeof(DiceOption::Name), "explosionDecoy"); + } + else if (dmMode == DecoyMode_ForceImplosion) + { + FormatEx(sPanelOption, sizeof(sPanelOption), "Implosion"); + Format(Option.Name, sizeof(DiceOption::Name), "implosionDecoy"); + } + + g_dmFuturistic[client] = dmMode; + FGrenades_SwitchMode(client, dmMode); + + Format(sText, sizeof(sText), "Du hast beim %s %s%s%s Decoy gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, sPanelOption, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "slow", false)) + { + // slow + int iSpeed = GetRandomInt(2, 4); + float fSpeed = iSpeed / 10.0; + + SetClientSpeed(client, (GetClientSpeed(client) - fSpeed)); + + Format(sText, sizeof(sText), "Du hast beim %s %sSlow (+%.0f%%)%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, (fSpeed * 100), TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "flashbang", false)) + { + // 1 flash + GivePlayerItem(client, "weapon_flashbang"); + + Format(sText, sizeof(sText), "Du hast beim %s %s1 Flash%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "freeze", false)) + { + // freeze + SetEntityMoveType(client, MOVETYPE_NONE); + CreateTimer(10.0, Timer_Unfreeze, GetClientUserId(client)); + + Format(sText, sizeof(sText), "Du hast beim %s %s10 Sekunden Freeze%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "smokegrenade", false)) + { + // smoke + GivePlayerItem(client, "weapon_smokegrenade"); + + Format(sText, sizeof(sText), "Du hast beim %s %seine Smoke%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "tSwap", false)) + { + // t swap + int iOpponent = GetRandomPlayer(client, CS_TEAM_T); + + if (iOpponent < 1) + { + Format(sText, sizeof(sText), "Du hast beim %s %sT Spawn %sgewürfelt...", sDice, SPECIAL, TEXT); + Format(sText1, sizeof(sText1), "Kein Spieler für T-Swap gefunden, Sorry."); + type = 0; + } + else + { + float fClientPosition[3], fOpponentPosition[3]; + GetClientAbsOrigin(client, fClientPosition); + GetClientAbsOrigin(iOpponent, fOpponentPosition); + + TeleportEntity(client, fOpponentPosition); + TeleportEntity(iOpponent, fClientPosition); + + CPrintToChat(iOpponent, "%s%N %shat mit dir die Position getauscht.", SPECIAL, client, TEXT); + + Format(sText, sizeof(sText), "Du hast beim %s %sT Spawn %smit %s%N%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, SPECIAL, iOpponent, TEXT, chance); + type = 1; + } + } + else if (StrEqual(Option.Name, "longjump", false)) + { + // longjump + g_bLongjump[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sLongjump%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "zombie", false)) + { + // zombie + g_bZombie[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sZombie Mode%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "bhop", false)) + { + // bhop + g_bBhop[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sein Bhop Script%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "mirrorMovement", false)) + { + // mirror movement + g_bMirrorMovement[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sMirrored Movement%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "kevlarHelm", false)) + { + // kevlar + helm + GivePlayerItem(client, "item_assaultsuit"); + SetEntProp(client, Prop_Send, "m_ArmorValue", 100, 1); + + Format(sText, sizeof(sText), "Du hast beim %s %seine Kevlar mit Helm%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "invisible", false)) + { + // invisible + float fTime = GetRandomInt(3, 5) * 1.0; + + CreateTimer(fTime, Timer_ResetInvisible, GetClientUserId(client)); + SetEntityRenderMode(client, RENDER_NONE); + + Format(sText, sizeof(sText), "Du hast beim %s %s%.0f Sekunden Unsichtbar%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, fTime, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "noclip", false)) + { + // noclip + SetEntityMoveType(client, MOVETYPE_NOCLIP); + g_hNoclip[client] = CreateTimer(1.0, NoclipTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + + Format(sText, sizeof(sText), "Du hast beim %s %sNoclip%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "weapon", false)) + { + // cz/revolver + bool bCZ75 = view_as(GetRandomInt(0, 1)); + int iWeapon = GivePlayerItem(client, bCZ75 ? "weapon_cz75a" : "weapon_revolver"); + SetEntData(iWeapon, g_iClip1, (bCZ75) ? 12 : 8); + SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0); + + Format(sText, sizeof(sText), "Du hast beim %s %seine %s%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, bCZ75 ? "CZ" : "Revolver", TEXT, chance); + Format(Option.Name, sizeof(DiceOption::Name), bCZ75 ? "cz" : "revolver"); + type = 2; + } + else if (StrEqual(Option.Name, "-50hp", false)) + { + // -50 hp + SetHealth(client, 50, false); + + Format(sText, sizeof(sText), "Du hast beim %s %s-50 HP%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "burn", false)) + { + // anbrennen + IgniteEntity(client, 14.0); + + Format(sText, sizeof(sText), "Du hast beim %s %sanbrennen%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "assassine", false)) + { + // Assassine + g_bAssassine[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sAssassine%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Man kann deine Kill's nicht mehr sehen"); + Format(sText2, sizeof(sText2), "Kleiner Tipp: Ergib dich als Assassine nicht!"); + type = 2; + } + else if (StrEqual(Option.Name, "loseall", false)) + { + // Strip all + StripAllWeapons(client); + g_bLose[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %salles verloren%s.", sDice, SPECIAL, TEXT); + type = 0; + } + else if (StrEqual(Option.Name, "slay", false)) + { + // selbstmordattentäter + ForcePlayerSuicide(client); + + Format(sText, sizeof(sText), "Du hast beim %s %sSlay%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "highGravity", false)) + { + // High grav + SetEntityGravity(client, 1.8); + g_hHighGravity[client] = CreateTimer(1.0, HighGravityTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + + Format(sText, sizeof(sText), "Du hast beim %s %shigh Gravity%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "tollpatsch", false)) + { + // Tollpatsch + g_bTollpatsch[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sTollpatsch%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "refuse", false)) + { + // 2nd refuse + Jail_AddClientRefuse(client); + + Format(sText, sizeof(sText), "Du hast beim %s %s2. Verweigern%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "hegrenade", false)) + { + // Granate + GivePlayerItem(client, "weapon_hegrenade"); + + Format(sText, sizeof(sText), "Du hast beim %s %seine Granate%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "decoyTeleport", false)) + { + GivePlayerItem(client, "weapon_decoy"); + g_bDecoy[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sein Decoy Teleport%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "jihad", false)) + { + GivePlayerItem(client, "weapon_c4"); + g_bJihad[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %seine Jihad-Bombe%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Nimm die Bombe in der Hand und drücke E zum aktivieren."); + type = 2; + } + else if (StrEqual(Option.Name, "drunk", false)) + { + // drunk + g_hDrunkTimer[client] = CreateTimer(5.0, Timer_Drunk, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + SetRandomAngles(client); + + Format(sText, sizeof(sText), "Du hast beim %s %sBetrunken%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "nofalldamage", false)) + { + // nofalldamage + g_bNoFallDamage[client] = true; + + Format(sText, sizeof(sText), "Du hast beim %s %sNo Fall Damage%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 2; + } + else if (StrEqual(Option.Name, "gohan", false)) + { + // gohan + SetGohanMode(client, true); + + Format(sText, sizeof(sText), "Du hast beim %s %sSon Gohan%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Lade dein Kame Hame He mit der Reload Taste auf."); + type = 2; + } + else if (StrEqual(Option.Name, "fists", false)) + { + // fists + StripAllWeapons(client); + int iWeapon = GivePlayerItem(client, "weapon_fists"); + EquipPlayerWeapon(client, iWeapon); + + Format(sText, sizeof(sText), "Du hast beim %s %sFäuste%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Hast aber alles andere verloren..."); + type = 0; + } + else if (StrEqual(Option.Name, "hammer", false)) + { + // hammer + StripAllWeapons(client); + int iWeapon = GivePlayerItem(client, "weapon_hammer"); + EquipPlayerWeapon(client, iWeapon); + + Format(sText, sizeof(sText), "Du hast beim %s %sein Hammer%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Hast aber alles andere verloren..."); + type = 0; + } + else if (StrEqual(Option.Name, "axe", false)) + { + // axe + StripAllWeapons(client); + int iWeapon = GivePlayerItem(client, "weapon_axe"); + EquipPlayerWeapon(client, iWeapon); + + Format(sText, sizeof(sText), "Du hast beim %s %seine Axt%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Hast aber alles andere verloren..."); + type = 0; + } + else if (StrEqual(Option.Name, "spanner", false)) + { + // spanner + StripAllWeapons(client); + int iWeapon = GivePlayerItem(client, "weapon_spanner"); + EquipPlayerWeapon(client, iWeapon); + + Format(sText, sizeof(sText), "Du hast beim %s %sein Schraubenschlüssel%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Hast aber alles andere verloren..."); + type = 0; + } + else if (StrEqual(Option.Name, "rentner", false)) + { + // rentner + g_bRentner[client] = true; + int iSpeed = GetRandomInt(2, 4); + float fSpeed = iSpeed / 10.0; + + SetClientSpeed(client, (GetClientSpeed(client) - fSpeed)); + + Format(sText, sizeof(sText), "Du bist beim %s wohl %seingeschlafen und gealtert%s? (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "delayedSlay", false)) + { + // delayedSlay + float fRoundTimeLeft = float(GameRules_GetProp("m_iRoundTime")); + float fTime = GetRandomFloat(5.0, fRoundTimeLeft); + g_hDelayedSlay[client] = CreateTimer(fTime, Timer_DelayedSlay, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); + + Format(sText, sizeof(sText), "Du hast beim %s %sDie Zeit%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "lover", false)) + { + // lover + g_iLover[client] = GetRandomPlayer(client, GetClientTeam(client)); + + if (g_iLover[client] == -1) + { + Format(sText, sizeof(sText), "Du hast beim %s %snichts%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + } + else + { + Format(sText, sizeof(sText), "Du hast beim %s %sLover%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Kümmere dich gut um %s%N%s, sonst stirbt du auch.", SPECIAL, g_iLover[client], TEXT); + } + + type = 1; + } + else if (StrEqual(Option.Name, "noDMGawp", false)) + { + // no damage awp + g_bAWP[client] = true; + + int iWeapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); + + if (iWeapon != -1) + { + SafeRemoveWeapon(client, iWeapon); + } + + iWeapon = GivePlayerItem(client, "weapon_awp"); + SetEntData(iWeapon, g_iClip1, 1); + SetEntProp(iWeapon, Prop_Send, "m_iPrimaryReserveAmmoCount", 0); + + Format(sText, sizeof(sText), "Du hast beim %s %seine AWP%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + type = 0; + } + else if (StrEqual(Option.Name, "bitchslap", false)) + { + // BitchSlap + g_iBSCount[client] = GetRandomInt(1, 30); + float fInterval = GetRandomFloat(0.1, 10.0); + int iDamage = GetRandomInt(0, 5); + bool bSound = view_as(GetRandomInt(0, 1)); + + SlapPlayer(client, iDamage, bSound); + g_iBSCount[client]--; + + DataPack pack = new DataPack(); + g_hBitchSlap[client] = CreateDataTimer(fInterval, Timer_BitchSlap, pack, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE); + WritePackCell(pack, client); + WritePackCell(pack, iDamage); + WritePackCell(pack, bSound); + + Format(sText, sizeof(sText), "Du hast beim %s %sBitch Slap%s gewürfelt. (Chance: %.2f%%)", sDice, SPECIAL, TEXT, chance); + Format(sText1, sizeof(sText1), "Anzahl: %d, Interval: %.2f, Damage: %d, Sound: %s", g_iBSCount[client], fInterval, iDamage, (bSound) ? "Ja" : "Nein"); + + type = 0; + } + + if (strlen(sText) < 1) + { + LogStackTrace("Option is empty. Player: %N, Team: %d, Dice: %d, Option: %s(?)", client, team, dice, Option.Name); + CPrintToChat(client, "Herzlichen Glückwunsch, dein Würfel ist kaputt."); + return 0; + } + + if (team == CS_TEAM_CT) + { + Format(Option.Name, sizeof(DiceOption::Name), "(ct) %s", Option.Name); + } + + if (!Option.Debug) + { + AddDiceToMySQL(client, dice, Option.Name, type); + } + + char sChatMessage[MAX_MESSAGE_LENGTH]; + strcopy(sChatMessage, sizeof(sChatMessage), sText); + + char sChatMessage1[MAX_MESSAGE_LENGTH]; + strcopy(sChatMessage1, sizeof(sChatMessage1), sText1); + + char sChatMessage2[MAX_MESSAGE_LENGTH]; + strcopy(sChatMessage2, sizeof(sChatMessage2), sText2); + + + int iPosition = StrContains(sChatMessage, " (Chance", false); + + if (iPosition > 3) + { + sChatMessage[iPosition] = '\0'; + } + + panel.SetTitle("Dice"); + + CRemoveTags(sText, sizeof(sText)); + panel.DrawText(sText); + CPrintToChat(client, sChatMessage); + + if (strlen(sText1) > 2) + { + CPrintToChat(client, sChatMessage1); + CRemoveTags(sText1, sizeof(sText1)); + panel.DrawText(sText1); + } + + if (strlen(sText2) > 2) + { + CPrintToChat(client, sChatMessage2); + CRemoveTags(sText2, sizeof(sText2)); + panel.DrawText(sText2); + } + + return type; +} \ No newline at end of file