Перейти к содержимому


Фотография

Плагин код


  • Авторизуйтесь для ответа в теме
Сообщений в теме: 2

#1 Адский

Адский

    Новичок

  • Пользователь
  • Pip
  • 23 сообщений

Отправлено 17 Январь 2019 - 14:01

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
#define DEBUG 0
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_SPONLY
#define advertising IsClientInGame(client) && GetConVarInt(cvar_meleeannounce)
#define MODEL_CROWBAR_W "models/weapons/melee/w_crowbar.mdl"
#define MODEL_CROWBAR_V "models/weapons/melee/v_crowbar.mdl"
#define MODEL_CRICKETBAT_W "models/weapons/melee/w_cricket_bat.mdl"
#define MODEL_CRICKETBAT_V "models/weapons/melee/v_cricket_bat.mdl"
#define MODEL_ELECTRICGUITAR_W "models/weapons/melee/w_electric_guitar.mdl"
#define MODEL_ELECTRICGUITAR_V "models/weapons/melee/v_electric_guitar.mdl"
#define MODEL_FIREAXE_W "models/weapons/melee/w_fireaxe.mdl"
#define MODEL_FIREAXE_V "models/weapons/melee/v_fireaxe.mdl"
#define MODEL_FRYINGPAN_W "models/weapons/melee/w_frying_pan.mdl"
#define MODEL_FRYINGPAN_V "models/weapons/melee/v_frying_pan.mdl"
#define MODEL_GOLFCLUB_W "models/weapons/melee/w_golfclub.mdl"
#define MODEL_GOLFCLUB_V "models/weapons/melee/v_golfclub.mdl"
#define MODEL_KATANA_W "models/weapons/melee/w_katana.mdl"
#define MODEL_KATANA_V "models/weapons/melee/v_katana.mdl"
#define MODEL_MACHETE_W "models/weapons/melee/w_machete.mdl"
#define MODEL_MACHETE_V "models/weapons/melee/v_machete.mdl"
#define MODEL_TONFA_W "models/weapons/melee/w_tonfa.mdl"
#define MODEL_TONFA_V "models/weapons/melee/v_tonfa.mdl"

