View Single Post
XHUNTERX
Senior Member
Join Date: Aug 2019
Location: World
Old 05-15-2020 , 11:40   Re: deathmatch (5 minutes =ak, 10 minutes = awp, 15 minutes = usp)
Reply With Quote #10

can you help me
is everything right?

Code:
#include <sourcemod>
#include <sdkhooks>
#pragma semicolon 1
#pragma newdecls required

int g_iWeapon;

public void OnMapStart()
{
    g_iWeapon = 0;
    CreateTimer(300.0, TimerChangeWeapon, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);    
}

public void OnClientPutInServer(int client)
{
    if (IsValidClient(client))
    {
        SDKHook(client, SDKHook_WeaponCanUse, OnWeaponUse);
    }
}

public Action TimerChangeWeapon(Handle timer)
{
    g_iWeapon++;
}

public Action OnWeaponUse(int client, int weapon)
{
    if (IsValidClient(client))
    {
        char sWeapon[32];
        GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));
        switch (g_iWeapon)
        {
            case 1: // USP-S
            {
                if (StrContains(sWeapon, "usp_silencer", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 2: // DEAGLE
            {
                if (StrContains(sWeapon, "deagle", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 3: // AK47
            {
                if (StrContains(sWeapon, "ak47", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 4: // M4A1
            {
                if (StrContains(sWeapon, "m4a1", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 5: // SSG
            {
                if (StrContains(sWeapon, "ssg08", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
            case 6: // AWP
            {
                if (StrContains(sWeapon, "awp", false) != -1)
                {
                    return Plugin_Handled;
                }
            }
        }
    }
    return Plugin_Continue;
}

stock bool IsValidClient(int client)
{
    return (client > 0 && client <= MaxClients && IsClientInGame(client) && !IsClientInKickQueue(client) && IsPlayerAlive(client) && !IsFakeClient(client));
}

Last edited by XHUNTERX; 05-15-2020 at 11:41.
XHUNTERX is offline