AlmazON
Не путать с самим yand3xmail
- Сообщения
- 5,099
- Реакции
- 2,755
После смерти игрока удалять его оружие через этот же промежуток времени или нет?Убирал только тот скаут, который выбросил игрок
После смерти игрока удалять его оружие через этот же промежуток времени или нет?Убирал только тот скаут, который выбросил игрок
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#define HEGRENADE_AMMO 11
#define FLASH_AMMO 12
#define SMOKE_AMMO 13
new Handle:cknife;
public Plugin:myinfo =
{
name = "Grenade Drop (he, flash, smoke)",
author = "rodipm",
description = "Allows you to drop your grenades like dropping normal weapons (by default pressing 'G')",
version = "1.3",
url = "http://forums.alliedmods.net/showthread.php?t=172315"
}
public OnPluginStart()
{
AddCommandListener(Drop, "drop");
cknife = CreateConVar("gd_dropknife", "0", "allows you to drop the knife too");
}
public Action:Drop(client, const String:command[], argc)
{
decl String:name[80];
new count;
new index;
new wpindex = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
if(!IsValidEntity(wpindex))
return Plugin_Handled;
GetEntityClassname(wpindex, name, sizeof(name));
//if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
if(IsClientConnected(client) && IsClientInGame(client))
{
if(StrEqual(name, "weapon_flashbang", false))
{
count = GetEntProp(client, Prop_Send, "m_iAmmo", _, FLASH_AMMO);
CS_DropWeapon(client, wpindex, true, true);
if(count > 1)
{
index = GivePlayerItem(client, "weapon_flashbang");
SetEntProp(client, Prop_Send, "m_iAmmo", count-1, _, FLASH_AMMO);
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", index);
}
return Plugin_Handled;
}
else if(StrEqual(name, "weapon_hegrenade", false))
{
count = GetEntProp(client, Prop_Send, "m_iAmmo", _, HEGRENADE_AMMO);
CS_DropWeapon(client, wpindex, true, true);
if(count > 1)
{
index = GivePlayerItem(client, "weapon_hegrenade");
SetEntProp(client, Prop_Send, "m_iAmmo", count-1, _, HEGRENADE_AMMO);
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", index);
}
return Plugin_Handled;
}
else if(StrEqual(name, "weapon_smokegrenade", false))
{
count = GetEntProp(client, Prop_Send, "m_iAmmo", _, SMOKE_AMMO);
CS_DropWeapon(client, wpindex, true, true);
if(count > 1)
{
index = GivePlayerItem(client, "weapon_smokegrenade");
SetEntProp(client, Prop_Send, "m_iAmmo", count-1, _, SMOKE_AMMO);
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", index);
}
return Plugin_Handled;
}
else if(StrEqual(name, "weapon_knife", false) && GetConVarInt(cknife) == 1)
{
CS_DropWeapon(client, wpindex, true, true);
return Plugin_Handled;
}
}
return Plugin_Continue;
}
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
public Action:CS_OnCSWeaponDrop(client, index)
{
if (IsClientInGame(client))
{
decl String:weapon[25];
GetEntityClassname(index, weapon, sizeof(weapon));
if(StrEqual(weapon[7], "grenade")) return Plugin_Continue;
else return Plugin_Handled;
}
return Plugin_Continue;
}
GiveWeapon(client, index)
{
if (!IsPlayerAlive(client))
{
return;
}
new DmWeaponType:type = DM_GetWeaponType(index);
new entity = DM_GetClientWeapon(client, type);
if (entity != -1)
{
DM_DropWeapon(client, entity);
}
new String:cls[64];
DM_GetWeaponClassname(index, cls, sizeof(cls));
GivePlayerItem(client, cls);
}
//if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
if(IsClientConnected(client) && IsClientInGame(client))
DelWeaponOfIndex(client, index_weapon)
{
if(IsClientInGame(client))
{
RemovePlayerItem(client, index_weapon);
AcceptEntityInput(index_weapon, "Kill");
}
}
DropPlayerWeaponOnSlot(client,slot)
{
new weapon_index=-1;
new String:weapon_string[20];
// if client has a weapon on slot and string is available
if(((weapon_index = GetPlayerWeaponSlot(client, slot)) != -1)
&& GetEdictClassname(weapon_index, weapon_string, 20))
{
// give the same weapon to client (gets dropped)
GivePlayerItem(client,weapon_string);
// remove weapon from client
RemovePlayerItem(client, weapon_index);
}
}
public itemplayer(client)
{
new playeritem;
for (new i = 0; i < 6; i++)
{
if (i < 6 && (playeritem = GetPlayerWeaponSlot(client, i)) != -1)
{
RemovePlayerItem(client, playeritem);
}
}
}
чтобы после смерти игрока граната всё таки вываливалась из него
if (IsClientInGame(client))
if (IsClientInGame(client) && IsPlayerAlive(client))
Попробовал, безрезультатноПробовал?PHP:if (IsClientInGame(client) && IsPlayerAlive(client))
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
public Action:CS_OnCSWeaponDrop(client, index)
{
if(IsAcitveWeaponGrenade(client,index)) return Plugin_Continue;
else return Plugin_Handled;
}
bool:IsAcitveWeaponGrenade(client,index) {
if(index > MaxClients)
if(index == GetPlayerWeaponSlot(client, 4))
return true;
return false;
}
По-моему, про это уже и была речь. Нужно хукать урон и, когда игрока ранят "последний раз" (до смерти), то менять там переменную на выполнение return Plugin_Continue;, когда это граната. Так вот сделали.безрезультатно
чтобы любое оружие не выкидовалось точнее сказать не пропадало когда случайно нажымаеш на клавишу " G "
public OnPluginStart() AddCommandListener(DropWeapon, "drop");
public Action:DropWeapon(client, String:command[], args) return Plugin_Handled;
mp_death_drop_grenade 0 не подходит?Пока гуглил, нашел эту тему. Создам сообщение здесь, чтобы если кто-то искал, то мог найти этот тред.
Мне нужно удалять гранаты из игроков которые погибли (убили, суицид, etc), чтобы гранаты на карте не оставались.
Может кто подкинуть код?![]()
Кто знает как сделать что при открытом выборе оружия ( меню ) нельзя было выкинуть эмку - и т.д
#include <sourcemod>
#include <sdktools>
#define PLUGIN_NAME "Расширенный выбор оружия"
#define PLUGIN_AUTHOR "StrAnn1k"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_DESCRIPTION ""
int MENU_TIME[MAXPLAYERS+1];
public void OnPluginStart(){
HookEvent("item_purchase", Event_ItemPurchase, EventHookMode_Post);
RegConsoleCmd("drop", cmd_drop);
}
public Action cmd_drop(int client, int args){
return (MENU_TIME[client] - GetTime() > 0) ? Plugin_Handled : Plugin_Continue;
}
public Action Event_ItemPurchase(Event event, const char[] name, bool dontBroadcast){
int client = GetClientOfUserId(event.GetInt("userid"));
if(client < 1 || !IsClientInGame(client) || IsFakeClient(client))
return Plugin_Continue;
char weapon[64];
event.GetString("weapon", weapon, sizeof(weapon));
if(StrEqual(weapon, "weapon_hkp2000") || StrEqual(weapon, "weapon_usp_silencer")) // Покупка пистолетов
ShowChooseMenu(client, 1);
else if(StrEqual(weapon, "weapon_m4a1_silencer") || StrEqual(weapon, "weapon_m4a1")) // Покупка винтовок
ShowChooseMenu(client, 2);
return Plugin_Continue;
}
void ShowChooseMenu(int client, int type){
Menu hMenu = new Menu(MenuWeaponHandler);
if(type == 1){ // Пистолеты
hMenu.SetTitle("Выберите пистолет:");
hMenu.AddItem("weapon_usp_silencer", "USP-S");
hMenu.AddItem("weapon_hkp2000", "P2000");
}
else if(type == 2){ // Винтовки
hMenu.SetTitle("Выберите винтовку:");
hMenu.AddItem("weapon_m4a1_silencer", "M4A1-S");
hMenu.AddItem("weapon_m4a1", "M4A1");
}
hMenu.Display(client, 3);
MENU_TIME[client] = GetTime() + 3;
}
public int MenuWeaponHandler(Menu hMenu, MenuAction action, int client, int iItem){
if(action == MenuAction_Select){
if(client > 0 && IsClientInGame(client) && !IsFakeClient(client)){
char weapon[64];
hMenu.GetItem(iItem, weapon, sizeof(weapon));
ReplaceWeapon(client, weapon); // Replace the weapon with the selected one
}
}
MENU_TIME[client] = 0;
// Remove or comment out the following line
// hMenu.Close(); // Do not manually close the menu here
return 0; // Return int, not Handle
}
void ReplaceWeapon(int client, const char[] weapon){
int slot = (StrEqual(weapon, "weapon_usp_silencer") || StrEqual(weapon, "weapon_hkp2000")) ? 1 : 0; // 1 for pistols, 0 for primary weapons
// Remove the current weapon in the selected slot
int currentWeapon = GetPlayerWeaponSlot(client, slot);
if (currentWeapon != -1) // Compare to -1 for invalid entity index
RemovePlayerItem(client, currentWeapon); // Remove the current weapon
GivePlayerItem(client, weapon); // Give the new weapon
}
Можно еще как то офнуть меню покупки пока он не выберет оружиеcode:#include <sourcemod> #include <sdktools> #define PLUGIN_NAME "Расширенный выбор оружия" #define PLUGIN_AUTHOR "StrAnn1k" #define PLUGIN_VERSION "1.0" #define PLUGIN_DESCRIPTION "" int MENU_TIME[MAXPLAYERS+1]; public void OnPluginStart(){ HookEvent("item_purchase", Event_ItemPurchase, EventHookMode_Post); RegConsoleCmd("drop", cmd_drop); } public Action cmd_drop(int client, int args){ return (MENU_TIME[client] - GetTime() > 0) ? Plugin_Handled : Plugin_Continue; } public Action Event_ItemPurchase(Event event, const char[] name, bool dontBroadcast){ int client = GetClientOfUserId(event.GetInt("userid")); if(client < 1 || !IsClientInGame(client) || IsFakeClient(client)) return Plugin_Continue; char weapon[64]; event.GetString("weapon", weapon, sizeof(weapon)); if(StrEqual(weapon, "weapon_hkp2000") || StrEqual(weapon, "weapon_usp_silencer")) // Покупка пистолетов ShowChooseMenu(client, 1); else if(StrEqual(weapon, "weapon_m4a1_silencer") || StrEqual(weapon, "weapon_m4a1")) // Покупка винтовок ShowChooseMenu(client, 2); return Plugin_Continue; } void ShowChooseMenu(int client, int type){ Menu hMenu = new Menu(MenuWeaponHandler); if(type == 1){ // Пистолеты hMenu.SetTitle("Выберите пистолет:"); hMenu.AddItem("weapon_usp_silencer", "USP-S"); hMenu.AddItem("weapon_hkp2000", "P2000"); } else if(type == 2){ // Винтовки hMenu.SetTitle("Выберите винтовку:"); hMenu.AddItem("weapon_m4a1_silencer", "M4A1-S"); hMenu.AddItem("weapon_m4a1", "M4A1"); } hMenu.Display(client, 3); MENU_TIME[client] = GetTime() + 3; } public int MenuWeaponHandler(Menu hMenu, MenuAction action, int client, int iItem){ if(action == MenuAction_Select){ if(client > 0 && IsClientInGame(client) && !IsFakeClient(client)){ char weapon[64]; hMenu.GetItem(iItem, weapon, sizeof(weapon)); ReplaceWeapon(client, weapon); // Replace the weapon with the selected one } } MENU_TIME[client] = 0; // Remove or comment out the following line // hMenu.Close(); // Do not manually close the menu here return 0; // Return int, not Handle } void ReplaceWeapon(int client, const char[] weapon){ int slot = (StrEqual(weapon, "weapon_usp_silencer") || StrEqual(weapon, "weapon_hkp2000")) ? 1 : 0; // 1 for pistols, 0 for primary weapons // Remove the current weapon in the selected slot int currentWeapon = GetPlayerWeaponSlot(client, slot); if (currentWeapon != -1) // Compare to -1 for invalid entity index RemovePlayerItem(client, currentWeapon); // Remove the current weapon GivePlayerItem(client, weapon); // Give the new weapon }