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

Solved L4D2 Molotov Thrower & Who burned Gascan ? announce


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eziosid
Senior Member
Join Date: Sep 2017
Old 12-14-2017 , 06:41   L4D2 Molotov Thrower & Who burned Gascan ? announce
Reply With Quote #1

need help for this code i want players need to know who is throw fire bottels
PHP Code:
public Action:weapon_molotov_Throw(Handle:event, const String:name[], bool:dontBroadcast)
{

    if(!
round_is_started)
        return 
Plugin_Continue;

    new 
target GetClientOfUserId(GetEventInt(event"userid"));

    if(
IsValidSurvivor(target))
    {
        new 
count count_number_alive();
        new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));

        if(
IsValidClient(attacker))
        {
            if(
attacker != target)
                
PrintToChatAll("\x01%N\x04 Throw Fire Bottles \x01%N",attackertarget);
            else
            
PrintToChatAll("",targetcount);
        }
        else
        {
            
PrintToChatAll("",targetcount);
        }
    }

    return 
Plugin_Continue;

tnx

UPDATE : sory i forgot this its for ( L4D2 )
plugin link is here https://forums.alliedmods.net/showthread.php?p=2256175

Last edited by eziosid; 12-16-2017 at 00:57. Reason: got working plugin tnx [ru]In1ernal Error
eziosid is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-14-2017 , 09:25   Re: Molotov Thrower announce
Reply With Quote #2

Can you please provide the whole source code here?
__________________
Psyk0tik is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-14-2017 , 09:30   Re: Molotov Thrower announce
Reply With Quote #3

