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

Solved help with plugin


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
jugule
AlliedModders Donor
Join Date: Apr 2020
Old 05-02-2020 , 14:24   help with plugin
#1

PHP Code:
#include <basecomm>
#include <cstrike>
#include <clientprefs>
#include <geoip>
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <sdktools_functions> 
#include <smlib>
#include <sourcemod>
#include <sdktools_sound>
#include <console>
#include <string>
 
// Compiler Options
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_NAME           "test" 
#define PLUGIN_AUTHOR         "test" 
#define PLUGIN_DESCRIPTION    "test"
#define PLUGIN_VERSION        "1.0" 
#define PLUGIN_URL            "test" 


bool 
    DuelEnabled 
false,
    
DuelDeagle false,
    
DuelHe false,
    
DuelDecoy false,
    
DuelRevolver false,
    
DuelPumni false,
    
PlayerDuelGuard[MAXPLAYERS+1] = false,
    
PlayerDuelPrisonier[MAXPLAYERS+1] = false;
    
char 
    DuelDeagleBlock
[][] = 
    {
        
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
        
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
        
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
        
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
        
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_hegrenade","weapon_incgrenade","weapon_molotov",
        
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
    
},
    
DuelRevolverBlock[][] = 
    {
        
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
        
"weapon_tec9","weapon_cz75a","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
        
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
        
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
        
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_hegrenade","weapon_incgrenade","weapon_molotov",
        
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
    
},
    
DuelHeBlock[][] = 
    {
        
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
        
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
        
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
        
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
        
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_decoy","weapon_deagle","weapon_incgrenade","weapon_molotov",
        
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
    
},
    
DuelDecoyBlock[][] = 
    {
        
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
        
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
        
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
        
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
        
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_hegrenade","weapon_deagle","weapon_incgrenade","weapon_molotov",
        
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_melee"
    
},
    
DuelPumniBlock[][] = 
    {
        
"weapon_usp_silencer","weapon_elite","weapon_fiveseven","weapon_glock","weapon_hkp2000","weapon_p250",
        
"weapon_tec9","weapon_cz75a","weapon_revolver","weapon_bizon","weapon_mac10","weapon_mp7","weapon_mp9","weapon_p90",
        
"weapon_ump45","weapon_mp5sd","weapon_m249","weapon_mag7","weapon_negev","weapon_nova","weapon_sawedoff","weapon_xm1014",
        
"weapon_m4a1","weapon_m4a1_silencer","weapon_ak47","weapon_aug","weapon_awp","weapon_famas","weapon_gs3sg1","weapon_galilar",
        
"weapon_scar20","weapon_sg556","weapon_ssg08","weapon_flashbang","weapon_hegrenade","weapon_deagle","weapon_incgrenade","weapon_molotov",
        
"weapon_smokegrenade","weapon_taser","weapon_breachcharge","weapon_knife","weapon_knife_stiletto","weapon_decoy","weapon_melee"
    
};
    
Handle 
    attack_timer 
INVALID_HANDLE,
    
trie_armas;
    
public 
Plugin myinfo =
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
description PLUGIN_DESCRIPTION,
    
version PLUGIN_VERSION,
    
url PLUGIN_URL
};

// Stocks
stock bool IsValidClient(int client)
{
    if(
client <= 0) return false;
    if(
client MaxClients) return false;
    if(!
IsClientConnected(client)) return false;
    if(
IsFakeClient(client)) return false;
    if(
IsClientSourceTV(client)) return false;
    return 
IsClientInGame(client);
}

stock void ClearTimer(Handle &timer)
{
    if(
timer != INVALID_HANDLE)
    {
        
KillTimer(timer);
    }
    
timer INVALID_HANDLE;
}
    
public 
void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("weapon_fire"ClientWeaponReload);
    
HookEvent("round_start"Event_RoundStart);
    
//HookEvent("player_spawn", Event_PlayerSpawn);
    
RegConsoleCmd("sm_lr"Command_Duel);
    
RegConsoleCmd("sm_duel"Command_Duel);
    
DuelEnabled false;
    
DuelDeagle false;
    
DuelRevolver false;
    
DuelHe false;
    
DuelDecoy false;
    
DuelPumni false;
    
    
trie_armas CreateTrie();

}

public 
void OnMapStart()
{
    
AddFileToDownloadsTable("sound/music/lrnew.mp3");
    
PrecacheSound("music/lrnew.mp3"true);
    
}

public 
Action Event_PlayerDeath(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(GetEventInt(event"userid")), attacker GetClientOfUserId(GetEventInt(event"attacker"));
    
char cname[32], aname[32];
    
GetClientName(clientcname32);
    
GetClientName(attackeraname32);

    
int weapon
    if (!
attacker)
    {
        return;
    }
    if (
attacker == client)
    {
        return;
    }
    
int Prisoners;
    for(
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            if (
GetClientTeam(i) == CS_TEAM_T)
            {
                
Prisoners++;
            }
        }
    }
    if(
DuelEnabled)
    {
        if(
GetClientTeam(attacker) == && GetClientTeam(client) == && attacker != client)
        {
            
DuelEnabled false;
            
DuelDeagle false;
            
DuelRevolver false;
            
DuelHe false;
            
DuelDecoy false;
            
DuelPumni false;
            
PlayerDuelGuard[client] = false;
            
PlayerDuelPrisonier[client] = false;
            
FakeClientCommand(attacker"sm_lr");
        }
    }
    else 
    {
        if(
Prisoners == 1)
        {
            for(
int idx 1idx <= MaxClientsidx++)
            {
                if (
IsValidClient (idx) && IsPlayerAlive(idx) && GetClientTeam(idx) == CS_TEAM_T )
                {
                    
FakeClientCommand(idx"sm_lr");
                }
            }
        }
        
DuelEnabled false;
        
DuelDeagle false;
        
DuelRevolver false;
        
DuelHe false;
        
DuelDecoy false;
        
DuelPumni false;
        
PlayerDuelGuard[client] = false;
        
PlayerDuelPrisonier[client] = false;
    }
    if(
GetClientTeam(client) == 2)
    {
            
weapon GivePlayerItem(client"weapon_fists"); 
            
EquipPlayerWeapon(clientweapon);
        }
        else if(
GetClientTeam(client) == 3)
        {
            
weapon GivePlayerItem(client"weapon_fists"); 
            
EquipPlayerWeapon(clientweapon);
        }
}
public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast
{
        
DuelEnabled false;
        
DuelDeagle false;
        
DuelRevolver false;
        
DuelHe false;
        
DuelDecoy false;
        
DuelPumni false;
        
        for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
int weapon;
                    
RemoveAllWeapons(x);
                    
weapon GivePlayerItem(x"weapon_fists"); 
                   
EquipPlayerWeapon(xweapon);
                }
            }    
}

public 
Action Command_Duel(int clientint args)
{
    if(!
IsPlayerAlive(client) && GetClientTeam(client) == 2)
    {
        
PrintToChat(client" \x0F[BOT]JBGO\x01: Trebuie să fii în viată pentru a face duel.");
        return 
Plugin_Handled;
    }
    if(!
DuelEnabled)
    {
        
int availabletargetsG 0;
            
        for (
int i 1<= MaxClientsi++)
        {
            if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))        
            {
                ++
availabletargetsG;
            }
        }
        if(
availabletargetsG 0// Verificare gardieni
        
{
            
int availabletargets 0;
                
            for (
int i 1<= MaxClientsi++)
            {
                if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))        
                {
                    ++
availabletargets;
                }
            }

            if(
availabletargets 1
            {
                
PrintToChat(client" \x0F[BOT]JBGO\x01: Nu ești ultimul deținut să poți face duel.");
                return 
Plugin_Handled;
            }
            else
            {
                if(
IsPlayerAlive(client) && GetClientTeam(client) == 2)
                {
                    
Menu meniu_duel = new Menu(DuelMenuHandler);
                    
meniu_duel.SetTitle("----------------\nUltima Dorință\n----------------");
                    
meniu_duel.AddItem("""Duel Cuțite");
                    
meniu_duel.AddItem("""Duel Mâini Goale");
                    
meniu_duel.AddItem("""Duel Pistoale");
                    
meniu_duel.AddItem("""Duel Grenade");
                    
meniu_duel.ExitButton false;
                    
meniu_duel.Display(clientMENU_TIME_FOREVER);
                }
                else
                {
                    
PrintToChat(client" \x0F[BOT]JBGO\x01: Doar deținuții pot să foloască comanda \x06/lr\x01.");
                }
            }
        }
        else if(
GetClientTeam(client) == 3)
        {
            
PrintToChat(client" \x0F[BOT]JBGO\x01: Doar deținuții pot să foloască comanda \x06/lr\x01.");
        }
        else
        {
            
PrintToChat(client" \x0F[BOT]JBGO\x01: Trebuie să fie cel puțin un Gardian în viată pentru a începe un duel.");
        }
    }
    else
    {
        
PrintToChat(client" \x0F[BOT]JBGO\x01: Ești deja în duel.");
    }
    return 
Plugin_Handled;
}

