Knife Round- Auto Buy Problem

Сообщения
213
Реакции
71
Помог
2 раз(а)
Thanks to BlackSignature, Yesterday, he helped me alot to make many fixes to plugin, right now just there is one issue, players can buy weapons by F1 and F2 and use them, hence I was thinking instead of stripping weapons from players, they could not change the weapons primary, secondary, nades and only able to use carry knife, it will also retain there weapon that they had before knife round & F1 & F2 can also be avoided to prevent switching?

instead of stripping away weapons what if they can't change weapons (Just have knife in hand).

Код:
            // take away players weapon

            strip_user_weapons(players[num])
Код:
/*


Knife Round
===========

Description
After every X rounds , an special knife round will occur.
For plugin to work properly add knife_round_delay "10" (what ever number of rounds you want) or use cvar atleast once in server.

*/
#include <amxmodx>
#include <fun>
#include <engine>

// Red , Green , Blue
new const HUD_COLOR[3] = {0 , 255 , 0}

// Hud X position
const Float: HUD_POSITION_X = -1.0
// Hud Y position
const Float: HUD_POSITION_Y = 0.25

// Hud display time
const Float:HOLD_TIME = 10.0
const HUD_CHANNEL = -1

// buy menu commands
new const g_szBuyCmds[ ][ ] = {
    "usp", "glock", "deagle", "p228", "elites", "fn57", "m3", "xm1014", "mp5", "tmp", "p90", "mac10", "ump45", "ak47",
    "galil", "famas", "sg552", "m4a1", "aug", "scout", "awp", "g3sg1", "sg550", "m249", "vest", "vesthelm", "flash", "hegren",
    "sgren", "defuser", "nvgs", "shield", "primammo", "secammo", "km45", "9x19mm", "nighthawk", "228compact", "12gauge",
    "autoshotgun", "smg", "mp", "c90", "cv47", "defender", "clarion", "krieg552", "bullpup", "magnum", "d3au1", "krieg550",
    "buyammo1", "buyammo2"
}

new const VERSION[] = "1.0"

// players class (needed when we want to block weapon pick up)
new const PLAYER_CLASS[] = "player"

// variable to increase value
new g_knife_round

// is knife round ?
new bool: g_is_knife_round

// cvar
new cvar_knife_round

public plugin_init()
{
    register_plugin("Knife Round" , VERSION , "LearninG")
    // looping through buy commands
    for (new i; i<sizeof g_szBuyCmds; i++)
    {
        register_clcmd(g_szBuyCmds[i] , "block_buy")
    }
    // called when user touch weapons , shield ...
    register_touch("armoury_entity", PLAYER_CLASS, "PlayerTouchArmoury")
    register_touch("weaponbox", PLAYER_CLASS, "PlayerTouchWeaponBox")
    register_touch("weapon_shield", PLAYER_CLASS, "PlayerTouchShield")

    // event_new_round
    register_logevent("event_new_round",2,"0=World triggered","1=Round_Start")
    register_event("TextMsg", "event_restart_game", "a", "2=#Game_Commencing", "2=#Game_will_restart_in")
    register_event( "30" , "event_intermission" , "a" )
    register_cvar("knife_round_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY)

    // store cvar in variable
    cvar_knife_round = register_cvar("knife_round_delay" , "10")
}

// called when new round begins
public event_new_round()
{
    g_is_knife_round = false
    // increase variable value by 1
    g_knife_round++
    // variable value reached our cvar number ?
    if (g_knife_round >= get_pcvar_num(cvar_knife_round))
    {
        // Start round
        g_is_knife_round = true
        g_knife_round = 0
        // looping through all connected players
        new players[32], num
        get_players(players, num, "a")

        for( --num; num >= 0; num-- )
        {
            // take away players weapon
            strip_user_weapons(players[num])
            // give them a knife
            give_item(players[num] , "weapon_knife")
            // set our hud message and show it to them.
            set_hudmessage(HUD_COLOR[0] , HUD_COLOR[1] , HUD_COLOR[2] , HUD_POSITION_X , HUD_POSITION_Y , 0, 8.0, HOLD_TIME, 0.3, 0.3, HUD_CHANNEL)
            show_hudmessage(players[num] , "[PSL] Special Round- Knife Only Round !!!")
        }
    }
}

public event_restart_game() {
    g_knife_round = 0
}

public block_buy()
{
    // is knife round ?
    if (g_is_knife_round)
    {
        // block buy commands
        return PLUGIN_HANDLED
    }
    // allow buy commands
    return PLUGIN_CONTINUE
}

public PlayerTouchArmoury(ent, id)
{
    if (g_is_knife_round)
    {
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}

public PlayerTouchWeaponBox(ent, id)
{
    // player has touched a weapon , when round is knife_round
    if (g_is_knife_round)
    {
        // block weapon pickup
        return PLUGIN_HANDLED
    }
    // allow pick up
    return PLUGIN_CONTINUE
}

// player has touched shield.
public PlayerTouchShield(ent, id)
{
    if (g_is_knife_round)
    {
        return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}

public event_intermission()
{
    g_is_knife_round = false
    g_knife_round = 0
}
 

Ayk

Сообщения
763
Реакции
476
Помог
19 раз(а)
An old method to force only knife for the players:
Код:
register_event ( "CurWeapon", "CurrentWeapon", "be", "1=1" );

public CurrentWeapon ( id ) {
    if ( g_bForceKnife == true )
        engclient_cmd ( id, "weapon_knife" );
}
 
Сообщения
213
Реакции
71
Помог
2 раз(а)

Ayk

Сообщения
763
Реакции
476
Помог
19 раз(а)
rg_switch_weapon() was made to work exclusively with the weapons.
engclient_cmd() will fake the execution of any commands.

Inside "CurWeapon" event we don't have the weapon index, so engclient_cmd() looks better.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу