Raised This Month: $51 Target: $400
 12% 

Please Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TyanColte
Member
Join Date: Sep 2010
Old 10-26-2011 , 20:31   Please Help
Reply With Quote #1

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_manicompatibleINVALID_HANDLE;

new 
g_points[MAXPLAYERS+1];
new 
bool:g_fssenable[MAXPLAYERS+1] = {truetruetrue , ...};
new 
bool:g_timebetweenenable[MAXPLAYERS+1] = {truetruetrue , ...};



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"_true0.0true1.0);
    
g_forgive CreateConVar("sm_ta_fss_forgive""1""1 - Turn the Forgivemenu On\n0 - Turn the Forgivemenu OFF"_true0.0true1.0);
    
g_saysorry CreateConVar("sm_ta_fss_saysorry""1""1 - Turn the Saysorrymenu On\n0 - Turn the Forgivemenu OFF"_true0.0true1.0);
    
g_maxpoints CreateConVar("sm_ta_fss_points_limit""8""The maximum nuber of points a player can reach bevore he gets punished" _true0.0,true,99.0);
    
g_punish_mode CreateConVar("sm_ta_fss_punishmode""1""0 - Kick\n1 - Ban"_true0.0true1.0);
    
g_punish_bantime CreateConVar("sm_ta_fss_bantime""5""Bantime (minutes) , only if sm_ta_fss_punishmode = 1 "_true0.0true500.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."_true2.0true200.0); 
    
g_manicompatible CreateConVar("sm_ta_fss_manicompatible""1""1 - The forgivemenu won't popup if the victim dies.\n0 - Popup normally."_true0.0true1.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_enableCB_enable );
    
    
SetConVarString(g_versionPLUGIN_VERSION);
    
    
decl String:longfile[100];
    
decl String:file[50];
    
GetConVarString(g_sorry_soundfilesizeof(file));
    
Format(longfilesizeof(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 

        {
            
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 == || 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(attacker1);
            if(
GetConVarBool(g_saysorry)) SetClientPoints(attacker1);
            
            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 Timebetweenenableattacker);
            
            return;
        }
        
        if(
GetConVarBool(g_forgive))
        {
            if(
IsFakeClient(victim))
            {
                
decl String:victimname[MAX_NAME_LENGTH+1];
                
GetClientName(victimvictimnamesizeof(victimname)); 
                
                if(
IsClientInGame(attacker)) PrintToChat(attacker"%t","Bots Don't Count"victimnameg_points[attacker], GetConVarInt(g_maxpoints));
            }
            else
            {
                
CreateForgivemenue(victimattacker);
            }
        }
        
        if(
GetConVarBool(g_saysorry) && IsClientInGame(attacker))
        {
            if(
IsFakeClient(attacker))
            {
                
                
decl String:attackername[MAX_NAME_LENGTH+1];
                
GetClientName(attackerattackernamesizeof(attackername));
                
                if(
IsClientInGame(victim)) CPrintToChatEx(victimattacker"%T""Sorry"victimattackername);
                
                
Play_SaySorry(victim);
            }
            else
            {
                
CreateSaysorrymenu(attackervictim);
            }
        }
        
        
g_fssenable[attacker]  = false;
        
CreateTimer(GetConVarFloat(g_timebeteewnattacks), FssenableattackerTIMER_FLAG_NO_MAPCHANGE);
        
        
g_timebetweenenable[attacker] = false;
        
CreateTimer(2.0 Timebetweenenableattacker,TIMER_FLAG_NO_MAPCHANGE);
        
    }
}
public 
Action:Timebetweenenable(Handle:timerany:data)
{
    new 
client data;
    
g_timebetweenenable[client] = true;
}

public 
Action:Fssenable(Handle:timerany:data)
{
    new 
client data;
    
g_fssenable[client] = true;
}


CreateForgivemenue(clientattacker)
{
    if(
GetConVarBool(g_manicompatible) && !IsPlayerAlive(client))
    {
        return;
    }
    
//format the attacker id to save it in the menu
    
decl String:buffer[10] ;
    
IntToString(attackerbuffersizeof(buffer));
    
    new 
Handle:menu CreateMenu(Forgive);
    
    
//format the yes option
    
decl String:yes[12];
    
Format(yessizeof(yes), "%T""Yes"client);
    
    
//format the no option
    
decl String:no[12];
    
Format(nosizeof(no), "%T""No"client);
    
    
//create menu items
    
SetMenuTitle(menu"%T""Forgive?"client);
    
AddMenuItem(menubufferyes);
    
AddMenuItem(menubufferno);
    
SetMenuExitButton(menufalse);
    
    
//display menu to victim
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
    
    
}

