Raised This Month: $165 Target: $400
 41% 

[L4D2] Anti-Runner System


Post New Thread Reply   
 
Thread Tools Display Modes
Skorpion1976
Veteran Member
Join Date: Jun 2009
Location: Austria
Old 04-03-2010 , 09:28   Re: [L4D2] Anti-Runner System
Reply With Quote #11

sorry but it´s not working properly. every other map the round does not end though all survivors are in safe room. no errors in sm log.
Skorpion1976 is offline
terminator2k2
Senior Member
Join Date: Feb 2010
Old 04-03-2010 , 14:01   Re: [L4D2] Anti-Runner System
Reply With Quote #12

Quote:
Originally Posted by Herokim View Post
Could you at least make to show a menu to person that is keyman? But not to other.....

i think if u show the person who is the keyman then that person might mess around rather than go to the saferoom, as every 1 is depending on him......

also to the op.....thanks for the plugin...working great so far...no problems at all.....

Last edited by terminator2k2; 04-03-2010 at 18:34.
terminator2k2 is offline
kiraibrasil
Member
Join Date: Jun 2009
Old 04-03-2010 , 21:17   Re: [L4D2] Anti-Runner System
Reply With Quote #13

Coop = 100% works
Versus = 66% Works have bug
kiraibrasil is offline
kiraibrasil
Member
Join Date: Jun 2009
Old 04-03-2010 , 21:55   Re: [L4D2] Anti-Runner System
Reply With Quote #14

I fixed the plugins in versus mode. Damn I translate for my language, the more you can put into your language.
I do not get the error charger door. So I hung up

PHP Code:
#include <sourcemod>
#include <sdktools>

#define DEBUG 0
#define JAPANESE 0
#define PLUGIN_VERSION "1.0"
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY
#define MAXLENGTH 128

#define SURVIVOR 2
#define CHARGER 6
#define TANK 8

#define UNLOCK 0
#define LOCK 1

new Handle:sm_ar_announce INVALID_HANDLE;
new 
Handle:sm_ar_assault_health INVALID_HANDLE;
new 
Handle:sm_ar_assault_hate INVALID_HANDLE;
new 
Handle:sm_ar_lock_tankalive INVALID_HANDLE;

/* Lock flag */
new SafetyLock;

/* Keyman's ID */
new idKeyman;

/* Goal door ID */
new idGoal;

/* Keyman's name */
new String:nmKeyman[MAXLENGTH];

/* Sound file */
new String:SoundNotice[MAXLENGTH] = "doors/latchlocked2.wav";
new 
String:SoundDoorOpen[MAXLENGTH] = "doors/door_squeek1.wav";
new 
String:SoundDoorSpawn[MAXLENGTH] = "music/gallery_music.mp3";

/* Assault door model */
new String:ModelAssault[MAXLENGTH] = "models/props_doors/checkpoint_door_02.mdl";

public 
Plugin:myinfo 
{
    
name "[L4D2] Anti-Runner System feat.Assault door",
    
author "ztar",
    
description "Only Keyman can open saferoom door.",
    
version PLUGIN_VERSION,
    
url "http://ztar.blog7.fc2.com/"
}

public 
OnPluginStart()
{
    
sm_ar_announce          CreateConVar("sm_ar_announce","1""Announce plugin info(0:OFF 1:ON)"CVAR_FLAGS);
    
sm_ar_assault_health CreateConVar("sm_ar_assault_health","2000""Health of Assault door"CVAR_FLAGS);
    
sm_ar_assault_hate      CreateConVar("sm_ar_assault_hate","0""Probability of spawning Assault door(0-100)"CVAR_FLAGS);
    
sm_ar_lock_tankalive CreateConVar("sm_ar_lock_tankalive","1""Lock door if any Tank is alive(0:OFF 1:ON)"CVAR_FLAGS);
    
    
HookEvent("player_death"Event_Player_Death);
    
HookEvent("player_use"Event_Player_Use);
    
HookEvent("round_start"Event_Round_Start);
    
HookEvent("player_team"Event_Join_Team);
    
    
AutoExecConfig(true"l4d2_anti-runner");
}