new Handle:cvar_maxweaponstotal = INVALID_HANDLE;
new Handle:cvar_maxweaponsclient = INVALID_HANDLE;
new Handle:cvar_meleeannounce = INVALID_HANDLE;
new numweaponstotal;
new numweaponsclient[MAXPLAYERS + 1];
public Plugin:myinfo = 
{
    name = "[L4D2]Melee",
    author = "Adski",
    description = "melee",
    version = PLUGIN_VERSION,
    url = ""
}
public OnPluginStart()
{
    //melee weapons menu cvar
    RegConsoleCmd("sm_melee", MeleeMenu);
    //plugin version
    CreateConVar("melee_version", PLUGIN_VERSION, "L4D 2 Melee Weapons Menu version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    cvar_maxweaponstotal = CreateConVar("melee_max", "40", "How much times all players can get melee weapons per map", FCVAR_PLUGIN|FCVAR_NOTIFY);
    cvar_maxweaponsclient = CreateConVar("melee_playermax", "10", "How much times one player can get melee weapons", FCVAR_PLUGIN|FCVAR_NOTIFY);
    // Announce cvar
    cvar_meleeannounce = CreateConVar("melee_announce", "3", "реклама 1? реклама 2, 3 реклама,  0 нет.",CVAR_FLAGS,true,0.0,true,3.0);
    HookEvent("round_end", Event_RoundEnd);
    //autoexec
    AutoExecConfig(true, "l4d2_melee");
}
public OnMapStart()
{
    PrecacheModel(MODEL_CROWBAR_W, true);
    PrecacheModel(MODEL_CROWBAR_V, true);
    PrecacheModel(MODEL_CRICKETBAT_W, true);
    PrecacheModel(MODEL_CRICKETBAT_V, true);
    PrecacheModel(MODEL_ELECTRICGUITAR_W, true);
    PrecacheModel(MODEL_ELECTRICGUITAR_V, true);
    PrecacheModel(MODEL_FIREAXE_W, true);
    PrecacheModel(MODEL_FIREAXE_V, true);
    PrecacheModel(MODEL_FRYINGPAN_W, true);
    PrecacheModel(MODEL_FRYINGPAN_V, true);
    PrecacheModel(MODEL_GOLFCLUB_W, true);
    PrecacheModel(MODEL_GOLFCLUB_V, true);
    PrecacheModel(MODEL_KATANA_W, true);
    PrecacheModel(MODEL_KATANA_V, true);
    PrecacheModel(MODEL_GOLFCLUB_W, true);
    PrecacheModel(MODEL_GOLFCLUB_V, true);
    PrecacheModel(MODEL_MACHETE_W, true);
    PrecacheModel(MODEL_MACHETE_V, true);
    PrecacheModel(MODEL_TONFA_W, true);
    PrecacheModel(MODEL_TONFA_V, true);
       
    numweaponstotal = 0;
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    numweaponstotal = 0;
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public OnClientPostAdminCheck(client)
{
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public OnClientPutInServer(client)
{
    if (client)
    {
        if (GetConVarBool(cvar_meleeannounce))
            CreateTimer(30.0, AnnounceMelee, client);
    }
}
public Action:MeleeMenu(client,args)
{
    if(!client || !IsClientInGame(client)) 
        return Plugin_Handled;
    if(GetClientTeam(client) != 2)
    {
        PrintToChat(client, "Извините, но рукопашное оружие  могут брать только игроки  играющие за выживших.");
        return Plugin_Handled;
    }
    if(numweaponstotal >= GetConVarInt(cvar_maxweaponstotal)) 
    {
        PrintToChat(client, " установлен Лимит %i оружия для этой карты.", GetConVarInt(cvar_maxweaponstotal));
        return Plugin_Handled;
    }
    if(numweaponsclient[client] >= GetConVarInt(cvar_maxweaponsclient)) 
    {
        PrintToChat(client, "Время выдачи рукопашного оружия %i минуты вышло.", GetConVarInt(cvar_maxweaponsclient));
        return Plugin_Handled;
    }
    Melee(client);
    return Plugin_Handled;
}
public Action:Melee(clientId)
{
    new Handle:menu = CreateMenu(MeleeMenuHandler);
    AddMenuItem(menu, "option1", "Лом");
    AddMenuItem(menu, "option2", "Бита для крикета");
    AddMenuItem(menu, "option3", "Электро гитара");
    AddMenuItem(menu, "option4", "Топор");
    AddMenuItem(menu, "option5", "Сковородка");
    AddMenuItem(menu, "option6", "Клюшка");
    AddMenuItem(menu, "option7", "Катана");
    AddMenuItem(menu, "option8", "Мачете");
    AddMenuItem(menu, "option9", "Дигл");
    AddMenuItem(menu, "option10", "Дубинка");
    AddMenuItem(menu, "option11", "Пистолет");
   
   
   
   
   
  
    SetMenuExitButton(menu, true);
    DisplayMenu(menu, clientId, MENU_TIME_FOREVER);
    return Plugin_Handled;
}
public Action:AnnounceMelee(Handle:timer, any:client)
{
    if(advertising == 3)
    {
        PrintToChatAll("тут будет моя реклама");
        PrintToChatAll("тут  будет моя реклама");
    }
    else if(advertising == 2)
    {
        PrintToChatAll("тут будет моя реклама ");
    }
    else if(advertising == 1)
    {
        PrintToChatAll("Тут будет моя реклама");
    }
}
public MeleeMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
    //Strip the CHEAT flag off of the "give" command
    new flags = GetCommandFlags("give");
    SetCommandFlags("give", flags & ~FCVAR_CHEAT);
    if ( action == MenuAction_Select ) {
        switch (itemNum)
        {
            case 1: //Crowbar
            {
                //Give the player a Crowbar
                FakeClientCommand(client, "give crowbar");
            }
            case 2: //Cricket Bat
            {
                //Give the player a Cricket Bat
                FakeClientCommand(client, "give cricket_bat");
            }
            case 3: //Electric Guitar
            {
                //Give the player a Electric Guitar
                FakeClientCommand(client, "give electric_guitar");
            }
            case 4: //Fire Axe
            {
                //Give the player a Fire Axe
                FakeClientCommand(client, "give fireaxe");
            }
            case 5: //Frying Pan
            {
                //Give the player a Frying Pan
                FakeClientCommand(client, "give frying_pan");
            }
            case 6: //Golf Club
            {
                //Give the player a Golf Club
                FakeClientCommand(client, "give golfclub");
            }
            case 7: //Katana
            {
                //Give the player a Katana
                FakeClientCommand(client, "give katana");
            }
            case 8: //Machete
            {
                //Give the player a Machete
                FakeClientCommand(client, "give machete");
            }
            case 9: //Magnum
            {
                //Give the player a Magnum
                FakeClientCommand(client, "give pistol_magnum");
            }
            case 10: //Night Stick
            {
                //Give the player a Night Stick
                FakeClientCommand(client, "give tonfa");
            }
            case 11: //Pistol
            {
                //Give the player a Pistol
                FakeClientCommand(client, "give pistol");
            }
        }
        numweaponstotal++;
        numweaponsclient[client]++;
    }
    //Add the CHEAT flag back to "give" command
    SetCommandFlags("give", flags|FCVAR_CHEAT);

где  тут в   у меня в плагине ошибка не могу  понять ,  в игре на сервере   при вызове   контекстого меню с  выбором оружия ,  оружия начинает  работать с цифры 2  то есть смещается выдача ,   милишка выдается с   цифры 2 в менюшке на сервере ,  но  на  цифре  два    на сервере срабатывает  выдача   рукопашного  ружия "Лом"  хотя он у меня стоит на цифре 1 ,  на  цифре 1 вообще ничего не выдается , я не могу понять  в чем ошибка  все проверял  вроде  все как нужно . 



#2 BloodyBlade

BloodyBlade

    Постоянный пользователь

  • Пользователь
  • PipPipPipPipPip
  • 1 097 сообщений

Отправлено 17 Январь 2019 - 22:31

 

#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
#define DEBUG 0
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_SPONLY
#define advertising IsClientInGame(client) && GetConVarInt(cvar_meleeannounce)
#define MODEL_CROWBAR_W "models/weapons/melee/w_crowbar.mdl"
#define MODEL_CROWBAR_V "models/weapons/melee/v_crowbar.mdl"
#define MODEL_CRICKETBAT_W "models/weapons/melee/w_cricket_bat.mdl"
#define MODEL_CRICKETBAT_V "models/weapons/melee/v_cricket_bat.mdl"
#define MODEL_ELECTRICGUITAR_W "models/weapons/melee/w_electric_guitar.mdl"
#define MODEL_ELECTRICGUITAR_V "models/weapons/melee/v_electric_guitar.mdl"
#define MODEL_FIREAXE_W "models/weapons/melee/w_fireaxe.mdl"
#define MODEL_FIREAXE_V "models/weapons/melee/v_fireaxe.mdl"
#define MODEL_FRYINGPAN_W "models/weapons/melee/w_frying_pan.mdl"
#define MODEL_FRYINGPAN_V "models/weapons/melee/v_frying_pan.mdl"
#define MODEL_GOLFCLUB_W "models/weapons/melee/w_golfclub.mdl"
#define MODEL_GOLFCLUB_V "models/weapons/melee/v_golfclub.mdl"
#define MODEL_KATANA_W "models/weapons/melee/w_katana.mdl"
#define MODEL_KATANA_V "models/weapons/melee/v_katana.mdl"
#define MODEL_MACHETE_W "models/weapons/melee/w_machete.mdl"
#define MODEL_MACHETE_V "models/weapons/melee/v_machete.mdl"
#define MODEL_TONFA_W "models/weapons/melee/w_tonfa.mdl"
#define MODEL_TONFA_V "models/weapons/melee/v_tonfa.mdl"

new Handle:cvar_maxweaponstotal = INVALID_HANDLE;
new Handle:cvar_maxweaponsclient = INVALID_HANDLE;
new Handle:cvar_meleeannounce = INVALID_HANDLE;
new numweaponstotal;
new numweaponsclient[MAXPLAYERS + 1];
public Plugin:myinfo = 
{
    name = "[L4D2]Melee",
    author = "Adski",
    description = "melee",
    version = PLUGIN_VERSION,
    url = ""
}
public OnPluginStart()
{
    //melee weapons menu cvar
    RegConsoleCmd("sm_melee", MeleeMenu);
    //plugin version
    CreateConVar("melee_version", PLUGIN_VERSION, "L4D 2 Melee Weapons Menu version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    cvar_maxweaponstotal = CreateConVar("melee_max", "40", "How much times all players can get melee weapons per map", FCVAR_PLUGIN|FCVAR_NOTIFY);
    cvar_maxweaponsclient = CreateConVar("melee_playermax", "10", "How much times one player can get melee weapons", FCVAR_PLUGIN|FCVAR_NOTIFY);
    // Announce cvar
    cvar_meleeannounce = CreateConVar("melee_announce", "3", "реклама 1? реклама 2, 3 реклама,  0 нет.",CVAR_FLAGS,true,0.0,true,3.0);
    HookEvent("round_end", Event_RoundEnd);
    //autoexec
    AutoExecConfig(true, "l4d2_melee");
}
public OnMapStart()
{
    PrecacheModel(MODEL_CROWBAR_W, true);
    PrecacheModel(MODEL_CROWBAR_V, true);
    PrecacheModel(MODEL_CRICKETBAT_W, true);
    PrecacheModel(MODEL_CRICKETBAT_V, true);
    PrecacheModel(MODEL_ELECTRICGUITAR_W, true);
    PrecacheModel(MODEL_ELECTRICGUITAR_V, true);
    PrecacheModel(MODEL_FIREAXE_W, true);
    PrecacheModel(MODEL_FIREAXE_V, true);
    PrecacheModel(MODEL_FRYINGPAN_W, true);
    PrecacheModel(MODEL_FRYINGPAN_V, true);
    PrecacheModel(MODEL_GOLFCLUB_W, true);
    PrecacheModel(MODEL_GOLFCLUB_V, true);
    PrecacheModel(MODEL_KATANA_W, true);
    PrecacheModel(MODEL_KATANA_V, true);
    PrecacheModel(MODEL_GOLFCLUB_W, true);
    PrecacheModel(MODEL_GOLFCLUB_V, true);
    PrecacheModel(MODEL_MACHETE_W, true);
    PrecacheModel(MODEL_MACHETE_V, true);
    PrecacheModel(MODEL_TONFA_W, true);
    PrecacheModel(MODEL_TONFA_V, true);
       
    numweaponstotal = 0;
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    numweaponstotal = 0;
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public OnClientPostAdminCheck(client)
{
    for(new i = 1; i <= MAXPLAYERS; i++)
        numweaponsclient[i] = 0;
}
public OnClientPutInServer(client)
{
    if (client)
    {
        if (GetConVarBool(cvar_meleeannounce))
            CreateTimer(30.0, AnnounceMelee, client);
    }
}
public Action:MeleeMenu(client,args)
{
    if(!client || !IsClientInGame(client)) 
        return Plugin_Handled;
    if(GetClientTeam(client) != 2)
    {
        PrintToChat(client, "Извините, но рукопашное оружие  могут брать только игроки  играющие за выживших.");
        return Plugin_Handled;
    }
    if(numweaponstotal >= GetConVarInt(cvar_maxweaponstotal)) 
    {
        PrintToChat(client, " установлен Лимит %i оружия для этой карты.", GetConVarInt(cvar_maxweaponstotal));
        return Plugin_Handled;
    }
    if(numweaponsclient[client] >= GetConVarInt(cvar_maxweaponsclient)) 
    {
        PrintToChat(client, "Время выдачи рукопашного оружия %i минуты вышло.", GetConVarInt(cvar_maxweaponsclient));
        return Plugin_Handled;
    }
    Melee(client);
    return Plugin_Handled;
}
public Action:Melee(clientId)
{
    new Handle:menu = CreateMenu(MeleeMenuHandler);
    AddMenuItem(menu, "option1", "Лом");
    AddMenuItem(menu, "option2", "Бита для крикета");
    AddMenuItem(menu, "option3", "Электро гитара");
    AddMenuItem(menu, "option4", "Топор");
    AddMenuItem(menu, "option5", "Сковородка");
    AddMenuItem(menu, "option6", "Клюшка");
    AddMenuItem(menu, "option7", "Катана");
    AddMenuItem(menu, "option8", "Мачете");
    AddMenuItem(menu, "option9", "Дигл");
    AddMenuItem(menu, "option10", "Дубинка");
    AddMenuItem(menu, "option11", "Пистолет");
   
   
   
   
   
  
    SetMenuExitButton(menu, true);
    DisplayMenu(menu, clientId, MENU_TIME_FOREVER);
    return Plugin_Handled;
}
public Action:AnnounceMelee(Handle:timer, any:client)
{
    if(advertising == 3)
    {
        PrintToChatAll("тут будет моя реклама");
        PrintToChatAll("тут  будет моя реклама");
    }
    else if(advertising == 2)
    {
        PrintToChatAll("тут будет моя реклама ");
    }
    else if(advertising == 1)
    {
        PrintToChatAll("Тут будет моя реклама");
    }
}
public MeleeMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
    //Strip the CHEAT flag off of the "give" command
    new flags = GetCommandFlags("give");
    SetCommandFlags("give", flags & ~FCVAR_CHEAT);
    if ( action == MenuAction_Select ) {
        switch (itemNum)
        {
            case 1: //Crowbar
            {
                //Give the player a Crowbar
                FakeClientCommand(client, "give crowbar");
            }
            case 2: //Cricket Bat
            {
                //Give the player a Cricket Bat
                FakeClientCommand(client, "give cricket_bat");
            }
            case 3: //Electric Guitar
            {
                //Give the player a Electric Guitar
                FakeClientCommand(client, "give electric_guitar");
            }
            case 4: //Fire Axe
            {
                //Give the player a Fire Axe
                FakeClientCommand(client, "give fireaxe");
            }
            case 5: //Frying Pan
            {
                //Give the player a Frying Pan
                FakeClientCommand(client, "give frying_pan");
            }
            case 6: //Golf Club
            {
                //Give the player a Golf Club
                FakeClientCommand(client, "give golfclub");
            }
            case 7: //Katana
            {
                //Give the player a Katana
                FakeClientCommand(client, "give katana");
            }
            case 8: //Machete
            {
                //Give the player a Machete
                FakeClientCommand(client, "give machete");
            }
            case 9: //Magnum
            {
                //Give the player a Magnum
                FakeClientCommand(client, "give pistol_magnum");
            }
            case 10: //Night Stick
            {
                //Give the player a Night Stick
                FakeClientCommand(client, "give tonfa");
            }
            case 11: //Pistol
            {
                //Give the player a Pistol
                FakeClientCommand(client, "give pistol");
            }
        }
        numweaponstotal++;
        numweaponsclient[client]++;
    }
    //Add the CHEAT flag back to "give" command
    SetCommandFlags("give", flags|FCVAR_CHEAT);

где  тут в   у меня в плагине ошибка не могу  понять ,  в игре на сервере   при вызове   контекстого меню с  выбором оружия ,  оружия начинает  работать с цифры 2  то есть смещается выдача ,   милишка выдается с   цифры 2 в менюшке на сервере ,  но  на  цифре  два    на сервере срабатывает  выдача   рукопашного  ружия "Лом"  хотя он у меня стоит на цифре 1 ,  на  цифре 1 вообще ничего не выдается , я не могу понять  в чем ошибка  все проверял  вроде  все как нужно . 

 

Кидай пожалуйста в следующий раз код под спойлер, как это сделал я ниже.

Ошибка была в нумеровании команд выдачи.

Пробуй. Так должно правильно выдаваться.

Скрытый текст

Сообщение отредактировал BloodyBlade: 17 Январь 2019 - 22:36

  • Адский это нравится

#3 Адский

Адский

    Новичок

  • Пользователь
  • Pip
  • 23 сообщений

Отправлено 18 Январь 2019 - 11:22

Кидай пожалуйста в следующий раз код под спойлер, как это сделал я ниже.

Ошибка была в нумеровании команд выдачи.

Пробуй. Так должно правильно выдаваться.

Скрытый текст

Спасибо) 




Количество пользователей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных