Команда раз за раунд csgo

vasil

Участник
Сообщения
115
Реакции
21
Всем привет. Один вопрос. Как реализовать функцию в плагине один раз за раунд.

На примере оружия.

Через плагин берется оружие !ak47 !awp ! m4a1 и тд....
Как реализовать чтоб игрок смог брать только одно в раунде...?
Спасибо

кусочек из плагина
PHP:
public Action:Command_Awp(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_awp");
            GivePlayerItem(client, "item_assaultsuit");

    }
    return Plugin_Handled;

}

public Action:Command_M4a1_silencer(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_m4a1_silencer");
            GivePlayerItem(client, "item_assaultsuit");

    }
    return Plugin_Handled;
}
 

akvorok.ego

Участник
Сообщения
314
Реакции
186
Всем привет. Один вопрос. Как реализовать функцию в плагине один раз за раунд.

На примере оружия.

Через плагин берется оружие !ak47 !awp ! m4a1 и тд....
Как реализовать чтоб игрок смог брать только одно в раунде...?
Спасибо

PHP:
new awp[MAXPLAYERS+1], m4a1[MAXPLAYERS+1];

public OnPluginStart()
{
	HookEvent("player_spawn", Event_PlayerSpawn);
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid")); 
	if (client && IsClientInGame(client)) awp[client] = 1, m4a1[client] = 1;
}

public Action:Command_Awp(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(awp[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_awp");
            GivePlayerItem(client, "item_assaultsuit");
		
			awp[client] = 0;
    }
    return Plugin_Handled;

}

public Action:Command_M4a1_silencer(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(m4a1[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_m4a1_silencer");
            GivePlayerItem(client, "item_assaultsuit");
			
			m4a1[client] = 0;
    }
    return Plugin_Handled;
}

Либо вместо:
PHP:
player_spawn
Поставь:
PHP:
round_start
 

DarklSide

Участник
Сообщения
931
Реакции
468
Последнее редактирование:

vasil

Участник
Сообщения
115
Реакции
21
PHP:
new awp[MAXPLAYERS+1], m4a1[MAXPLAYERS+1];

public OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid")); 
    if (client && IsClientInGame(client)) awp[client] = 1, m4a1[client] = 1;
}

public Action:Command_Awp(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(awp[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_awp");
            GivePlayerItem(client, "item_assaultsuit");
        
            awp[client] = 0;
    }
    return Plugin_Handled;

}

public Action:Command_M4a1_silencer(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(m4a1[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_m4a1_silencer");
            GivePlayerItem(client, "item_assaultsuit");
            
            m4a1[client] = 0;
    }
    return Plugin_Handled;
}
Оружие теперь не берется... ни какое
 

akvorok.ego

Участник
Сообщения
314
Реакции
186
PHP:
new awp[MAXPLAYERS+1], m4a1[MAXPLAYERS+1];

public OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid")); 
    if (client && IsClientInGame(client)) awp[client] = 1, m4a1[client] = 1;
}

public Action:Command_Awp(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(awp[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_awp");
            GivePlayerItem(client, "item_assaultsuit");
        
            awp[client] = 0;
    }
    return Plugin_Handled;

}

public Action:Command_M4a1_silencer(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else if(m4a1[client])
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_m4a1_silencer");
            GivePlayerItem(client, "item_assaultsuit");
            
            m4a1[client] = 0;
    }
    return Plugin_Handled;
}
Оружие теперь не берется... ни какое

Сделай:
PHP:
if (client && IsClientInGame(client)) awp[client] = 1; m4a1[client] = 1;
Выдать m4a1 сразу с одетым глушителем не возможно:
PHP:
GivePlayerItem(client, "weapon_m4a1_silencer");
 

vasil

Участник
Сообщения
115
Реакции
21
Сделай:
PHP:
if (client && IsClientInGame(client)) awp[client] = 1; m4a1[client] = 1;
Выдать m4a1 сразу с одетым глушителем не возможно:
PHP:
GivePlayerItem(client, "weapon_m4a1_silencer");

Почему не возможно все прекрасно выдается у меня...( до твоего кода)
с твоим что то не хочет ни какое оружие выдаваться
Не выдается оружие ни калаш ни авп не тем более мка
даже так
GivePlayerItem(client, "weapon_m4a1")
Просто смысл теперь такой что как будто команды не существует.....на выдачу оружия.
 

DarklSide

Участник
Сообщения
931
Реакции
468
vasil,
PHP:
new bool:awp[MAXPLAYERS + 1] =  { false, ... }, 
bool:m4a1[MAXPLAYERS + 1] =  { false, ... };
public OnPluginStart()
{
    HookEvent("round_start", Event_OnRoundStart);
}
public OnClientDisconnect(client)
{
    awp[client] = false;
    m4a1[client] = false;
}
public Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new x = 1; x <= MaxClients; ++x)
    {
        awp[x] = false;
        m4a1[x] = false;
    }
}
public Action:Command_Awp(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!awp[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
                GivePlayerItem(client, "weapon_awp");
                GivePlayerItem(client, "item_assaultsuit");
                awp[client] = true;
            }
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_M4a1_silencer(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!m4a1[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
                GivePlayerItem(client, "weapon_m4a1_silencer");
                GivePlayerItem(client, "item_assaultsuit");
                m4a1[client] = true;
            }
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide.. У меня тогда вопрос...команда
просто у меня так команда есть и доступ к ней с определеным флагом. через admin_overrides
RegConsoleCmd("sm_m4a1_silencer", Command_M4a1_silencer,"Gives player an m4a1_silencer.");
С этой командой if (!m4a1[client]) получается любой сможет брать? если да то как ее убрать или закрыть
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide. Есть проблема...Оружие не берется... нажимая на калаву....Но есть такая штука если я подбираю оружие какое нибудь то после этого если нажать на выдачу команда срабатывает на оружие..как и должна по идеи сразу .как то так

Вот код который работает хорошо.(немного сократил по оружию) В него надо добавить выдачу одного оружия за раунд ..кроме дигла.

PHP:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

#pragma semicolon 1

#define PLUGIN_VERSION "2.0"

new weaponIndex;

#define MAX_WEAPONS    25
    
public Plugin:myinfo =
{
    name = "Weapon Give By command",
    author = "SynysteR",
    description = "type in chat for example: !awp and you will get an awp, works for all weapons",
    version = PLUGIN_VERSION
}

new const String:weaponList[MAX_WEAPONS][]={
    "\x04[SM]\x03 The weapon commands are:", "sm_awp", "sm_m4a1_silencer", "sm_ak47", "sm_aug", "sm_famas", "sm_g3sg1", "sm_galil", "sm_m249", "sm_m3", "sm_xm1014", "sm_mac10", "sm_mp5", "sm_p90", "sm_scout", "sm_sg550", "sm_sg552", "sm_tmp", "sm_ump45", "sm_deagle", "sm_usp", "sm_elite", "sm_fiveseven", "sm_glock", "sm_p228" 
};

public OnPluginStart()
{
        RegConsoleCmd("sm_awp", Command_Awp,"Gives player an awp.");
    RegConsoleCmd("sm_m4a1_silencer", Command_M4a1_silencer,"Gives player an m4a1_silencer.");
    RegConsoleCmd("sm_ak47", Command_Ak47,"Gives player an ak47");
    RegConsoleCmd("sm_deagle", Command_Deagle,"Gives player a deagle.");


}

enum WeaponsSlot
{
    Slot_Invalid = -1, /** Invalid weapon (slot). */
    Slot_Primary = 0, /** Primary weapon slot. */
    Slot_Secondary = 1, /** Secondary weapon slot. */
    Slot_Melee = 2, /** Melee (knife) weapon slot. */
    Slot_Projectile = 3, /** Projectile (grenades, flashbangs, etc) weapon slot. */
    Slot_Explosive = 4, /** Explosive (c4) weapon slot. */
}

public Action:Command_Awp(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_awp");
    }
    return Plugin_Handled;
}
public Action:Command_M4a1_silencer(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_m4a1_silencer");
    }
    return Plugin_Handled;
}
public Action:Command_Ak47(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {    
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_ak47");
    }
    return Plugin_Handled;
}
public Action:Command_Deagle(client, args)
{
    if(!IsPlayerAlive(client))
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    else
    {        
        if ((weaponIndex = GetPlayerWeaponSlot(client, 1)) != -1)
            RemovePlayerItem(client, weaponIndex);
            
        GivePlayerItem(client, "weapon_deagle");
    }
    return Plugin_Handled;
}
public Action:Command_weaponList(client, args)
{
    new i;
    for(i = 0; i < MAX_WEAPONS; ++i)
        ReplyToCommand(client, "%s", weaponList[i]);
    return Plugin_Handled;
}
 
Последнее редактирование:

DarklSide

Участник
Сообщения
931
Реакции
468
PHP:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "2.0"
new weaponIndex;
#define MAX_WEAPONS    25
new bool:awp[MAXPLAYERS + 1] =  { false, ... }, 
bool:m4a1[MAXPLAYERS + 1] =  { false, ... }, 
bool:ak47[MAXPLAYERS + 1] =  { false, ... };
public Plugin:myinfo = 
{
    name = "Weapon Give By command", 
    author = "SynysteR", 
    description = "type in chat for example: !awp and you will get an awp, works for all weapons", 
    version = PLUGIN_VERSION
}
new const String:weaponList[MAX_WEAPONS][] =  {
    "\x04[SM]\x03 The weapon commands are:", "sm_awp", "sm_m4a1_silencer", "sm_ak47", "sm_aug", "sm_famas", "sm_g3sg1", "sm_galil", "sm_m249", "sm_m3", "sm_xm1014", "sm_mac10", "sm_mp5", "sm_p90", "sm_scout", "sm_sg550", "sm_sg552", "sm_tmp", "sm_ump45", "sm_deagle", "sm_usp", "sm_elite", "sm_fiveseven", "sm_glock", "sm_p228"
};
public OnPluginStart()
{
    RegConsoleCmd("sm_awp", Command_Awp, "Gives player an awp.");
    RegConsoleCmd("sm_m4a1_silencer", Command_M4a1_silencer, "Gives player an m4a1_silencer.");
    RegConsoleCmd("sm_ak47", Command_Ak47, "Gives player an ak47");
    RegConsoleCmd("sm_deagle", Command_Deagle, "Gives player a deagle.");
    HookEvent("round_start", Event_OnRoundStart);
    
}
enum WeaponsSlot
{
    Slot_Invalid = -1, /** Invalid weapon (slot). */
    Slot_Primary = 0, /** Primary weapon slot. */
    Slot_Secondary = 1, /** Secondary weapon slot. */
    Slot_Melee = 2, /** Melee (knife) weapon slot. */
    Slot_Projectile = 3, /** Projectile (grenades, flashbangs, etc) weapon slot. */
    Slot_Explosive = 4, /** Explosive (c4) weapon slot. */
}
public Action:Command_Awp(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!awp[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
                GivePlayerItem(client, "weapon_awp");
                awp[client] = true;
            }
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_M4a1_silencer(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!m4a1[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
                GivePlayerItem(client, "weapon_m4a1_silencer");
                m4a1[client] = true;
            }
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Ak47(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!ak47[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
                GivePlayerItem(client, "weapon_ak47");
                ak47[client] = true;
            }
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Deagle(client, args)
{
    if (IsPlayerAlive(client))
    {
        if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
        {
            RemovePlayerItem(client, weaponIndex);
            GivePlayerItem(client, "weapon_deagle");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_weaponList(client, args)
{
    new i;
    for (i = 0; i < MAX_WEAPONS; ++i)
    ReplyToCommand(client, "%s", weaponList[i]);
    return Plugin_Handled;
}
public OnClientDisconnect(client)
{
    awp[client] = false;
    m4a1[client] = false;
    ak47[client] = false;
}
public Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new x = 1; x <= MaxClients; ++x)
    {
        awp[x] = false;
        m4a1[x] = false;
        ak47[x] = false;
    }
}
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide.... Не знаю что происходит.... даже дигл не берется......компилируется без ошибок
что то у меня не работает...вернул пока свой код....поздно уже пойду спать
 
N

NiGaByte

Парни, а как ограничивать выдачу оружия на карту? Т.е можно взять всего один раз за мапу.
 

DarklSide

Участник
Сообщения
931
Реакции
468
NiGaByte,
PHP:
public Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
->
PHP:
public OnMapEnd()
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide.. Вроде все испробовал.что то никак..Единственно когда срабатывает команда .Это надо сначала подобрать оружие любое..и вот когда оно в руках тогда плагин срабатывает.
 

DarklSide

Участник
Сообщения
931
Реакции
468
vasil,
PHP:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "2.0"
new weaponIndex;
#define MAX_WEAPONS    25
new bool:awp[MAXPLAYERS + 1] =  { false, ... }, 
bool:m4a1[MAXPLAYERS + 1] =  { false, ... }, 
bool:ak47[MAXPLAYERS + 1] =  { false, ... };
public Plugin:myinfo = 
{
    name = "Weapon Give By command", 
    author = "SynysteR", 
    description = "type in chat for example: !awp and you will get an awp, works for all weapons", 
    version = PLUGIN_VERSION
}
new const String:weaponList[MAX_WEAPONS][] =  {
    "\x04[SM]\x03 The weapon commands are:", "sm_awp", "sm_m4a1_silencer", "sm_ak47", "sm_aug", "sm_famas", "sm_g3sg1", "sm_galil", "sm_m249", "sm_m3", "sm_xm1014", "sm_mac10", "sm_mp5", "sm_p90", "sm_scout", "sm_sg550", "sm_sg552", "sm_tmp", "sm_ump45", "sm_deagle", "sm_usp", "sm_elite", "sm_fiveseven", "sm_glock", "sm_p228"
};
public OnPluginStart()
{
    RegConsoleCmd("sm_awp", Command_Awp, "Gives player an awp.");
    RegConsoleCmd("sm_m4a1_silencer", Command_M4a1_silencer, "Gives player an m4a1_silencer.");
    RegConsoleCmd("sm_ak47", Command_Ak47, "Gives player an ak47");
    RegConsoleCmd("sm_deagle", Command_Deagle, "Gives player a deagle.");
    HookEvent("round_start", Event_OnRoundStart);
    
}
enum WeaponsSlot
{
    Slot_Invalid = -1, /** Invalid weapon (slot). */
    Slot_Primary = 0, /** Primary weapon slot. */
    Slot_Secondary = 1, /** Secondary weapon slot. */
    Slot_Melee = 2, /** Melee (knife) weapon slot. */
    Slot_Projectile = 3, /** Projectile (grenades, flashbangs, etc) weapon slot. */
    Slot_Explosive = 4, /** Explosive (c4) weapon slot. */
}
public Action:Command_Awp(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!awp[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_awp");
            awp[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_M4a1_silencer(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!m4a1[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_m4a1_silencer");
            m4a1[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Ak47(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!ak47[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_ak47");
            ak47[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже использовали это оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Deagle(client, args)
{
    if (IsPlayerAlive(client))
    {
        if ((weaponIndex = GetPlayerWeaponSlot(client, 1)) != -1)
        {
            RemovePlayerItem(client, weaponIndex);
        }
        GivePlayerItem(client, "weapon_deagle");
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_weaponList(client, args)
{
    new i;
    for (i = 0; i < MAX_WEAPONS; ++i)
    ReplyToCommand(client, "%s", weaponList[i]);
    return Plugin_Handled;
}
public OnClientDisconnect(client)
{
    awp[client] = false;
    m4a1[client] = false;
    ak47[client] = false;
}
public Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new x = 1; x <= MaxClients; ++x)
    {
        awp[x] = false;
        m4a1[x] = false;
        ak47[x] = false;
    }
}
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide...Работает...Но того эфекта не получилось которого хотел....ТОесть Оружие да берется одно за один раунд.НО взять можно по очереди все.
Например. взял калаш больше взять не могу его...Но могу взять эмк или авп как только все перебрал больше не берется....

Изначально хотел.Например если взял эмку или любое...то другое нельзя взять..
 

DarklSide

Участник
Сообщения
931
Реакции
468
vasil,
PHP:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma semicolon 1
#define PLUGIN_VERSION "2.0"
new weaponIndex;
#define MAX_WEAPONS    25
new bool:weapons[MAXPLAYERS + 1] =  { false, ... };
public Plugin:myinfo = 
{
    name = "Weapon Give By command", 
    author = "SynysteR", 
    description = "type in chat for example: !awp and you will get an awp, works for all weapons", 
    version = PLUGIN_VERSION
}
new const String:weaponList[MAX_WEAPONS][] =  {
    "\x04[SM]\x03 The weapon commands are:", "sm_awp", "sm_m4a1_silencer", "sm_ak47", "sm_aug", "sm_famas", "sm_g3sg1", "sm_galil", "sm_m249", "sm_m3", "sm_xm1014", "sm_mac10", "sm_mp5", "sm_p90", "sm_scout", "sm_sg550", "sm_sg552", "sm_tmp", "sm_ump45", "sm_deagle", "sm_usp", "sm_elite", "sm_fiveseven", "sm_glock", "sm_p228"
};
public OnPluginStart()
{
    RegConsoleCmd("sm_awp", Command_Awp, "Gives player an awp.");
    RegConsoleCmd("sm_m4a1_silencer", Command_M4a1_silencer, "Gives player an m4a1_silencer.");
    RegConsoleCmd("sm_ak47", Command_Ak47, "Gives player an ak47");
    RegConsoleCmd("sm_deagle", Command_Deagle, "Gives player a deagle.");
    HookEvent("round_start", Event_OnRoundStart);
    
}
enum WeaponsSlot
{
    Slot_Invalid = -1, /** Invalid weapon (slot). */
    Slot_Primary = 0, /** Primary weapon slot. */
    Slot_Secondary = 1, /** Secondary weapon slot. */
    Slot_Melee = 2, /** Melee (knife) weapon slot. */
    Slot_Projectile = 3, /** Projectile (grenades, flashbangs, etc) weapon slot. */
    Slot_Explosive = 4, /** Explosive (c4) weapon slot. */
}
public Action:Command_Awp(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!weapons[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_awp");
            weapons[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже выбрали оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_M4a1_silencer(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!weapons[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_m4a1_silencer");
            weapons[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже выбрали оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Ak47(client, args)
{
    if (IsPlayerAlive(client))
    {
        if (!weapons[client])
        {
            if ((weaponIndex = GetPlayerWeaponSlot(client, 0)) != -1)
            {
                RemovePlayerItem(client, weaponIndex);
            }
            GivePlayerItem(client, "weapon_ak47");
            weapons[client] = true;
        }
        else
        {
            PrintToChat(client, "\x04[SM] \x03 Вы уже выбрали оружие.");
        }
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_Deagle(client, args)
{
    if (IsPlayerAlive(client))
    {
        if ((weaponIndex = GetPlayerWeaponSlot(client, 1)) != -1)
        {
            RemovePlayerItem(client, weaponIndex);
        }
        GivePlayerItem(client, "weapon_deagle");
    }
    else
    {
        PrintToChat(client, "\x04[SM] \x03 Вы не можете использовать эту команду.");
    }
    return Plugin_Handled;
}
public Action:Command_weaponList(client, args)
{
    new i;
    for (i = 0; i < MAX_WEAPONS; ++i)
    ReplyToCommand(client, "%s", weaponList[i]);
    return Plugin_Handled;
}
public OnClientDisconnect(client)
{
    weapons[client] = false;
}
public Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    for (new x = 1; x <= MaxClients; ++x)
    {
        weapons[x] = false;
    }
}
 

vasil

Участник
Сообщения
115
Реакции
21
DarklSide...Дружище ОГРОМНОЕ Человеческое Спасибо!!!:beer::beer::beer::beer::beer::beer::beer::beer::beer::beer::beer::beer::beer:

Каждый грамм - за создателей программ!
 
Сверху Снизу