FrozDark
Участник
- Сообщения
- 1,769
- Реакции
- 2,050
какой догадливый)Лишняя нагрузка! Просто делаем g_bHasEE[0] = true в самом начале кода и вуаля - игровой мир у нас тоже "VIP"! Опять же, всё одной проверкой
какой догадливый)Лишняя нагрузка! Просто делаем g_bHasEE[0] = true в самом начале кода и вуаля - игровой мир у нас тоже "VIP"! Опять же, всё одной проверкой
По идее, лучший вариант такой:Просто делаем g_bHasEE[0] = true в самом начале кода
new bool:g_bHasEE[MAXPLAYERS+1] = {true};
Ведь тогда она сбросит наши усилия на нет. Придётся делать:PHP:public OnClientPostAdminCheck(iClient) g_bHasEE[iClient] = false;
public OnClientPostAdminCheck(iClient) if(iClient) g_bHasEE[iClient] = false;
public OnClientPostAdminCheck(iClient)
{
g_bHasEE[iClient] = false;
g_bHasEE[0] = true;
}
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <shop>
#define CATEGORY "stuff"
new bool:g_bHasEE[MAXPLAYERS+1] = {true};
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Electro Effect",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
HookEvent("player_death", Event_ElectroEffect);
g_hPrice = CreateConVar("sm_shop_electroeffect_price", "7000", "Стоимость покупки электро эффекта.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_electroeffect_sellprice", "3500", "Стоимость продажи электро эффекта.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_electroeffect_duration", "2592000", "Длительность электро эффекта в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_electroeffect", "shop");
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
{
if(id != INVALID_ITEM)
{
if(hCvar == g_hPrice) Shop_SetItemPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hSellPrice) Shop_SetItemSellPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hDuration) Shop_SetItemValue(id, GetConVarInt(hCvar));
}
}
public OnPluginEnd() Shop_UnregisterMe();
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Дополнительно", "");
if (Shop_StartItem(category_id, "electroeffect"))
{
Shop_SetInfo("Электро-эффект", "", GetConVarInt(g_hPrice), GetConVarInt(g_hSellPrice), Item_Togglable, GetConVarInt(g_hDuration));
Shop_SetCallbacks(OnItemRegistered, OnItemUsed);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) id = item_id;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasEE[iClient] = false;
return Shop_UseOff;
}
g_bHasEE[iClient] = true;
return Shop_UseOn;
}
public OnClientPostAdminCheck(iClient)
{
g_bHasEE[iClient] = false;
g_bHasEE[0] = true;
}
//Функция обратного вызова, срабатывающая при любом убийстве.
public Event_ElectroEffect(Handle:event, const String:name[], bool:dontBroadcast)
{
//Получаем индекс игрока-убийцы attacker.
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
//Фильтр убийства игровым миром: "игрок"-убийца attacker не может быть равен нулю.
if(g_bHasEE[attacker] && attacker)
{
//Получаем индекс игрока-жертвы victim (убитого).
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
//Фильтрация самоубийства: игрок-убийца attacker не может быть равен игроку-жертве victim (т.е. самому себе).
if(attacker != victim)
{
decl Float:fVec[3];
GetClientAbsOrigin(victim, fVec);
fVec[2] += 20.0;
new tesla = CreateEntityByName("point_tesla"); //Он делается с помощью создания entity объекта "point_tesla"
DispatchKeyValue(tesla, "beamcount_min", "5"); // Минимальное Количество всплесков
DispatchKeyValue(tesla, "beamcount_max", "10"); //Максимальное
DispatchKeyValue(tesla, "lifetime_min", "0.2"); //Минимальное время жизни
DispatchKeyValue(tesla, "lifetime_max", "0.5"); //Максимальное время жизни
DispatchKeyValue(tesla, "m_flRadius", "100.0"); // Радиус
DispatchKeyValue(tesla, "m_SoundName", "DoSpark"); //Звук искр
DispatchKeyValue(tesla, "texture", "sprites/physbeam.vmt"); // Текстура спрайта
DispatchKeyValue(tesla, "m_Color", "255 255 255"); //Цвет
DispatchKeyValue(tesla, "thick_min", "1.0");
DispatchKeyValue(tesla, "thick_max", "10.0");
DispatchKeyValue(tesla, "interval_min", "0.1");
DispatchKeyValue(tesla, "interval_max", "0.2");
DispatchSpawn(tesla); //Спавним наш "point_tesla"
TeleportEntity(tesla, fVec, NULL_VECTOR, NULL_VECTOR); //И телепортируем на позицию прицела
AcceptEntityInput(tesla, "TurnOn");
AcceptEntityInput(tesla, "DoSpark");
}
}
}
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <shop>
#define CATEGORY "stuff"
#define X_CMD "scolor"
new bool:g_bHasSK[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Skin Color",
author = "Smoke",
version = "1.0"
};
new String:sM_ColorName[51][35],
sM_rgba[51][4],
sM_PlayerColorNum[MAXPLAYERS+1],
sM_PlayerNewColorNum[MAXPLAYERS+1],
max_color;
public OnPluginStart()
{
HookEvent("player_spawn", player_spawn);
HookEvent("round_start", round_start, EventHookMode_PostNoCopy);
RegConsoleCmd(X_CMD, say_X_CMD);
g_hPrice = CreateConVar("sm_shop_skincolor_price", "10000", "Стоимость покупки цвета скина.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_skincolor_sellprice", "5000", "Стоимость продажи цвета скина.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_skincolor_duration", "2592000", "Длительность цвета скина в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_skincolor", "shop");
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
{
if(id != INVALID_ITEM)
{
if(hCvar == g_hPrice) Shop_SetItemPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hSellPrice) Shop_SetItemSellPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hDuration) Shop_SetItemValue(id, GetConVarInt(hCvar));
}
}
public OnPluginEnd() Shop_UnregisterMe();
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Дополнительно", "");
if (Shop_StartItem(category_id, "skincolor"))
{
Shop_SetInfo("Цвет Скина [!scolor]", "", GetConVarInt(g_hPrice), GetConVarInt(g_hSellPrice), Item_Togglable, GetConVarInt(g_hDuration));
Shop_SetCallbacks(OnItemRegistered, OnItemUsed);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) id = item_id;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasSK[iClient] = false;
return Shop_UseOff;
}
g_bHasSK[iClient] = true;
return Shop_UseOn;
}
public OnClientPostAdminCheck(iClient)
{
g_bHasSK[iClient] = false;
}
public OnMapStart()
{
new Handle:kv = CreateKeyValues("skin_color");
if (!FileToKeyValues(kv, "cfg/skin_color.txt"))
{
CloseHandle(kv);
SetFailState("Ошибка в cfg/skin_color.txt");
return;
}
new r, g, b, a;
decl String:str_num[3];
for (new x = 1; x < 51; x++)
{
IntToString(x, str_num, 3);
if (!KvJumpToKey(kv, str_num))
{
if (x == 1)
{
CloseHandle(kv);
SetFailState("Цвет №1 не найден в cfg/skin_color.txt!");
}
break;
}
KvGetString(kv, "color_name", sM_ColorName[x], 75);
KvGetColor(kv, "color_rgba", r, g, b, a);
KvRewind(kv);
sM_rgba[x][0] = r;
sM_rgba[x][1] = g;
sM_rgba[x][2] = b;
sM_rgba[x][3] = a;
max_color = x;
}
CloseHandle(kv);
}
public player_spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
new c = sM_PlayerColorNum[iClient];
if (c > 0 && GetClientTeam(iClient) > 1)
{
SetEntityRenderMode(iClient, RENDER_TRANSCOLOR);
SetEntityRenderColor(iClient, sM_rgba[c][0], sM_rgba[c][1], sM_rgba[c][2], sM_rgba[c][3]);
}
}
public OnClientPutInServer(iClient)
{
sM_PlayerColorNum[iClient] = 0;
sM_PlayerNewColorNum[iClient] = 1;
}
public Action:say_X_CMD(iClient, args)
{
if (g_bHasSK[iClient] && iClient)
{
if (iClient > 0 && args < 1) ShowMenu(iClient);
}
else
{
PrintToChat(iClient, "\x04[Цвет Скина] \x01Вы не купили/включили данную возможность в \x03!shop ");
}
return Plugin_Handled;
}
ShowMenu(iClient)
{
new Handle:p = CreatePanel();
SetPanelTitle(p, "Выбор Цвета Скина\n------------------------------------\n \n");
decl String:f[128];
if (sM_PlayerColorNum[iClient] > 0)
{
Format(f, sizeof(f), "Текущий цвет: %s\n \n", sM_ColorName[sM_PlayerColorNum[iClient]]);
DrawPanelText(p, f);
}
else DrawPanelText(p, "Текущий цвет: Стандартный\n \n");
Format(f, sizeof(f), "Выбрать другой: < %s >", sM_ColorName[sM_PlayerNewColorNum[iClient]]);
DrawPanelItem(p, f);
DrawPanelItem(p, "СОХРАНИТЬ изменения\n \n");
DrawPanelItem(p, "Выход");
SendPanelToClient(p, iClient, Select_Menu, 0);
CloseHandle(p);
}
public Select_Menu(Handle:menu, MenuAction:action, iClient, option)
{
if (action != MenuAction_Select) return;
if (option == 1)
{
if (++sM_PlayerNewColorNum[iClient] > max_color) sM_PlayerNewColorNum[iClient] = 1;
ShowMenu(iClient);
}
else if (option == 2)
{
new c = sM_PlayerColorNum[iClient];
new n = sM_PlayerNewColorNum[iClient];
if (sM_rgba[c][0] == sM_rgba[n][0] && sM_rgba[c][1] == sM_rgba[n][1] && sM_rgba[c][2] == sM_rgba[n][2] && sM_rgba[c][3] == sM_rgba[n][3])
{
PrintToChat(iClient, "\x04[Цвет Скина] \x01У вас и так этот цвет..");
}
else
{
sM_PlayerColorNum[iClient] = n;
PrintToChat(iClient, "\x04[Цвет Скина] \x01Изменения вступят в силу в следующем раунде");
ShowMenu(iClient);
}
}
}
public round_start(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
{
if (GetRandomInt(1, 5) == 3)
{
PrintToChat(iClient, "\x04[Цвет Скина] \x01Хотите сменить цвет скина? \x01(\x03%s, !%s, /%s\x01)", X_CMD, X_CMD, X_CMD);
}
}
}
Поможешь с другими вопросами? И почему не правильно?Это неправильно. Всегда ставь if(g_bHasEE[attacker]) для событий.
B1g, так и не понятно, чего ты хочешь?
if(attacker) остановит дальнейший код при убийстве миром. Убери.
B1g, ты прям плагины на лету пишешь :-D
new g_iActiveOffset,
g_iPrimaryOffset;
HookEvent("bullet_impact", Event_BulletImpact);
if ( (g_iActiveOffset = FindSendPropInfo("CCSPlayer", "m_hActiveWeapon")) == -1 )
{
PrintToServer("Failed to find CCSPlayer::m_hActiveWeapon offset");
}
if ( (g_iPrimaryOffset = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1")) == -1 )
{
PrintToServer("Failed to find CBaseCombatWeapon::m_iClip1 offset");
}
public Action:Event_BulletImpact(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_bHasUA[iClient] && iClient)
{
new iWeapon = GetEntDataEnt2(iClient, g_iActiveOffset);
if (IsValidEdict(iWeapon))
SetEntData(iWeapon, g_iPrimaryOffset, 30);
}
}
Самый простой вариант.для бесконечных патронов
new g_iActiveOffset, g_iPrimaryOffset;
public OnPluginStart()
{
if((g_iActiveOffset=FindSendPropInfo("CCSPlayer", "m_hActiveWeapon")) == -1 || (g_iPrimaryOffset=FindSendPropInfo("CBaseCombatWeapon", "m_iClip1")) == -1)
SetFailState("Failed to find '%s' offset!", g_iPrimaryOffset ? "CBaseCombatWeapon::m_iClip1":"CCSPlayer::m_hActiveWeapon");
HookEvent("bullet_impact", Event_BulletImpact);
}
public Event_BulletImpact(Handle:event, String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if(g_bHasUA[iClient] && (iClient=GetEntDataEnt2(iClient, g_iActiveOffset)) != -1) SetEntData(iClient, g_iPrimaryOffset, 30);
}
Самый простой вариант.
Уже не помню, что точно писал в своём, но и твой можно улучшить.
Варианта вроде два:Можно такое сделать? Или как-то на подобие
Варианта вроде два:
1) Создать массив для оружия, где будет расписано, сколько патронов должен устанавливать код для каждого из них.
2) Каждый раз узнавать, сколько патронов до выстрела и возвращать это значение вновь. Или вроде того.
Мог перепутать оружие и правильное количество патронов, а так работает.самый простой по твоему мнению вариант
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <sdktools_functions>
#include <shop>
#define FragColor {225,0,0,225}
#define FlashColor {255,116,0,225}
#define SmokeColor {0,225,0,225}
#define CATEGORY "stuff"
new g_iBeamSpriteIndex;
new bool:g_bCanCheckGrenades;
new bool:g_bIsActive[MAXPLAYERS+1];
new bool:g_bHasGT[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Grenade Trails",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
g_hPrice = CreateConVar("sm_shop_grenadetrails_price", "6000", "Стоимость покупки трейлов за грантами.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_grenadetrails_sellprice", "3000", "Стоимость продажи трейлов за грантами.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_grenadetrails_duration", "2592000", "Длительность трейлов за грантами в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
// Plugin reloaded ?
for(new i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
{
OnClientPostAdminCheck(i);
}
}
AutoExecConfig(true, "shop_grenadetrails", "shop");
if (Shop_IsStarted()) Shop_Started();
}
public OnConVarChange(Handle:hCvar, const String:oldValue[], const String:newValue[])
{
if(id != INVALID_ITEM)
{
if(hCvar == g_hPrice) Shop_SetItemPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hSellPrice) Shop_SetItemSellPrice(id, GetConVarInt(hCvar));
else if(hCvar == g_hDuration) Shop_SetItemValue(id, GetConVarInt(hCvar));
}
}
public OnPluginEnd() Shop_UnregisterMe();
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Дополнительно", "");
if (Shop_StartItem(category_id, "grenadetrails"))
{
Shop_SetInfo("Трейлы за грантами", "", GetConVarInt(g_hPrice), GetConVarInt(g_hSellPrice), Item_Togglable, GetConVarInt(g_hDuration));
Shop_SetCallbacks(OnItemRegistered, OnItemUsed);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) id = item_id;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasGT[iClient] = false;
return Shop_UseOff;
}
g_bHasGT[iClient] = true;
return Shop_UseOn;
}
public OnClientPostAdminCheck(iClient)
{
g_bHasGT[iClient] = false;
}
public OnMapEnd()
{
g_bCanCheckGrenades = false;
}
public OnMapStart()
{
g_bCanCheckGrenades = true;
g_iBeamSpriteIndex = PrecacheModel("materials/sprites/laserbeam.vmt");
}
public OnEntityCreated(entity, const String:classname[])
{
if(g_bCanCheckGrenades && StrContains(classname, "_projectile", false) != -1)
{
new Handle:datapack = INVALID_HANDLE;
CreateDataTimer(0.0, projectile, datapack, TIMER_FLAG_NO_MAPCHANGE);
WritePackCell(datapack, entity);
WritePackString(datapack, classname);
ResetPack(datapack);
}
}
public Action:projectile(Handle:timer, Handle:datapack, Handle:event)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_bHasGT[iClient] && iClient)
{
new entity = ReadPackCell(datapack);
new m_hThrower = GetEntPropEnt(entity, Prop_Send, "m_hThrower");
if(0 < m_hThrower <= MaxClients && g_bIsActive[m_hThrower])
{
new String:classname[30];
ReadPackString(datapack, classname, sizeof(classname));
if(StrContains(classname, "hegrenade", false) != -1) //грена
{
TE_SetupBeamFollow(entity, g_iBeamSpriteIndex, 0, Float:1.0, Float:3.0, Float:3.0, 1, FragColor);
TE_SendToAll();
}
else if(StrContains(classname, "flashbang", false) != -1) //флешка
{
TE_SetupBeamFollow(entity, g_iBeamSpriteIndex, 0, Float:1.0, Float:3.0, Float:3.0, 1, FlashColor);
TE_SendToAll();
}
else // дымовая
{
TE_SetupBeamFollow(entity, g_iBeamSpriteIndex, 0, Float:1.0, Float:3.0, Float:3.0, 1, SmokeColor);
TE_SendToAll();
}
}
}
}
Нет, можно и 0.0. Полезно, например, когда необходимо выдать сообщение игрока после введённой команды, при этом не меняя сам механизм её отлова/ввода.должно быть минимум 0.1
В таймере нет Event'ов! Вообще можно без таймера попробовать.C-подобный:public Action:projectile(Handle:timer, Handle:datapack[U], [B]Handle:event[/B][/U])