public 
OnMapStart()
{
    
/* Precache */
    
PrecacheSound(SoundNoticetrue);
    
PrecacheSound(SoundDoorOpentrue);
    
PrecacheSound(SoundDoorSpawntrue);
    
PrecacheModel(ModelAssaulttrue);
    
    
/* Find goal door and lock */
    //InitDoor();
    
    /* Select Keyman */
    //SelectKeyman();
    #if DEBUG
    //LogMessage("[ARS][0] Keyman selected -> <%d:%s>", idKeyman, nmKeyman);
    #endif
}

public 
OnClientPutInServer(client)
{
    if(!
IsValidEntity(client))
        return;
    if(
IsFakeClient(client))
        return;
    
    
/* Announce about this plugin */
    
CreateTimer(20.0TimerAnnounceclient);
}

public 
Event_Join_Team(Handle:eventString:event_name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
clientTeam GetEventInt(event"team");
    new 
bool:isBot GetEventBool(event"isbot");
    
    if(!
IsValidEntity(client) || isBot == true)
        return;
    if(
clientTeam == SURVIVOR)
    {
        
SelectKeyman();
        
#if DEBUG
        
LogMessage("[ARS][1] Keyman selected -> <%d:%s>"idKeymannmKeyman);
        
#endif
    
}
}

public 
Action:TimerAnnounce(Handle:timerany:client)
{
    if(
IsClientInGame(client) && GetConVarInt(sm_ar_announce))
        
PrintToChat(client"\x04[ARS]\x01 Sistema de\x03 Anti-Rush \x01ativado.");
}

public 
OnClientDisconnect(client)
{
    if(!
IsValidEntity(client))
        return;
    
    
/* If Keyman disconnect, Re-select Keyman */
    
if(client == idKeyman)
    {
        
SelectKeyman();
        
#if DEBUG
        
LogMessage("[ARS][2] Keyman selected -> <%d:%s>"idKeymannmKeyman);
        
#endif
    
}
}

public 
Action:RoundStartDelay(Handle:timerany:client)
{
    
InitDoor();
    
SelectKeyman();
    
#if DEBUG
    
LogMessage("[ARS][3] Keyman selected -> <%d:%s>"idKeymannmKeyman);
    
#endif
}

public 
Action:Event_Round_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(1.0RoundStartDelay)
}

public 
Action:Event_Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    
    
/* If victim was Keyman, Re-select Keyman */
    
if(victim == idKeyman)
    {
        
SelectKeyman();
        
#if DEBUG
        
LogMessage("[ARS][4] Keyman selected -> <%d:%s>"idKeymannmKeyman);
        
#endif
    
}
    return 
Plugin_Continue;
}