Here you go:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnPluginEnd()
{
    
UnhookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnMolotovThrown(Event event, const char[] namebool dontBroadcast)
{
    
int thrower GetClientOfUserId(event.GetInt("userid"));
    if (!
IsValidClient(thrower))
    {
        return;
    }
    
    
PrintToChatAll("\x04%N\x01 Threw \x05Molotov!"thrower);

cravenge is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-14-2017 , 10:01   Re: Molotov Thrower announce
Reply With Quote #4

Quote:
Originally Posted by rogeraabbccdd View Post
I don't think there's a "molotov_thrown" event in CSGO, I can't find it in Alliedmodders wiki

PHP Code:
public void OnPluginStart() 
{
    
HookEvent("weapon_fire"Event_WeaponFire);
}

public 
Action Event_WeaponFire(Event event, const char[]namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid")); 
    
char sWeapon[50];
    
event.GetString("weapon"sWeaponsizeof(sWeapon));
    if (
IsValidClient(client) && StrEqual(sWeapon"molotov"))    PrintToChatAll("%N throw a molotov."client);

True, but I strongly believe this is meant for L4D2 since the OP's posts are all related to L4D2. I could be wrong though so, eh.
__________________
Psyk0tik is offline
eziosid
Senior Member
Join Date: Sep 2017
Old 12-14-2017 , 11:40   Re: Molotov Thrower announce
Reply With Quote #5

Quote:
Originally Posted by cravenge View Post
Here you go:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnPluginEnd()
{
    
UnhookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnMolotovThrown(Event event, const char[] namebool dontBroadcast)
{
    
int thrower GetClientOfUserId(event.GetInt("userid"));
    if (!
IsValidClient(thrower))
    {
        return;
    }
    
    
PrintToChatAll("\x04%N\x01 Threw \x05Molotov!"thrower);

thanks you cravenge sir and all this its works fine

(REQ) 1 more help i want to know gascan_burn code also

PHP Code:
PrintToChatAll("\x04%N\x01 Burned Gascan \x05Molotov!"burner); 
am new and learnig sory for bad eng tnx again
Attached Images
File Type: jpg zw.jpg (16.3 KB, 311 views)
eziosid is offline
eziosid
Senior Member
Join Date: Sep 2017
Old 12-15-2017 , 01:27   Re: Molotov Thrower announce
Reply With Quote #6

Quote:
Originally Posted by cravenge View Post
Here you go:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnPluginEnd()
{
    
UnhookEvent("molotov_thrown"OnMolotovThrown);
}

public 
void OnMolotovThrown(Event event, const char[] namebool dontBroadcast)
{
    
int thrower GetClientOfUserId(event.GetInt("userid"));
    if (!
IsValidClient(thrower))
    {
        return;
    }
    
    
PrintToChatAll("\x04%N\x01 Threw \x05Molotov!"thrower);

thank you very much sir its work .. keep it up
eziosid is offline
eziosid
Senior Member
Join Date: Sep 2017
Old 12-15-2017 , 01:45   Re: Molotov Thrower announce
Reply With Quote #7

need help for this what is worn in this code

PHP Code:
public void OnPluginStart() 

    
HookEvent("gascan_burn"Ongascanburn); 


public 
void OnPluginEnd() 

    
UnhookEvent("gascan_burn"Ongascanburn); 


public 
void Ongascanburn(Event event, const char[] namebool dontBroadcast

    
int burner GetClientOfUserId(event.GetInt("userid")); 
    if (!
IsValidClient(burner)) 
    { 
        return; 
    } 
     
    
PrintToChatAll("\x04%N\x01 Burned \x05Gascan!"burner); 

its say
HTML Code:
[SM] Exception reported: Game event "gascan_burn" does not exist
tnx in advance

Last edited by eziosid; 12-15-2017 at 01:47.
eziosid is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-15-2017 , 02:48   Re: Molotov Thrower announce
Reply With Quote #8

For burning gascans:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("break_breakable"OnBreakBreakableEventHookMode_Pre);
}

public 
void OnPluginEnd()
{
    
UnhookEvent("break_breakable"OnBreakBreakableEventHookMode_Pre);
}

public 
void OnBreakBreakable(Event event, const char[] namebool dontBroadcast)
{
    
int breaker GetClientOfUserId(event.GetInt("userid");
    if (!
IsValidClient(breaker))
    {
        return 
Plugin_Continue;
    }
    
    
int broke event.GetInt("entindex");
    if (
broke || !IsValidEntity(broke) || !IsValidEdict(broke))
    {
        return 
Plugin_Continue;
    }
    
    
char sBrokeModel[128];
    
GetEntPropString(brokeProp_Data"m_ModelName"sBrokeModelsizeof(sBrokeModel));
    if (
StrEqual(sBrokeModel"models/props_junk/gascan001a.mdl"false)
    {
        
PrintToChatAll("\x04%N\x01 Broke \x05Gascan\x01!"breaker);
    }
    return 
Plugin_Continue;

cravenge is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-15-2017 , 04:51   Re: Molotov Thrower announce
Reply With Quote #9

Here you go, I fixed all the tag mismatches in cravenge's code and added all the plugin details. I also added a game check so that the "gascan broken" announcement can still work in Left 4 Dead.

PHP Code:
#include <sourcemod>
#pragma semicolon 1
#pragma newdecls required
#define PLUGIN_VERSION "1.0"

char GameName[64], sBrokeModel[128];
ConVar l4d_mtgb_enable;
int L4D2Version;

public 
Plugin myinfo =
{
    
name "[L4D & L4D2] Molotov Thrown/Gascan Broken Announcer",
    
author "cravenge and eziosid",
    
description "Makes an announcement when players throw a molotov or break a gascan.",
    
version PLUGIN_VERSION,
    
url "https://forums.alliedmods.net/showthread.php?t=303599"
}

public 
void OnPluginStart()
{
    
GameCheck();
    
GetGameFolderName(GameNamesizeof(GameName));
    if(!
StrEqual(GameName"left4dead2"false))
    if(!
StrEqual(GameName"left4dead"false))
        
SetFailState("The Molotov Thrown/Gascan Broken Announcer supports L4D and L4D2 only.");
    
l4d_mtgb_enable CreateConVar("l4d_mtgb_enable""1""Enable the plugin?\n(0: OFF)\n(1: ON)");
    
CreateConVar("l4d_mtgb_version"PLUGIN_VERSION"Version of the plugin."FCVAR_SPONLY|FCVAR_DONTRECORD);
    if(
L4D2Version)
        
HookEvent("molotov_thrown"OnMolotovThrown);
    
HookEvent("break_breakable"OnBreakBreakableEventHookMode_Pre);
    
AutoExecConfig(true"l4d_mtgb");
}

public 
void OnPluginEnd()
{
    if(
L4D2Version)
        
UnhookEvent("molotov_thrown"OnMolotovThrown);
    
UnhookEvent("break_breakable"OnBreakBreakableEventHookMode_Pre);
}

public 
void OnMolotovThrown(Event event, const char[] namebool dontBroadcast)
{
    
int thrower GetClientOfUserId(event.GetInt("userid"));
    if(!
l4d_mtgb_enable.BoolValue || !IsValidClient(thrower))
        return;
    if(
L4D2Version)
        if(
l4d_mtgb_enable.BoolValue)
            
PrintToChatAll("\x04%N\x01 threw a \x05molotov!"thrower);
}

public 
void OnBreakBreakable(Event event, const char[] namebool dontBroadcast)
{
    
int breaker GetClientOfUserId(event.GetInt("userid")), broke event.GetInt("entindex");
    if(!
l4d_mtgb_enable.BoolValue || !IsValidClient(breaker) || (broke || !IsValidEntity(broke) || !IsValidEdict(broke)))
        return;
    
GetEntPropString(brokeProp_Data"m_ModelName"sBrokeModelsizeof(sBrokeModel));
    if(
l4d_mtgb_enable.BoolValue && StrEqual(sBrokeModel"models/props_junk/gascan001a.mdl"false))
        
PrintToChatAll("\x04%N\x01 broke a \x05gascan\x01!"breaker);
}

void GameCheck()
{
    
GetGameFolderName(GameNamesizeof(GameName));
    if(
StrEqual(GameName"left4dead2"false))
        
L4D2Version true;
    else
        
L4D2Version false;
}

bool IsValidClient(int client)
{
    return (
client && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && GetClientTeam(client) == && IsPlayerAlive(client) && !IsFakeClient(client));

- Attached the .sp file.
Attached Files
File Type: sp Get Plugin or Get Source (l4d_mtgb.sp - 541 views - 2.6 KB)
__________________

Last edited by Psyk0tik; 12-15-2017 at 05:10.
Psyk0tik is offline
eziosid
Senior Member
Join Date: Sep 2017
Old 12-15-2017 , 05:49   Re: Molotov Thrower announce
Reply With Quote #10

[QUOTE=cravenge;2566303]For burning gascans:

hello sir this time got this error ..
Attached Images
File Type: jpg error.jpg (47.1 KB, 300 views)
eziosid 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 00:04.


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