public 
Forgive(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        
        
decl String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));
        new 
attacker StringToInt(info);    
        
        if(!
IsClientInGame(attacker) || !IsClientInGame(param1)) return;
        
        
decl String:victimname[MAX_NAME_LENGTH+1];
        
GetClientName(param1 victimnamesizeof(victimname));
        
        
decl String:attackername[MAX_NAME_LENGTH+1];
        
GetClientName(attackerattackernamesizeof(attackername));
        
        switch(
param2)
        {
            case 
0:
            {
                
PrintToChat(param1"%t","You forgiven",attackername);
                
PrintToChat(attacker"%t","Forgiven"victimname);
                
                
//sound
            
}
            
            case 
1:
            {
                
SetClientPoints(attacker1);
                
                if(
IsClientInGame(attacker)) PrintToChat(attacker"%t""Not forgiven"victimnameg_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(menuinfosizeof(info));
        new 
attacker StringToInt(info);    
        
        if(!
IsClientInGame(attacker) || !IsClientInGame(param1)) return;
        
        
decl String:victimname[MAX_NAME_LENGTH+1];
        
GetClientName(param1 victimnamesizeof(victimname));
        
        
decl String:attackername[MAX_NAME_LENGTH+1];
        
GetClientName(attackerattackernamesizeof(attackername));
        
        
SetClientPoints(attacker1);
        
        if(
IsClientInGame(attacker)) PrintToChat(attacker"%t""Not forgiven"victimnameg_points[attacker] , GetConVarInt(g_maxpoints));
        if(
IsClientInGame(param1)) PrintToChat(param1"%t" ,"You not forgiven"attackername);
    }
    else if (
action == MenuAction_End)
    {    
        
CloseHandle(menu);
    }
    
}
CreateSaysorrymenu(clientvictim)
{
    new 
String:buffer[10] ;
    
IntToString(victimbuffersizeof(buffer));
    
    new 
Handle:menu CreateMenu(SaySorry);
    
SetMenuTitle(menu"%T","Say sorry?"client);
    
    
decl String:yes[12];
    
Format(yessizeof(yes), "%T""Yes"client);
    
    
AddMenuItem(menubufferyes);
    
    
decl String:no[12];
    
Format(nosizeof(no), "%T""No"client);
    
    
AddMenuItem(menubufferno);
    
    
SetMenuExitButton(menufalse);
    
DisplayMenu(menuclientMENU_TIME_FOREVER);
}

public 
SaySorry(Handle:menuMenuAction:actionparam1param2)
{
    if (
action == MenuAction_Select)
    {
        
decl String:info[32];
        
GetMenuItem(menuparam2infosizeof(info));
        new 
victim StringToInt(info);
        
        if(!
IsClientInGame(victim) || !IsClientInGame(param1)) return;    
        
        
decl String:attackername[MAX_NAME_LENGTH+1];
        
GetClientName(param1 attackernamesizeof(attackername));
        
        
decl String:victimname[MAX_NAME_LENGTH+1];
        
GetClientName(victimvictimnamesizeof(victimname));
        
        switch(
param2)
        {
            case 
0:
            {
                
                
Play_SaySorry(param1);
                
Play_SaySorry(victim);
                
                if(
IsClientInGame(victim)) CPrintToChatEx(victimparam1"%T""Sorry"victimattackername);
                if(
IsClientInGame(param1)) CPrintToChatEx(param1param1"%T""Sorry"param1attackername);
                
            }
            case 
1:
            {
                
SetClientPoints(param11);
                
                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(menu0infosizeof(info));
            new 
victim StringToInt(info);
            
            if(!
IsClientInGame(victim) || !IsClientInGame(param1)) return;    
            
            
decl String:attackername[MAX_NAME_LENGTH+1];
            
GetClientName(param1 attackernamesizeof(attackername));
            
            
decl String:victimname[MAX_NAME_LENGTH+1];
            
GetClientName(victimvictimnamesizeof(victimname));
            
            
SetClientPoints(param11);
            
            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(reasonsizeof(reason), "%t","Banmsg",bantime );
                
BanClient(clientbantime,BANFLAG_AUTO|BANFLAG_AUTHIDreasonreason);
            }
        }
    }
}

Play_SaySorry(client)
{
    
decl String:file[50];
    
GetConVarString(g_sorry_soundfile ,sizeof(file));
    
    
ClientCommand(client"playgamesound \"%s\""file);    


__________________

Last edited by TyanColte; 10-27-2011 at 19:18. Reason: Figured it out.
TyanColte is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode