Покупка гранат командой в чате

Parlament Admin

Участник
Сообщения
69
Реакции
2
Уже достаточно давно видел на каком то иностранном сервере плагин который позволяет купить боевую и замораживающию гранату командой в чате !he !smoke.
Возможно кто то знает название или ссылочку на плагин.
 

KorDen

Atra esterní ono thelduin!
Сообщения
2,142
Реакции
1,424
Да собственно там ничего такого и делать не надо, грубо говоря:
Граната:
PHP:
#include <sourcemod>
#include <sdktools>
#define CostHE 200

public OnPluginStart()
{
	RegConsoleCmd("he", CmdBuyHe);
}
public Action:CmdBuyHe(client, arg)
{
	if(client>0 && IsPlayerAlive(client))
	{
		new cash = GetEntProp(client, Prop_Send, "m_iAccount");	
		if(!GetEntProp(client,Prop_Send,"m_bInBuyZone"))
			PrintCenterText(client, "You are not in a buy zone.");
		else if(cash < CostHE)
			PrintCenterText(client, "You not have enough money\nHE cost $%i", CostHE);
		else
		{
			SetEntProp(client, Prop_Send, "m_iAccount", cash - CostHE);
			GivePlayerItem(client, "weapon_hegrenade");
			PrintCenterText(client, "You have purchased HE");
		}
	}
	return Plugin_Handled;
}
 

Parlament Admin

Участник
Сообщения
69
Реакции
2
Да собственно там ничего такого и делать не надо, грубо говоря:
Граната:
PHP:
#include <sourcemod>
#include <sdktools>
#define CostHE 200

public OnPluginStart()
{
	RegConsoleCmd("he", CmdBuyHe);
}
public Action:CmdBuyHe(client, arg)
{
	if(client>0 && IsPlayerAlive(client))
	{
		new cash = GetEntProp(client, Prop_Send, "m_iAccount");	
		if(!GetEntProp(client,Prop_Send,"m_bInBuyZone"))
			PrintCenterText(client, "You are not in a buy zone.");
		else if(cash < CostHE)
			PrintCenterText(client, "You not have enough money\nHE cost $%i", CostHE);
		else
		{
			SetEntProp(client, Prop_Send, "m_iAccount", cash - CostHE);
			GivePlayerItem(client, "weapon_hegrenade");
			PrintCenterText(client, "You have purchased HE");
		}
	}
	return Plugin_Handled;
}

RIKO мне нужен был такой плагин для ZM мода, я не знаю почему модераторы переместили тему из раздела zombie, но если модифицируеш под зм сервер, буду очень признателен !!

Оффтоп
 
Последнее редактирование:

cangncan

Участник
Сообщения
69
Реакции
4
Стоят у меня три на sourcemod может и тебе пригодятся)))
вот на hegrenade
PHP:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new g_offsAccount;
new g_iMyWeapons;
new Handle:h_HePrice, heprice;

public Plugin:myinfo =
{
    name = "Buying grenade via chat",
    author = "FrozDark (HLModders.ru LLC)",
    description = "Buying grenade via chat",
    version = SOURCEMOD_VERSION,
    url = "http://www.hlmod.ru/"
};

public OnPluginStart()
{
    h_HePrice = CreateConVar("hg_cost", "300", "He grenade cost");
    
    g_iMyWeapons = FindSendPropOffs("CBaseCombatCharacter", "m_hMyWeapons");
    g_offsAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
    
    if (g_offsAccount == -1)
        SetFailState("Couldn't find offset \"m_iAccount\"!");
    if (g_iMyWeapons == -1)
        SetFailState("Couldn't find offset \"m_hMyWeapons\"!");
        
    HookConVarChange(h_HePrice, ConVarChange_HePrice);

    RegConsoleCmd("sm_hg", BuyGrenade);
    RegConsoleCmd("sm_bhg", BuyGrenade);
    RegConsoleCmd("sm_buyhe", BuyGrenade);
    RegConsoleCmd("sm_buyhegrenade", BuyGrenade);
}

public OnConfigsExecuted()
{
    heprice = GetConVarInt(h_HePrice);
}

public ConVarChange_HePrice(Handle:convar, const String:oldValue[], const String:newValue[])
{
    heprice = StringToInt(newValue);
}

public Action:BuyGrenade(client, argc)
{
    if (IsFakeClient(client))
        return Plugin_Handled;
    
    new money = GetEntData(client, g_offsAccount);
        
    if (PlayerHasWeapon(client, "weapon_hegrenade") || (money < heprice))
        return Plugin_Handled;
        
    SetEntData(client, g_offsAccount, money - heprice);
    GivePlayerItem(client, "weapon_hegrenade");
    
    return Plugin_Handled;
}

bool:PlayerHasWeapon(client, const String:Weapon[32])
{
    new weaponentity = -1;
    new String:weaponname[32];
    
    for (new i = 0; i <= 128; i += 4)
    {
        weaponentity = GetEntDataEnt2(client, (g_iMyWeapons + i));
        if (IsValidEdict(weaponentity))
        {
            GetEdictClassname(weaponentity, weaponname, sizeof(weaponname));
            if (StrEqual(weaponname, Weapon, false))
                return true;
        }
        else
            continue;
    }
    return false;
}
сам переделал, в коде не разбираюсь но....ошибок не сыпет и работает:

на флешь:
PHP:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new g_offsAccount;
new g_iMyWeapons;
new Handle:F_FgPrice, fgprice;

public Plugin:myinfo =
{
    name = "Buying grenade via chat",
    author = "FrozDark (HLModders.ru LLC)",
    description = "Buying grenade via chat",
    version = SOURCEMOD_VERSION,
    url = "http://www.hlmod.ru/"
};

public OnPluginStart()
{
    F_FgPrice = CreateConVar("fg_cost", "300", "Fl grenade cost");
    
    g_iMyWeapons = FindSendPropOffs("CBaseCombatCharacter", "m_hMyWeapons");
    g_offsAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
    
    if (g_offsAccount == -1)
        SetFailState("Couldn't find offset \"m_iAccount\"!");
    if (g_iMyWeapons == -1)
        SetFailState("Couldn't find offset \"m_hMyWeapons\"!");
        
    HookConVarChange(F_FgPrice, ConVarChange_FgPrice);

    RegConsoleCmd("sm_fg", BuyGrenade);
    RegConsoleCmd("sm_bfg", BuyGrenade);
    RegConsoleCmd("sm_buyfg", BuyGrenade);
    RegConsoleCmd("sm_buyflashbang", BuyGrenade);
}

public OnConfigsExecuted()
{
    fgprice = GetConVarInt(F_FgPrice);
}

public ConVarChange_FgPrice(Handle:convar, const String:oldValue[], const String:newValue[])
{
    fgprice = StringToInt(newValue);
}

public Action:BuyGrenade(client, argc)
{
    if (IsFakeClient(client))
        return Plugin_Handled;
    
    new money = GetEntData(client, g_offsAccount);
        
    if (PlayerHasWeapon(client, "weapon_flashbang") || (money < fgprice))
        return Plugin_Handled;
        
    SetEntData(client, g_offsAccount, money - fgprice);
    GivePlayerItem(client, "weapon_flashbang");
    
    return Plugin_Handled;
}

bool:PlayerHasWeapon(client, const String:Weapon[32])
{
    new weaponentity = -1;
    new String:weaponname[32];
    
    for (new i = 0; i <= 128; i += 4)
    {
        weaponentity = GetEntDataEnt2(client, (g_iMyWeapons + i));
        if (IsValidEdict(weaponentity))
        {
            GetEdictClassname(weaponentity, weaponname, sizeof(weaponname));
            if (StrEqual(weaponname, Weapon, false))
                return true;
        }
        else
            continue;
    }
    return false;
}
на дымовую:
PHP:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new g_offsAccount;
new g_iMyWeapons;
new Handle:s_SgPrice, sgprice;

public Plugin:myinfo =
{
    name = "Buying grenade via chat",
    author = "FrozDark (HLModders.ru LLC)",
    description = "Buying grenade via chat",
    version = SOURCEMOD_VERSION,
    url = "http://www.hlmod.ru/"
};

public OnPluginStart()
{
    s_SgPrice = CreateConVar("sg_cost", "300", "Sm grenade cost");
    
    g_iMyWeapons = FindSendPropOffs("CBaseCombatCharacter", "m_hMyWeapons");
    g_offsAccount = FindSendPropInfo("CCSPlayer", "m_iAccount");
    
    if (g_offsAccount == -1)
        SetFailState("Couldn't find offset \"m_iAccount\"!");
    if (g_iMyWeapons == -1)
        SetFailState("Couldn't find offset \"m_hMyWeapons\"!");
        
    HookConVarChange(s_SgPrice, ConVarChange_SgPrice);

    RegConsoleCmd("sm_sg", BuyGrenade);
    RegConsoleCmd("sm_bsg", BuyGrenade);
    RegConsoleCmd("sm_buysg", BuyGrenade);
    RegConsoleCmd("sm_buysmokegrenade", BuyGrenade);
}

public OnConfigsExecuted()
{
    sgprice = GetConVarInt(s_SgPrice);
}

public ConVarChange_SgPrice(Handle:convar, const String:oldValue[], const String:newValue[])
{
    sgprice = StringToInt(newValue);
}

public Action:BuyGrenade(client, argc)
{
    if (IsFakeClient(client))
        return Plugin_Handled;
    
    new money = GetEntData(client, g_offsAccount);
        
    if (PlayerHasWeapon(client, "weapon_smokegrenade") || (money < sgprice))
        return Plugin_Handled;
        
    SetEntData(client, g_offsAccount, money - sgprice);
    GivePlayerItem(client, "weapon_smokegrenade");
    
    return Plugin_Handled;
}

bool:PlayerHasWeapon(client, const String:Weapon[32])
{
    new weaponentity = -1;
    new String:weaponname[32];
    
    for (new i = 0; i <= 128; i += 4)
    {
        weaponentity = GetEntDataEnt2(client, (g_iMyWeapons + i));
        if (IsValidEdict(weaponentity))
        {
            GetEdictClassname(weaponentity, weaponname, sizeof(weaponname));
            if (StrEqual(weaponname, Weapon, false))
                return true;
        }
        else
            continue;
    }
    return false;
}
 

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #6
cangncan, а в один соиденить не?
 

cangncan

Участник
Сообщения
69
Реакции
4
я в коде не силен. Могу только что-нибудь переделать. Вот если кто помог...может быть R1KO :)???
 

acik_traiks

Что нибудь напишем?)
Сообщения
770
Реакции
627
а при появление(возрождение) можно чтоб довал he smoke flash?
 

cangncan

Участник
Сообщения
69
Реакции
4
acik, если сервер DM то это делается в cssdm.equip.txt вот так например:
// Automatic things to give on spawn.
//
"AutoItems"
{
// Health amount to give (0 to use default from game/other plugin)
"health" "100"

// Armor amount to give
"armor" "100"

// Whether to give a helmet. If you want to disable armor, you must
// set this to "no" as well as setting armor to 0.
"helmet" "yes"

// Number of flashbangs to give
"flashbangs" "1"

// Whether to give a smoke grenade
"smokegrenade" "yes"

// Whether to give an HE grenade
"hegrenade" "yes"

// Whether to give defusekits to CTs
"defusekits" "yes"

// Whether to give nightvision
"nightvision" "yes"
}
 

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #12
acik,
PHP:
#include <sourcemod>
#include <sdktools>
#include <zombiereloaded>

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

public Event_PlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
	if(iClient > 0 && IsPlayerAlive(iClient) && ZR_IsClientHuman(iClient) && !IsFakeClient(iClient))
	{
		GivePlayerItem(iClient, "weapon_hegrenade");
		GivePlayerItem(iClient, "weapon_flashbang");
		GivePlayerItem(iClient, "weapon_smokegrenade");
	}
}
Все гранаты при спавне.
 
Последнее редактирование:

Parlament Admin

Участник
Сообщения
69
Реакции
2
acik,
PHP:
#include <sourcemod>
#include <sdktools>

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

public Event_PlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
{
    new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
	if(iClient > 0 && IsPlayerAlive(iClient) && !IsFakeClient(iClient))
	{
		GivePlayerItem(client, "weapon_hegrenade");
		GivePlayerItem(client, "weapon_flashbang");
		GivePlayerItem(client, "weapon_smokegrenade");
	}
}
Все гранаты при спавне.

Отличная идея, выдавать игроку гранаты при спавне именно так делается в зомби моде cs 1.6 :)
 
  • Мне нравится
Реакции: R1KO

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #14
Parlament Admin, там нет проверки зомби игрок или нет
 

acik_traiks

Что нибудь напишем?)
Сообщения
770
Реакции
627
R1KO, у меня постоянно дает по 2 грены каждой Как только зашел тоже дается)
 

R1KO

fuck society
Сообщения
9,457
Реакции
7,786
  • Команда форума
  • #18
acik, странно, вроде проверки все есть
 
Сверху Снизу