public 
int DuelMenuHandler(Menu menuMenuAction actionint clientint param)
{
    
int availabletargets 0;
                    
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))        
        {
            ++
availabletargets;
            }
    }
    if(
IsValidClient(client) && !IsPlayerAlive(client) && GetClientTeam(client) == 2)
    {
        
delete menu;
        
PrintToChat(client" \x0F[BOT]JBGO\x01: Trebuie să fii în viată pentru a face duel.");
    }
    else if(
availabletargets 1
    {
        
delete menu;
        
PrintToChat(client" \x0F[BOT]JBGO\x01: Nu ești ultimul deținut să poți face duel.");
    }
    else if(
action == MenuAction_Select)
    {
        
char select[1024];
        
GetMenuItem(menuparamselectsizeof(select));
        switch (
param)
        {
            case 
0:
            {
                
char target[50];
                
Menu meniu_cutit = new Menu(CutitMenuHandler);
                
meniu_cutit.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_cutit.AddItem(targettarget);
                    }
                }
                
meniu_cutit.Display(clientMENU_TIME_FOREVER);
            }
            case 
1:
            {
                
char target[50];
                
Menu meniu_pumni = new Menu(PumniMenuHandler);
                
meniu_pumni.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_pumni.AddItem(targettarget);
                    }
                }
                
meniu_pumni.Display(clientMENU_TIME_FOREVER);
            }
            case 
2:
            {
                
DuelPistoale(client);
            }
            case 
3:
            {
                
DuelGrenade(client);
            }
        }
    }
}

public 
int CutitMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
RemoveAllWeapons(client);
                
int weapon GivePlayerItem(client"weapon_knife_stiletto");
                
EquipPlayerWeapon(clientweapon);
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client100);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
RemoveAllWeapons(target);
                
int weapon GivePlayerItem(target"weapon_knife_stiletto"); 
                
EquipPlayerWeapon(targetweapon);
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target100);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}

public 
int PumniMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
DuelPumni true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
RemoveAllWeapons(client);
                
int weapon GivePlayerItem(client"weapon_fists");
                
EquipPlayerWeapon(clientweapon);
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client100);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
RemoveAllWeapons(target);
                
int weapon GivePlayerItem(target"weapon_fists"); 
                
EquipPlayerWeapon(targetweapon);
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target100);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}

stock bool DuelGrenade(int client)
{
    if (
IsPlayerAlive(client) && GetClientTeam(client) == 2)
    {
        
Menu meniu_duelgrenade = new Menu(DuelGrenadeMenuHandler);
        
meniu_duelgrenade.SetTitle("----------------\nDuel Grenade\n----------------");    
        
meniu_duelgrenade.AddItem("""Duel cu HE");
        
meniu_duelgrenade.AddItem("""Duel cu Decoy");
        
meniu_duelgrenade.ExitBackButton true;
        
meniu_duelgrenade.Display(clientMENU_TIME_FOREVER);
        return 
true;
    }
    return 
false;
}

public 
int DuelGrenadeMenuHandler(Menu menuMenuAction actionint clientint param)
{
    if (
action == MenuAction_Cancel && param == MenuCancel_ExitBack)
    {
        
FakeClientCommand(client"sm_lr");
    }
    else if(
action == MenuAction_Select)
    {

        
char select[1024];
        
GetMenuItem(menuparamselectsizeof(select));
        switch (
param)                 
        {
            case 
0:
            {
                
char target[50];
                
Menu meniu_he = new Menu(HeMenuHandler);
                
meniu_he.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_he.AddItem(targettarget);
                    }
                }
                
meniu_he.Display(clientMENU_TIME_FOREVER);
            }
            case 
1:
            {
                
char target[50];
                
Menu meniu_decoy = new Menu(DecoyMenuHandler);
                
meniu_decoy.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_decoy.AddItem(targettarget);
                    }
                }
                
meniu_decoy.Display(clientMENU_TIME_FOREVER);
            }
        }
    }
}

public 
int DecoyMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
DuelDecoy true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
RemoveAllWeapons(client);
                
GivePlayerItem(client"weapon_decoy");
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client1);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
RemoveAllWeapons(target);
                
GivePlayerItem(target"weapon_decoy");    
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target1);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}

public 
int HeMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
DuelHe true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
RemoveAllWeapons(client);
                
GivePlayerItem(client"weapon_hegrenade");
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client100);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
RemoveAllWeapons(target);
                
GivePlayerItem(target"weapon_hegrenade");    
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target100);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}

public 
void OnEntityCreated(int iEntity, const char[] szClassname)
{
    if(
DuelEnabled)
    {
        if(
DuelHe)
        {
            if (!
StrEqual(szClassname"hegrenade_projectile"))
                return;
            
SDKHook(iEntitySDKHook_SpawnOnEntitySpawned);
        }
        else if(
DuelDecoy)
        {
            if (!
StrEqual(szClassname"decoy_projectile"))
                return;
            
SDKHook(iEntitySDKHook_SpawnOnEntitySpawned);
        }
        
    }
}

public 
int OnEntitySpawned(int iEntity)
{
    
int iClient GetEntPropEnt(iEntityProp_Send"m_hOwnerEntity");
    
    if (
iClient == -|| !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
        return;
        
    if(
DuelHe)
    {
        
CreateTimer(1.4Timer_GiveHeGetClientUserId(iClient), TIMER_FLAG_NO_MAPCHANGE);
    }
    else if(
DuelDecoy)
    {
        
CreateTimer(0.0Timer_RemoveThinkTickEntIndexToEntRef(iEntity), TIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action Timer_RemoveThinkTick(Handle hTimerint iRef)
{
    
int iEntity EntRefToEntIndex(iRef);
    
    if (
iEntity == INVALID_ENT_REFERENCE || !IsValidEntity(iEntity))
        return;
        
    
SetEntProp(iEntityProp_Data"m_nNextThinkTick", -1);
    
    
CreateTimer(1.4Timer_RemoveDecoyEntIndexToEntRef(iEntity), TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action Timer_RemoveDecoy(Handle hTimerint iRef)
{
    
int iEntity EntRefToEntIndex(iRef);
    if (
iEntity == INVALID_ENT_REFERENCE || !IsValidEntity(iEntity))
        return;
        
    
int iClient GetEntPropEnt(iEntityProp_Data"m_hOwnerEntity");
    
    
AcceptEntityInput(iEntity"Kill");
        
    if (
iClient == -|| !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
        return;
        
    
GivePlayerItem(iClient"weapon_decoy");
}

public 
Action Timer_GiveHe(Handle hTimerint iUserid)
{
    
int iClient GetClientOfUserId(iUserid);
        
    if (
iClient == -|| !IsClientInGame(iClient) || !IsPlayerAlive(iClient))
        return;
        
    
GivePlayerItem(iClient"weapon_hegrenade");
}

stock bool DuelPistoale(int client)
{
    if (
IsPlayerAlive(client) && GetClientTeam(client) == 2)
    {
        
Menu meniu_duelpistoale = new Menu(DuelPistoaleMenuHandler);
        
meniu_duelpistoale.SetTitle("----------------\nDuel Pistoale\n----------------");    
        
meniu_duelpistoale.AddItem("""Duel Deagle");
        
meniu_duelpistoale.AddItem("""Duel Revolver");
        
meniu_duelpistoale.ExitBackButton true;
        
meniu_duelpistoale.Display(clientMENU_TIME_FOREVER);
        return 
true;
    }
    return 
false;
}

public 
int DuelPistoaleMenuHandler(Menu menuMenuAction actionint clientint param)
{
    if (
action == MenuAction_Cancel && param == MenuCancel_ExitBack)
    {
        
FakeClientCommand(client"sm_lr");
    }
    else if(
action == MenuAction_Select)
    {

        
char select[1024];
        
GetMenuItem(menuparamselectsizeof(select));
        switch (
param)                 
        {
            case 
0:
            {
                
char target[50];
                
Menu meniu_deagle = new Menu(DeagleMenuHandler);
                
meniu_deagle.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_deagle.AddItem(targettarget);
                    }
                }
                
meniu_deagle.Display(clientMENU_TIME_FOREVER);
            }
            case 
1:
            {
                
char target[50];
                
Menu meniu_revolver = new Menu(RevolverMenuHandler);
                
meniu_revolver.SetTitle("----------------\nAlege Oponentul\n----------------");
                for (
int i 1<= MaxClientsi++)
                {
                    if(
IsValidClient(i) && GetClientTeam(i) == && IsPlayerAlive(i) )        
                    {
                        
GetClientName(itargetsizeof(target));
                        
meniu_revolver.AddItem(targettarget);
                    }
                }
                
meniu_revolver.Display(clientMENU_TIME_FOREVER);    
            }
        }
    }
}

public 
int DeagleMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
DuelDeagle true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
char weaponclassname[MAX_WEAPON_STRING];
                
RemoveAllWeapons(client);
                
int iWeapon GivePlayerItem(client"weapon_deagle");
                
SetEntProp(iWeaponProp_Send"m_iClip1"1);
                
Client_GetActiveWeaponName(clientweaponclassnameMAX_WEAPON_STRING);
            
SetEntProp(iWeaponProp_Send"m_iPrimaryReserveAmmoCount"0);
                
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
                
Client_SetWeaponPlayerAmmo(clientweaponclassname0);    
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client100);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
char weaponclassname[MAX_WEAPON_STRING];
                
RemoveAllWeapons(target);
                
int iWeapon GivePlayerItem(target"weapon_deagle");
                
SetEntProp(iWeaponProp_Send"m_iClip1"1);
                
Client_GetActiveWeaponName(targetweaponclassnameMAX_WEAPON_STRING);
                
SetEntProp(iWeaponProp_Send"m_iPrimaryReserveAmmoCount"0);
                
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
                
Client_SetWeaponPlayerAmmo(targetweaponclassname0);    
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target100);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}

public 
int RevolverMenuHandler(Menu menuMenuAction actionint clientint param2)
{
    if(
action == MenuAction_Select)
    {
        
DuelEnabled true;
        
DuelRevolver true;
        
char arg1[50];
        
GetMenuItem(menuparam2arg1sizeof(arg1));
        
int target FindTarget(clientarg1truefalse);
        if (
target != -1
        {
            for(
int x 1<= MaxClientsx++)
            {
                if(
IsClientInGame(x))
                {
                    
ClientCommandx"play \"music/lrnew.mp3\"" );
                }
            }    
            if(
GetClientTeam(client) == 2)
            {
                
char weaponclassname[MAX_WEAPON_STRING];
                
RemoveAllWeapons(client);
                
int iWeapon GivePlayerItem(client"weapon_revolver");
                
SetEntProp(iWeaponProp_Send"m_iClip1"1);
                
Client_GetActiveWeaponName(clientweaponclassnameMAX_WEAPON_STRING);
                
SetEntProp(iWeaponProp_Send"m_iPrimaryReserveAmmoCount"0);
                
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
                
Client_SetWeaponPlayerAmmo(clientweaponclassname0);    
                
                
SetEntityRenderMode(clientRENDER_TRANSCOLOR);
                
SetEntityRenderColor(client25500255);
                
SetEntityHealth(client100);
                
SetEntProp(clientProp_Send"m_ArmorValue"0);
                
SetEntProp(clientProp_Send"m_bHasHelmet"0);
                
PlayerDuelPrisonier[client] = true;
            }
            if(
GetClientTeam(target) == 3)
            {
                
char weaponclassname[MAX_WEAPON_STRING];
                
RemoveAllWeapons(target);
                
int iWeapon GivePlayerItem(target"weapon_revolver");
                
SetEntProp(iWeaponProp_Send"m_iClip1"1);
                
Client_GetActiveWeaponName(targetweaponclassnameMAX_WEAPON_STRING);
                
SetEntProp(iWeaponProp_Send"m_iPrimaryReserveAmmoCount"0);
                
//SetEntProp(iWeapon, Prop_Send, "m_iClip1", 0);
                
Client_SetWeaponPlayerAmmo(targetweaponclassname0);    
                
SetEntityRenderMode(targetRENDER_TRANSCOLOR);
                
SetEntityRenderColor(target00255255);
                
SetEntityHealth(target100);
                
SetEntProp(targetProp_Send"m_ArmorValue"0);
                
SetEntProp(targetProp_Send"m_bHasHelmet"0);
                
PlayerDuelGuard[target] = true;
            }
        }
    }
}


public 
void RemoveAllWeapons(int client)
{
    if(
IsValidClient(client))
    {
        
int weapon;
        for(
int i 05i++) 
        { 
            while((
weapon GetPlayerWeaponSlot(clienti)) != -1
            {
                
RemovePlayerItem(clientweapon);
                
AcceptEntityInput(weapon"Kill"); 
            } 
        }
    }
}

public 
Action ClientWeaponReload(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event,  "userid"));
    
Darm(client);
}

public 
void Darm(int client)
{
    if(
IsPlayerAlive(client) && DuelEnabled)
    {
        
int weapon GetEntPropEnt(clientProp_Data"m_hActiveWeapon");
        if(
weapon && (weapon == GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY) || weapon == GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY)))
        {
            
int warray;
            
char classname[4];
            
//GetEdictClassname(weapon, classname, sizeof(classname));
            
Format(classname4"%i"GetEntProp(weaponProp_Send"m_iItemDefinitionIndex"));
            if(
GetTrieValue(trie_armasclassnamewarray))
            {
                if(
GetReserveAmmo(weapon) != warraySetEntProp(weaponProp_Send"m_iPrimaryReserveAmmoCount"1);
            }
        }
    }
}

public 
Action CS_OnCSWeaponDrop(int clientint weapon)
{
    
char weapon_name[30];
    
GetEntityClassname(weaponweapon_namesizeof(weapon_name));
    if(
DuelEnabled)
    {
        
PrintToChat(client" \x0F[BOT]JBGO\x01: Nu poți arunca armele în timpul unui duel.");
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;
}

stock int GetReserveAmmo(int weapon)
{
    return 
GetEntProp(weaponProp_Send"m_iPrimaryReserveAmmoCount");
}

public 
Action EventItemPickup2(int clientint weapon)
{
    if(
weapon == GetPlayerWeaponSlot(clientCS_SLOT_PRIMARY) || weapon == GetPlayerWeaponSlot(clientCS_SLOT_SECONDARY) && DuelEnabled)
    {
        
int warray;
        
char classname[4];
        
//GetEdictClassname(weapon, classname, sizeof(classname));
        
Format(classname4"%i"GetEntProp(weaponProp_Send"m_iItemDefinitionIndex"));
        
        if(!
GetTrieValue(trie_armasclassnamewarray))
        {
            
warray GetEntProp(weaponProp_Send"m_iPrimaryReserveAmmoCount");
            
            
SetTrieValue(trie_armasclassnamewarray);
        }
    }
}

public 
void OnClientPutInServer(int client
{
    if(!
IsValidClient(client)) 
    {
        return;
    }

    
SDKHook(clientSDKHook_OnTakeDamageHook_OnTakeDamage);
    
SDKHook(clientSDKHook_WeaponCanUseHook_WeaponCanUse);
    
SDKHook(clientSDKHook_PostThinkPostOnPostThinkPost);
    
SDKHook(clientSDKHook_WeaponEquipPostEventItemPickup2);
}

public 
Action Hook_OnTakeDamage(int clientint &attackerint &inflictorfloat &damageint &damagetype)
{
    if(!
DuelEnabled)
    {
        if(
IsValidClient(attacker) && GetClientTeam(attacker) == && GetClientTeam(client) == && attacker != client)
        {
            if(
attack_timer == INVALID_HANDLE)
            {
                
//for(int x = 1; x <= MaxClients; x++)
                //{
                    //if(IsValidClient(x))
                    //{
                        //ClientCommand( x, "play \"*xsag/jbgo/revolt_xsag.mp3\"" );
                    //}
                //}    
                
SetEntityRenderColor(attacker25500255);
                
PrintCenterTextAll("%N a devenit agresiv"attacker);
                
attack_timer CreateTimer(10.0AttackTimerEnd);
            }
        }
    }
    else if(
DuelEnabled)
    {
        if(
IsValidClient(attacker) && GetClientTeam(attacker) == && GetClientTeam(client) == && !PlayerDuelGuard[attacker] && !PlayerDuelPrisonier[client] && attacker != client)
        {
            
damage 0.0;
            return 
Plugin_Changed;
        }
        else if(
IsValidClient(attacker) && GetClientTeam(attacker) == && GetClientTeam(client) == && !PlayerDuelGuard[client] && !PlayerDuelPrisonier[attacker] && attacker != client)
        {
            
damage 0.0;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageHook_OnTakeDamage);
}

public 
Action Hook_WeaponCanUse(int clientint weapon)
{
    
char classname[64];
    
GetEntityClassname(weaponclassnamesizeof classname);
    if(
DuelDeagle)
    {
        for(
int i 044i++)
        {
            if(
StrEqual(classnameDuelDeagleBlock[i]))
            {
                return 
Plugin_Handled;
            }
        }
    }
    if(
DuelRevolver)
    {
        for(
int i 043i++)
        {
            if(
StrEqual(classnameDuelRevolverBlock[i]))
            {
                return 
Plugin_Handled;
            }
        }
    }
    if(
DuelHe)
    {
        for(
int i 044i++)
        {
            if(
StrEqual(classnameDuelHeBlock[i]))
            {
                return 
Plugin_Handled;
            }
        }    
    }
    if(
DuelDecoy)
    {
        for(
int i 0<44i++)
        {
            if(
StrEqual(classnameDuelDecoyBlock[i]))
            {
                return 
Plugin_Handled;
            }
        }
    }
    if(
DuelPumni)
    {
        for(
int i 045i++)
        {
            if(
StrEqual(classnameDuelPumniBlock[i]))
            {
                return 
Plugin_Handled;
            }
        }    
    }
    if(
StrEqual(classname"weapon_melee") && !(HasWeapon(client"weapon_melee") || HasWeapon(client"weapon_knife")))
    {
        
EquipPlayerWeapon(clientweapon);
    }
    return 
Plugin_Continue;
}
public 
void OnPostThinkPost(int client)
{
    
SetEntProp(clientProp_Send"m_iAddonBits"0);
}
public 
Action AttackTimerEnd(Handle timer)
{
    
ClearTimer(attack_timer);
}

stock bool HasWeapon(int client, const char[] classname)
{
    
int index;
    
int weapon;
    
char sName[64];

    while((
weapon GetNextWeapon(clientindex)) != -1)
    {
        
GetEdictClassname(weaponsNamesizeof(sName));
        if (
StrEqual(sNameclassname))
        {
            return 
true;
        }
    }
    return 
false;
}

stock int GetNextWeapon(int clientint &weaponIndex)
{
    static 
int weaponsOffset = -1;
    if (
weaponsOffset == -1)
    {
        
weaponsOffset FindDataMapInfo(client"m_hMyWeapons");
    }

    
int offset weaponsOffset + (weaponIndex 4);
    
int weapon;
    
    while (
weaponIndex 48
    {
        
weaponIndex++;
        
weapon GetEntDataEnt2(clientoffset);
        
        if (
IsValidEdict(weapon)) 
        {
            return 
weapon;
        }
        
offset += 4;
    }
    return -
1;

I have this plugin and it causes me to crash quite often, would you have any idea why?

Last edited by DarkDeviL; 05-03-2020 at 15:36. Reason: Restore to previous version. + Solved tag
jugule is offline
Closed Thread



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:51.


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