public 
Action:Event_Player_Use(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    new 
Entity GetEventInt(event"targetid");
    
    if(
IsValidEntity(Entity) && (SafetyLock == LOCK) && (Entity == idGoal))
    {
        new 
String:entname[MAXLENGTH];
        if(
GetEdictClassname(Entityentnamesizeof(entname)))
        {
            
/* Saferoom door */
            
if(StrEqual(entname"prop_door_rotating_checkpoint"))
            {
                for (new 
1<= GetMaxClients(); i++)
                {
                    
/* is valid, in game, alive, and not bot */
                    
if(IsValidEntity(i) && IsClientInGame(i))
                    {
                        if(
GetEntProp(iProp_Send"m_zombieClass") == TANK && GetConVarInt(sm_ar_lock_tankalive))
                        {
                            
EmitSoundToAll(SoundNoticeEntity);
                            
PrintHintText(client"O Tank ainda está vivo, mate-o seu covarde!");
                            return 
Plugin_Continue;
                        }
                    }
                }
                
                
AcceptEntityInput(Entity"Lock");
                
SetEntProp(EntityProp_Data"m_hasUnlockSequence"LOCK);
                
                if(!
IsValidEntity(idKeyman) || !IsClientInGame(idKeyman) || !IsPlayerAlive(idKeyman) || IsFakeClient(idKeyman))
                {
                    
SelectKeyman();
                    
#if DEBUG
                    
LogMessage("[ARS][5] Keyman selected -> <%d:%s>"idKeymannmKeyman);
                    
#endif
                
}
                
                if(
client == idKeyman)
                {
                    
/* If client is Keyman, unlock */
                    
EmitSoundToAll(SoundDoorOpenEntity);
                    
SafetyLock UNLOCK;
                    
ControlDoor(EntityUNLOCK);
                    if(
GetConVarInt(sm_ar_announce))
                    {
                        
PrintToChatAll("\x04[ARS] \x01O Homem-Chave \x03%s\x01 chegou na Sala Segura!"nmKeyman);
                    }
                    
                    
/* Caluculate probability */
                    
new adProb GetConVarInt(sm_ar_assault_hate);
                    
//new adProb = GetConVarInt(sm_ar_assault_hate) * (DeadCount()+1);
                    
if(adProb 100adProb 100;
                    if(
adProb GetRandomInt(099))
                    {
                        
/* Spawn Assault door */
                        //PrintHintTextToAll("Porta de ASSALTO!");
                        //AssaultDoor(client, Entity);
                    
}
                }
                else
                {
                    
/* Notify client who is Keyman */
                    
EmitSoundToAll(SoundNoticeEntity);
                    
PrintHintTextToAll("O Homem-Chave é %s.\nApenas ele pode abrir a porta da Sala Segura!"nmKeyman);
                }
            }
        }
    }
    return 
Plugin_Continue;
}

public 
SelectKeyman()
{
    new 
count 0;
    new 
idAlive[MAXPLAYERS+1];
    
    
/* See all clients */
    
for (new 1<= GetMaxClients(); i++)
    {
        
/* is valid, in game, alive, and not bot */
        
if(IsValidEntity(i) && IsClientInGame(i) && IsPlayerAlive(i) && !IsFakeClient(i))
        {
            
/* Survivor team */
            
if(GetClientTeam(i) == SURVIVOR)
            {
                
idAlive[count] = i;
                
count++;
            }
        }
    }
    if(
count == 0) return;
    new 
key GetRandomInt(0count-1);
    
    
/* Get Keyman ID and name */
    
idKeyman idAlive[key];
    
GetClientName(idKeymannmKeymansizeof(nmKeyman));
    
    return;
}

public 
InitDoor()
{
    new 
Entity = -1;
    while((
Entity FindEntityByClassname(Entity"prop_door_rotating_checkpoint")) != -1)
    {
        if(
GetEntProp(EntityProp_Data"m_hasUnlockSequence") == UNLOCK)
        {
            
idGoal Entity;
            
ControlDoor(EntityLOCK);
        }
    }
    
SafetyLock LOCK;
}

public 
ControlDoor(EntityOperation)
{
    if(
Operation == LOCK)
    {
        
/* Close and lock */
        
AcceptEntityInput(Entity"Close");
        
AcceptEntityInput(Entity"Lock");
        
AcceptEntityInput(Entity"ForceClosed");
        
SetEntProp(EntityProp_Data"m_hasUnlockSequence"LOCK);
    }
    else if(
Operation == UNLOCK)
    {
        
/* Unlock and open */
        
SetEntProp(EntityProp_Data"m_hasUnlockSequence"UNLOCK);
        
AcceptEntityInput(Entity"Unlock");
        
AcceptEntityInput(Entity"ForceClosed");
        
AcceptEntityInput(Entity"Open");
    }
}

public 
AssaultDoor(clientEntity)
{
    if(!
client) return;
    
    
/* Spawn Charger */
    
new admindata GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    new 
spawnflags GetCommandFlags("z_spawn");
    
SetCommandFlags("z_spawn"spawnflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"z_spawn charger");
    
SetCommandFlags("z_spawn"spawnflags|FCVAR_CHEAT);
    
SetUserFlagBits(clientadmindata);
    
    for (new 
1<= GetMaxClients(); i++)
    {
        
/* is Charger */
        
if(GetEntProp(iProp_Send"m_zombieClass") == CHARGER)
        {
            
/* Get entity position */
            
decl Float:pos[3];
            
GetClientAbsOrigin(clientpos);
            
pos[2] += 30;
            
            
/* Teleport after setting up */
            
ScreenFade(client200002001001);
            
SetEntityModel(iModelAssault);
            
SetEntityHealth(iGetConVarInt(sm_ar_assault_health));
            
TeleportEntity(iposNULL_VECTORNULL_VECTOR);
            
EmitSoundToAll(SoundDoorSpawni);
            
            return;
        }
    }
}

public 
DeadCount()
{
    new 
dCount 0;
    
    
/* See all clients */
    
for (new 1<= GetMaxClients(); i++)
    {
        if(!
IsValidEntity(i) || !IsClientInGame(i) || IsFakeClient(i))
            continue;
        
        
/* Count DEAD player in survivor team */
        
if(!IsPlayerAlive(i))
            
dCount++;
    }
    return 
dCount;
}

public 
ScreenFade(targetredgreenbluealphadurationtype)
{
    new 
Handle:msg StartMessageOne("Fade"target);
    
BfWriteShort(msg500);
    
BfWriteShort(msgduration);
    if (
type == 0)
        
BfWriteShort(msg, (0x0002 0x0008));
    else
        
BfWriteShort(msg, (0x0001 0x0010));
    
BfWriteByte(msgred);
    
BfWriteByte(msggreen);
    
BfWriteByte(msgblue);
    
BfWriteByte(msgalpha);
    
EndMessage();

Sorry for my bad english

Last edited by kiraibrasil; 04-03-2010 at 21:59.
kiraibrasil is offline
terminator2k2
Senior Member
Join Date: Feb 2010
Old 04-05-2010 , 17:31   Re: [L4D2] Anti-Runner System
Reply With Quote #15

hi there , had a few times where it will not let any one open the saferoom door......also when this happens you dont get the message come up "blablabla has the key" this is in coop mode......havent checked source mod yet for errors....
terminator2k2 is offline
satannuts
Member
Join Date: Jan 2010
Old 04-06-2010 , 12:48   Re: [L4D2] Anti-Runner System
Reply With Quote #16

on first look, I thought this was to prevent people from speed hacking = Anti-Runner. But I was sadly mistaken. Good Work tho.
satannuts is offline
kiraibrasil
Member
Join Date: Jun 2009
Old 04-07-2010 , 18:58   Re: [L4D2] Anti-Runner System
Reply With Quote #17

I fix bug

l4d2_anti-runner_English.sp English

l4d2_anti-runner.sp PT-BR
kiraibrasil is offline
Acecombat2
Senior Member
Join Date: Nov 2009
Old 04-08-2010 , 04:08   Re: [L4D2] Anti-Runner System
Reply With Quote #18

what bug?

Edit: this?
Quote:
Originally Posted by kiraibrasil View Post
errors. Exp sometimes the survivor will close the door to the secure room and he did not finish the game
Map c5m2_park
__________________
I'm Noob So Please Don't Criticise me (Fail In Engglish)

Last edited by Acecombat2; 04-08-2010 at 04:14.
Acecombat2 is offline
mikhdenis
Member
Join Date: Aug 2009
Location: Ukraine
Old 04-08-2010 , 04:31   Re: [L4D2] Anti-Runner System
Reply With Quote #19

Quote:
Health of Assault door
It can be broken and opened without a key?
mikhdenis is offline
Jo-Barf_Creepy
Member
Join Date: Mar 2010
Location: Denmark
Old 04-08-2010 , 06:07   Re: [L4D2] Anti-Runner System
Reply With Quote #20

So very great idea you have there
__________________
I <3 SourceMod
_____________
(L4D2) Can anyone make a plugin to set the spit's size and damage?
Jo-Barf_Creepy is offline
Reply


Thread Tools
Display Modes

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 13:05.


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