Raised This Month: $ Target: $400
 0% 

[REQ] [L4D] Remove/Give Medkit on Safes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FuzzOne
Member
Join Date: Nov 2009
Location: Brazil
Old 11-05-2009 , 04:29   [REQ] [L4D] Remove/Give Medkit on Safes
Reply With Quote #1

Hi guys, i'm making a server where i want the survivors to always have just 2 medkits.

I need a plugin that remove all medkits from all survivors inventory, from Entrance Safe house and Exit Safe house, and later give 2 medkits to random survivors (but dont give to a bot).

I'm trying to modify this plugin , but i'm stuck...
http://forums.alliedmods.net/showthread.php?p=968013

Help plz?
FuzzOne is offline
Send a message via MSN to FuzzOne
DieTeetasse
Senior Member
Join Date: Jul 2009
Old 11-05-2009 , 06:39   Re: [REQ] [L4D] Remove/Give Medkit on Safes
Reply With Quote #2

Just Loop through all entities at the round start and delete entities with such a name like "weapon_first_aid_kit_spawn" (i am just guessing at the moment).

The only problem is, that the server needs a few seconds to register all entities in the list. You can see that if you enable the entity debug list per console (i think its the command "cl_entityreport", but i have to check that at home).

The medkit give thing is simple (this should with the right medkit name work):
PHP Code:
#include <sourcemod>

//Global variables
new bool:alreadygotsomething[4];
new 
bool:startarea true;

public 
OnPluginStart()
{
    
//Hook events
    
HookEvent("round_end"Event_round_end)
    
HookEvent("player_spawn"Event_player_spawnedEventHookMode_Post);
    
HookEvent("player_left_start_area"Event_player_left_start_area);


public 
OnMapStart()
{
    
init_values();
}

public 
Action:Event_round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    
//Get gamemode
    
new String:mode[10];
    new 
Handle:gamemode FindConVar("mp_gamemode");
    
GetConVarString(gamemodemodesizeof(mode));

    
//Sometimes Spawn is before Roundstart in 2nd round (only versus)
    
if (StrContains(mode"versus") > -1)
    {
        
init_values();
    }
}

init_values()
{
    
//On roundstart survivors are inside saferoom        
    
startarea true;
        
    
//Reset player
    
for (new 04i++)
    {
        
alreadygotsomething[i] = false;
    }
}

public 
Action:Event_player_spawned(Handle:event, const String:name[], bool:dontBroadcast)
{    
    
//Startarea?
    
if (startarea)
    {
        
//Get Client
        
new id GetEventInt(event"userid");
        new 
client GetClientOfUserId(id);
        
        
//Client survivor and human?
        
if (GetClientTeam(client) == && !IsFakeClient(client))
        {
            
//Get model
            
new String:modelname[200];
            
GetClientModel(clientmodelnamesizeof(modelname));
            
            new 
number;
            
//Find arraynumber by modelname
            //Zoey
            
if(StrContains(modelname"teenangst"false) != -1)
            {
                
number    0
            
}
            
//Francis
            
else if(StrContains(modelname"biker"false) != -1)
            {
                
number    1
            
}    
            
//Louis
            
else if(StrContains(modelname"manager"false) != -1)
            {
                
number    2
            
}    
            
//Bill
            
else if(StrContains(modelname"namvet"false) != -1)
            {
                
number    3
            
}                
            
            
//Model got already something or not?
            
if (!alreadygotsomething[number])
            {            
                
//Give medkit
                
CreateTimer(0.5Timer_GiveMedclient);

                
//Save that he might got something...
                
alreadygotsomething[number] = true;
            }
        }
    }
}  

public 
Action:Timer_GiveMed(Handle:timerany:client)
{
    
//Strip cheatflag
    
new flags GetCommandFlags("give")
    
SetCommandFlags("give"flags & ~FCVAR_CHEAT)
    
    
//Give item (just guessing the name!!!)
    
FakeClientCommand(client"give %s""weapon_first_aid_kit")
    
    
//Set cheatflag
    
SetCommandFlags("give"flags)

}

public 
Action:Event_player_left_start_area(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (
startarea)
    {
        
//First player left startarea, no more spawns
        
startarea false;
    }

DieTeetasse 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 03:59.


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