TyanColte |
10-26-2011 20:31 |
Please Help
I did find a use for this post after all, i'm working on modifying a plugin that is basically a TK forgiving plugin. I made it where it's not TKs that trigger the forgiving system but opposite team attacks/kills i need to figure out a way to have a player put a command where (since i run an achievement server) they can temporarily disable the forgiving system for arena battles and if they go afk to allow other players to farm kills. Can some body help?
Code posted below
PHP Code:
#include <sourcemod>
#include <colors>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "1.2"
public Plugin:myinfo =
{
name = "TA fogive / say sorry",
author = "J. (Keksmampfer) Wiese",
description = "<- Description ->",
version = PLUGIN_VERSION,
url = "http://www.oldschool-gaming.de/news/"
}
new Handle:g_version = INVALID_HANDLE;
new Handle:g_enable = INVALID_HANDLE;
new Handle:g_forgive = INVALID_HANDLE;
new Handle:g_saysorry = INVALID_HANDLE;
new Handle:g_maxpoints = INVALID_HANDLE;
new Handle:g_punish_mode = INVALID_HANDLE;
new Handle:g_punish_bantime = INVALID_HANDLE;
new Handle:g_sorry_sound = INVALID_HANDLE;
new Handle:g_timebeteewnattacks = INVALID_HANDLE;
new Handle:g_manicompatible= INVALID_HANDLE;
new g_points[MAXPLAYERS+1];
new bool:g_fssenable[MAXPLAYERS+1] = {true, true, true , ...};
new bool:g_timebetweenenable[MAXPLAYERS+1] = {true, true, true , ...};
public OnPluginStart()
{
g_version = CreateConVar("sm_ta_fss_version", PLUGIN_VERSION, "TA fogive / say sorry plugin version", FCVAR_DONTRECORD|FCVAR_REPLICATED|FCVAR_NOTIFY);
g_enable = CreateConVar("sm_ta_fss_enable", "1", "1 - Turn the plugin On\n0 - Turn the plugin OFF", _, true, 0.0, true, 1.0);
g_forgive = CreateConVar("sm_ta_fss_forgive", "1", "1 - Turn the Forgivemenu On\n0 - Turn the Forgivemenu OFF", _, true, 0.0, true, 1.0);
g_saysorry = CreateConVar("sm_ta_fss_saysorry", "1", "1 - Turn the Saysorrymenu On\n0 - Turn the Forgivemenu OFF", _, true, 0.0, true, 1.0);
g_maxpoints = CreateConVar("sm_ta_fss_points_limit", "8", "The maximum nuber of points a player can reach bevore he gets punished" , _, true, 0.0,true,99.0);
g_punish_mode = CreateConVar("sm_ta_fss_punishmode", "1", "0 - Kick\n1 - Ban", _, true, 0.0, true, 1.0);
g_punish_bantime = CreateConVar("sm_ta_fss_bantime", "5", "Bantime (minutes) , only if sm_ta_fss_punishmode = 1 ", _, true, 0.0, true, 500.0);
g_sorry_sound = CreateConVar("sm_ta_fss_saysorrysound", "vo/npc/female01/sorry01.wav", "The say sorry soundfilepath (relative to the \"sound/\" folder)");
g_timebeteewnattacks = CreateConVar("sm_ta_fss_timebeteewnattacks", "10.0", "Number of sconds between the repopup of the menue is allowed.", _, true, 2.0, true, 200.0);
g_manicompatible = CreateConVar("sm_ta_fss_manicompatible", "1", "1 - The forgivemenu won't popup if the victim dies.\n0 - Popup normally.", _, true, 0.0, true, 1.0);
AutoExecConfig(true,"ta.forgive.saysorry");
LoadTranslations("ta.fss.phrases");
if(GetConVarBool(g_enable))
{
HookEvent("player_activate", Event_activate);
HookEvent("player_hurt", Event_hurt);
}
HookConVarChange(g_enable, CB_enable );
SetConVarString(g_version, PLUGIN_VERSION);
decl String:longfile[100];
decl String:file[50];
GetConVarString(g_sorry_sound, file, sizeof(file));
Format(longfile, sizeof(longfile), "sound/%s", file);
AddFileToDownloadsTable(longfile);
PrecacheSound(file);
}
public CB_enable(Handle:cvar, const String:oldVal[], const String:newVal[])
{
//no change = no action
if( oldVal[0] == newVal[0]) return ;
switch (StringToInt(newVal))
{
case 0 :
{
LogMessage("Disable.");
UnhookEvent("player_activate", Event_activate);
UnhookEvent("player_hurt", Event_hurt);
}
case 1:
{
LogMessage("Enable.");
HookEvent("player_activate", Event_activate);
HookEvent("player_hurt", Event_hurt);
}
}
}
public Action:Event_activate(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
g_points[client] = 0;
g_fssenable[client]= true;
g_timebetweenenable[client] = true;
}
public Action:Event_hurt(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if(victim == attacker || attacker == 0 || victim == 0) return;
new victimteam = GetClientTeam(victim);
new attackerteam = GetClientTeam(attacker);
if(victimteam != attackerteam)
{
if(!g_timebetweenenable[attacker])
{
return;
}
if(!g_fssenable[attacker])
{
if(GetConVarBool(g_forgive)) SetClientPoints(attacker, 1);
if(GetConVarBool(g_saysorry)) SetClientPoints(attacker, 1);
if(IsClientInGame(attacker)) PrintToChat(attacker, "%t","Don't attack others unless asked.", g_points[attacker], GetConVarInt(g_maxpoints));
g_timebetweenenable[attacker] = false;
CreateTimer(2.0 , Timebetweenenable, attacker);
return;
}
if(GetConVarBool(g_forgive))
{
if(IsFakeClient(victim))
{
decl String:victimname[MAX_NAME_LENGTH+1];
GetClientName(victim, victimname, sizeof(victimname));
if(IsClientInGame(attacker)) PrintToChat(attacker, "%t","Bots Don't Count", victimname, g_points[attacker], GetConVarInt(g_maxpoints));
}
else
{
CreateForgivemenue(victim, attacker);
}
}
if(GetConVarBool(g_saysorry) && IsClientInGame(attacker))
{
if(IsFakeClient(attacker))
{
decl String:attackername[MAX_NAME_LENGTH+1];
GetClientName(attacker, attackername, sizeof(attackername));
if(IsClientInGame(victim)) CPrintToChatEx(victim, attacker, "%T", "Sorry", victim, attackername);
Play_SaySorry(victim);
}
else
{
CreateSaysorrymenu(attacker, victim);
}
}
g_fssenable[attacker] = false;
CreateTimer(GetConVarFloat(g_timebeteewnattacks), Fssenable, attacker, TIMER_FLAG_NO_MAPCHANGE);
g_timebetweenenable[attacker] = false;
CreateTimer(2.0 , Timebetweenenable, attacker,TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action:Timebetweenenable(Handle:timer, any:data)
{
new client = data;
g_timebetweenenable[client] = true;
}
public Action:Fssenable(Handle:timer, any:data)
{
new client = data;
g_fssenable[client] = true;
}
CreateForgivemenue(client, attacker)
{
if(GetConVarBool(g_manicompatible) && !IsPlayerAlive(client))
{
return;
}
//format the attacker id to save it in the menu
decl String:buffer[10] ;
IntToString(attacker, buffer, sizeof(buffer));
new Handle:menu = CreateMenu(Forgive);
//format the yes option
decl String:yes[12];
Format(yes, sizeof(yes), "%T", "Yes", client);
//format the no option
decl String:no[12];
Format(no, sizeof(no), "%T", "No", client);
//create menu items
SetMenuTitle(menu, "%T", "Forgive?", client);
AddMenuItem(menu, buffer, yes);
AddMenuItem(menu, buffer, no);
SetMenuExitButton(menu, false);
//display menu to victim
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public Forgive(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new attacker = StringToInt(info);
if(!IsClientInGame(attacker) || !IsClientInGame(param1)) return;
decl String:victimname[MAX_NAME_LENGTH+1];
GetClientName(param1 , victimname, sizeof(victimname));
decl String:attackername[MAX_NAME_LENGTH+1];
GetClientName(attacker, attackername, sizeof(attackername));
switch(param2)
{
case 0:
{
PrintToChat(param1, "%t","You forgiven",attackername);
PrintToChat(attacker, "%t","Forgiven", victimname);
//sound
}
case 1:
{
SetClientPoints(attacker, 1);
if(IsClientInGame(attacker)) PrintToChat(attacker, "%t", "Not forgiven", victimname, g_points[attacker], GetConVarInt(g_maxpoints));
if(IsClientInGame(param1)) PrintToChat(param1, "%t" ,"You not forgiven", attackername);
}
}
}
else if (action == MenuAction_Cancel)
{
decl String:info[32];
GetMenuItem(menu, 0 , info, sizeof(info));
new attacker = StringToInt(info);
if(!IsClientInGame(attacker) || !IsClientInGame(param1)) return;
decl String:victimname[MAX_NAME_LENGTH+1];
GetClientName(param1 , victimname, sizeof(victimname));
decl String:attackername[MAX_NAME_LENGTH+1];
GetClientName(attacker, attackername, sizeof(attackername));
SetClientPoints(attacker, 1);
if(IsClientInGame(attacker)) PrintToChat(attacker, "%t", "Not forgiven", victimname, g_points[attacker] , GetConVarInt(g_maxpoints));
if(IsClientInGame(param1)) PrintToChat(param1, "%t" ,"You not forgiven", attackername);
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
CreateSaysorrymenu(client, victim)
{
new String:buffer[10] ;
IntToString(victim, buffer, sizeof(buffer));
new Handle:menu = CreateMenu(SaySorry);
SetMenuTitle(menu, "%T","Say sorry?", client);
decl String:yes[12];
Format(yes, sizeof(yes), "%T", "Yes", client);
AddMenuItem(menu, buffer, yes);
decl String:no[12];
Format(no, sizeof(no), "%T", "No", client);
AddMenuItem(menu, buffer, no);
SetMenuExitButton(menu, false);
DisplayMenu(menu, client, MENU_TIME_FOREVER);
}
public SaySorry(Handle:menu, MenuAction:action, param1, param2)
{
if (action == MenuAction_Select)
{
decl String:info[32];
GetMenuItem(menu, param2, info, sizeof(info));
new victim = StringToInt(info);
if(!IsClientInGame(victim) || !IsClientInGame(param1)) return;
decl String:attackername[MAX_NAME_LENGTH+1];
GetClientName(param1 , attackername, sizeof(attackername));
decl String:victimname[MAX_NAME_LENGTH+1];
GetClientName(victim, victimname, sizeof(victimname));
switch(param2)
{
case 0:
{
Play_SaySorry(param1);
Play_SaySorry(victim);
if(IsClientInGame(victim)) CPrintToChatEx(victim, param1, "%T", "Sorry", victim, attackername);
if(IsClientInGame(param1)) CPrintToChatEx(param1, param1, "%T", "Sorry", param1, attackername);
}
case 1:
{
SetClientPoints(param1, 1);
if(IsClientInGame(victim)) PrintToChat(victim, "%t", "Not Sorry" , attackername);
if(IsClientInGame(param1)) PrintToChat(param1, "%t", "You not sorry" ,victimname , g_points[param1], GetConVarInt(g_maxpoints));
}
}
}
else if (action == MenuAction_Cancel)
{
if(param2 == MenuCancel_Interrupted)
{
decl String:info[32];
GetMenuItem(menu, 0, info, sizeof(info));
new victim = StringToInt(info);
if(!IsClientInGame(victim) || !IsClientInGame(param1)) return;
decl String:attackername[MAX_NAME_LENGTH+1];
GetClientName(param1 , attackername, sizeof(attackername));
decl String:victimname[MAX_NAME_LENGTH+1];
GetClientName(victim, victimname, sizeof(victimname));
SetClientPoints(param1, 1);
if(IsClientInGame(victim)) PrintToChat(victim, "%t", "Not Sorry" , attackername);
if(IsClientInGame(param1)) PrintToChat(param1, "%t", "You not sorry" ,victimname , g_points[param1], GetConVarInt(g_maxpoints));
}
}
else if (action == MenuAction_End)
{
CloseHandle(menu);
}
}
SetClientPoints(client , number)
{
if(!IsClientInGame(client)) return;
g_points[client] += number;
if( GetConVarInt(g_maxpoints) < g_points[client] )
{
switch(GetConVarInt(g_punish_mode))
{
case 0:
{
KickClient(client, "%t", "Kickmsg");
}
case 1:
{
new bantime = GetConVarInt(g_punish_bantime);
decl String:reason[100];
Format(reason, sizeof(reason), "%t","Banmsg",bantime );
BanClient(client, bantime,BANFLAG_AUTO|BANFLAG_AUTHID, reason, reason);
}
}
}
}
Play_SaySorry(client)
{
decl String:file[50];
GetConVarString(g_sorry_sound, file ,sizeof(file));
ClientCommand(client, "playgamesound \"%s\"", file);
}
|