mirror of
https://github.com/Jackzmc/sourcemod-plugins.git
synced 2025-05-06 21:33:20 +00:00
ftt: Add silent application
This commit is contained in:
parent
9468169517
commit
d548ad9af3
3 changed files with 58 additions and 101 deletions
|
@ -29,6 +29,7 @@ StringMap trollKV;
|
|||
char trollIds[MAX_TROLLS+1][MAX_TROLL_NAME_LENGTH];
|
||||
char DEFAULT_FLAG_PROMPT_MULTIPLE[] = "Choose flags (Multiple)";
|
||||
char DEFAULT_FLAG_PROMPT[] = "Choose flags";
|
||||
bool SilentMenuSelected[MAXPLAYERS+1];
|
||||
|
||||
static int g_trollAddPromptIndex;
|
||||
|
||||
|
@ -176,7 +177,7 @@ enum struct Troll {
|
|||
|
||||
void Activate(int client, int activator, trollModifier modifier = TrollMod_Invalid, int flags = 0) {
|
||||
if(modifier == TrollMod_Invalid) modifier = this.GetDefaultMod();
|
||||
ApplyTroll(client, this.name, activator, modifier, false, flags);
|
||||
ApplyTroll(client, this.name, activator, modifier, flags);
|
||||
}
|
||||
|
||||
void Toggle(int client, int flags) {
|
||||
|
@ -278,7 +279,7 @@ void ToggleTroll(int client, const char[] name, int flags = 0) {
|
|||
troll.activeFlagClients[client] = flags;
|
||||
}
|
||||
|
||||
void ApplyTroll(int victim, const char[] name, int activator, trollModifier modifier, bool silent = false, int flags = 0) {
|
||||
void ApplyTroll(int victim, const char[] name, int activator, trollModifier modifier, int flags = 0) {
|
||||
static Troll troll;
|
||||
int trollIndex = GetTroll(name, troll);
|
||||
if(trollIndex == -1) {
|
||||
|
@ -295,7 +296,7 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
|
|||
return;
|
||||
}
|
||||
bool isActive = IsTrollActive(victim, troll.name);
|
||||
if(!silent) {
|
||||
if(!SilentMenuSelected[activator]) {
|
||||
if(isActive) {
|
||||
ShowActivityEx(activator, "[FTT] ", "deactivated troll \"%s\" on %N. ", troll.name, victim);
|
||||
LogAction(activator, victim, "\"%L\" deactivated troll \"%s\" on \"%L\"", activator, troll.name, victim);
|
||||
|
@ -312,105 +313,12 @@ void ApplyTroll(int victim, const char[] name, int activator, trollModifier modi
|
|||
|
||||
LogAction(activator, victim, "\"%L\" activated troll \"%s\" with flags=%d for \"%L\"", activator, troll.name, flags, victim);
|
||||
}
|
||||
}
|
||||
} else SilentMenuSelected[activator] = false;
|
||||
if(modifier == TrollMod_Constant) {
|
||||
Trolls[troll.id].activeFlagClients[victim] = isActive ? -1 : flags;
|
||||
}
|
||||
}
|
||||
|
||||
bool ApplyAffect(int victim, const Troll troll, int activator, trollModifier modifier, int flags) {
|
||||
bool isActive = IsTrollActiveByRawID(victim, troll.id);
|
||||
if(StrEqual(troll.name, "Reset User")) {
|
||||
LogAction(activator, victim, "\"%L\" reset all troll effects for \"%L\"", activator, victim);
|
||||
ShowActivityEx(activator, "[FTT] ", "reset troll effects for %N. ", victim);
|
||||
for(int i = 0; i <= MAX_TROLLS; i++) {
|
||||
Trolls[i].activeFlagClients[victim] = -1;
|
||||
}
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
SetEntityGravity(victim, 1.0);
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Slow Speed"))
|
||||
if(isActive)
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 1.0);
|
||||
else
|
||||
SetEntPropFloat(victim, Prop_Send, "m_flLaggedMovementValue", 0.8);
|
||||
else if(StrEqual(troll.name, "Higher Gravity"))
|
||||
if(isActive)
|
||||
SetEntityGravity(victim, 1.0);
|
||||
else
|
||||
SetEntityGravity(victim, 1.3);
|
||||
else if(StrEqual(troll.name, "Half Primary Ammo")) {
|
||||
int current = GetPrimaryReserveAmmo(victim);
|
||||
SetPrimaryReserveAmmo(victim, current / 2);
|
||||
} else if(StrEqual(troll.name, "UziRules")) {
|
||||
DisableTroll(victim, "No Pickup");
|
||||
DisableTroll(victim, "Primary Disable");
|
||||
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
} else if(StrEqual(troll.name, "Primary Disable")) {
|
||||
DisableTroll(victim, "UziRules");
|
||||
DisableTroll(victim, "No Pickup");
|
||||
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
} else if(StrEqual(troll.name, "No Pickup")) {
|
||||
DisableTroll(victim, "UziRules");
|
||||
DisableTroll(victim, "Primary Disable");
|
||||
SDKHook(victim, SDKHook_WeaponCanUse, Event_ItemPickup);
|
||||
} else if(StrEqual(troll.name, "CameTooEarly")) {
|
||||
ReplyToCommand(activator, "This troll mode is not implemented.");
|
||||
} else if(StrEqual(troll.name, "KillMeSoftly")) {
|
||||
static char wpn[32];
|
||||
GetClientWeaponName(victim, 4, wpn, sizeof(wpn));
|
||||
if(StrEqual(wpn, "weapon_adrenaline") || StrEqual(wpn, "weapon_pain_pills")) {
|
||||
ClientCommand(victim, "slot5");
|
||||
g_bPendingItemGive[victim] = true;
|
||||
}else{
|
||||
ReplyToCommand(activator, "User does not have pills or adrenaline");
|
||||
return false;
|
||||
}
|
||||
//TODO: Implement TrollMod_Constant
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Throw It All")) {
|
||||
if(modifier == TrollMod_Instant)
|
||||
ThrowAllItems(victim);
|
||||
if(hThrowTimer == INVALID_HANDLE && modifier == TrollMod_Constant) {
|
||||
hThrowTimer = CreateTimer(hThrowItemInterval.FloatValue, Timer_ThrowTimer, _, TIMER_REPEAT);
|
||||
}
|
||||
} else if(StrEqual(troll.name, "Swarm")) {
|
||||
if(modifier == TrollMod_Instant) {
|
||||
L4D2_RunScript("RushVictim(GetPlayerFromUserID(%d), %d)", victim, 15000);
|
||||
}
|
||||
return true;
|
||||
} else if(StrEqual(troll.name, "Gun Jam")) {
|
||||
int wpn = GetClientWeaponEntIndex(victim, 0);
|
||||
if(wpn > -1)
|
||||
SDKHook(wpn, SDKHook_Reload, Event_WeaponReload);
|
||||
else {
|
||||
ReplyToCommand(activator, "Victim does not have a primary weapon.");
|
||||
return false;
|
||||
}
|
||||
} else if(StrEqual(troll.name, "Vomit Player"))
|
||||
L4D_CTerrorPlayer_OnVomitedUpon(victim, victim);
|
||||
else if(StrEqual(troll.name, "Inface Special")) {
|
||||
FakeClientCommand(victim, "sm_inface");
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Insta Special")) {
|
||||
FakeClientCommand(victim, "sm_insta");
|
||||
return false;
|
||||
} else if(StrEqual(troll.name, "Goo")) {
|
||||
static float pos[3], ang[3];
|
||||
GetClientAbsOrigin(victim, pos);
|
||||
GetClientAbsAngles(victim, ang);
|
||||
L4D2_SpitterPrj(victim, pos, ang);
|
||||
} else if(StrEqual(troll.name, "Stagger")) {
|
||||
L4D_StaggerPlayer(victim, victim, NULL_VECTOR);
|
||||
} else {
|
||||
#if defined DEBUG
|
||||
PrintToServer("[FTT] Possibly invalid troll, no action: %s", troll.name);
|
||||
ReplyToCommand(activator, "[FTT/Debug] If nothing occurs, this troll possibly was not implemented correctly. ");
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsTrollActive(int client, const char[] troll) {
|
||||
if(troll[0] == '\0') {
|
||||
ThrowError("Troll name is empty");
|
||||
|
|
|
@ -255,6 +255,50 @@ public Action Command_ApplyUser(int client, int args) {
|
|||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_ApplyUserSilent(int client, int args) {
|
||||
if(args < 1) {
|
||||
SilentMenuSelected[client] = true;
|
||||
ShowTrollMenu(client);
|
||||
}else{
|
||||
char arg1[32], arg2[16];
|
||||
GetCmdArg(1, arg1, sizeof(arg1));
|
||||
GetCmdArg(2, arg2, sizeof(arg2));
|
||||
StringToLower(arg2);
|
||||
|
||||
static char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[1], target_count;
|
||||
bool tn_is_ml;
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg1,
|
||||
client,
|
||||
target_list,
|
||||
1,
|
||||
COMMAND_FILTER_NO_MULTI,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
tn_is_ml)) <= 0
|
||||
&& target_list[0] > 0) {
|
||||
/* This function replies to the admin with a failure message */
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
SilentMenuSelected[client] = true;
|
||||
if(args == 2) {
|
||||
static char key[32];
|
||||
for(int i = 0; i < categories.Length; i++) {
|
||||
categories.GetString(i, key, sizeof(key));
|
||||
if(StrEqual(key, arg2, false)) {
|
||||
ShowTrollsForCategory(client, GetClientUserId(target_list[0]), i);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
ReplyToCommand(client, "[FTT] Unknown category: '%s'", arg2);
|
||||
}
|
||||
SetupCategoryMenu(client, target_list[0]);
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_ListModes(int client, int args) {
|
||||
static char name[MAX_TROLL_NAME_LENGTH];
|
||||
static Troll troll;
|
||||
|
|
|
@ -267,8 +267,8 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
|||
ArrayList phrases;
|
||||
bool foundWord = false;
|
||||
int words = ExplodeString(sArgs, " ", strings, 32, MAX_PHRASE_LENGTH);
|
||||
// Replace all swear words
|
||||
for(int i = 0; i < words; i++) {
|
||||
//TODO: Check for valid working
|
||||
phrases = GetPhrasesArray(strings[i]);
|
||||
if(phrases != null && phrases.Length > 0) {
|
||||
foundWord = true;
|
||||
|
@ -277,25 +277,30 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
|||
}
|
||||
int length = MAX_PHRASE_LENGTH * words;
|
||||
char[] message = new char[length];
|
||||
|
||||
if(foundWord) {
|
||||
ImplodeStrings(strings, 32, " ", message, length);
|
||||
} else {
|
||||
} else if(Trolls[profanityID].activeFlagClients[client] & 2) { //Replace full messages if flag enabled
|
||||
if(!fullMessagePhraseList) {
|
||||
PrintToServer("[FTT] Error: Could not find full message phrases!!!");
|
||||
return Plugin_Continue;
|
||||
}
|
||||
fullMessagePhraseList.GetString(GetRandomInt(0, fullMessagePhraseList.Length - 1), message, MAX_PHRASE_LENGTH);
|
||||
} else {
|
||||
return Plugin_Continue;
|
||||
}
|
||||
if(Trolls[profanityID].activeFlagClients[client] % 2) {
|
||||
|
||||
if(Trolls[profanityID].activeFlagClients[client] & 8) { //If 'show original' enabled
|
||||
CPrintToChat(client, "{blue}%N {default}: %s", client, sArgs);
|
||||
for(int i = 1; i <= MaxClients; i++) {
|
||||
if(IsClientConnected(i) && IsClientInGame(i) && i != client) {
|
||||
CPrintToChat(i, "{blue}%N {default}: %s", client, message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else { //else show modified to all
|
||||
CPrintToChatAll("{blue}%N {default}: %s", client, message);
|
||||
}
|
||||
// Print original in console no matter what
|
||||
PrintToServer("%N: %s", client, sArgs);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue