Primo, ! и / например.
R1KO, а в чем нюанс всё-таки? Я просто чутка не понимаю... Ему надо !st.
B1g, пример привести можешь?
B1g, таймер.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <shop>
#define PLUGIN_VERSION "2.1.0"
#define CATEGORY "ability"
#define ITEM "speed"
new Float:g_fSpeed,
g_iPrice,
g_iSellPrice,
g_iDuration,
ItemId:id;
new bool:g_bHasSpeed[MAXPLAYERS+1];
public Plugin:myinfo =
{
name = "[Shop] Speed",
author = "FrozDark (HLModders LLC)",
description = "Speed ability",
version = PLUGIN_VERSION,
url = "http://www.hlmod.ru/"
};
public OnPluginStart()
{
new Handle:hCvar;
HookConVarChange((hCvar = CreateConVar("sm_shop_speed_amount", "1.2", "Множитель скорости (1.0 - Нормальная)", 0, true, 0.1)), OnSpeedChange);
g_fSpeed = GetConVarFloat(hCvar);
HookConVarChange((hCvar = CreateConVar("sm_shop_speed_price", "1000", "Цена покупки скорости.")), OnPriceChange);
g_iPrice = GetConVarInt(hCvar);
HookConVarChange((hCvar = CreateConVar("sm_shop_speed_sellprice", "800", "Цена продажи скорости.")), OnSellPriceChange);
g_iSellPrice = GetConVarInt(hCvar);
HookConVarChange((hCvar = CreateConVar("sm_shop_speed_duration", "86400", "Длительность скорости в секундах.")), OnDurationChange);
g_iDuration = GetConVarInt(hCvar);
CloseHandle(hCvar);
AutoExecConfig(true, "shop_speed", "shop");
HookEvent("player_spawn", PlayerSpawn);
if (Shop_IsStarted()) Shop_Started();
}
public OnSpeedChange(Handle:hCvar, const String:sOld[], const String:sNew[]) g_fSpeed = GetConVarFloat(hCvar);
public OnPriceChange(Handle:hCvar, const String:sOld[], const String:sNew[])
{
g_iPrice = GetConVarInt(hCvar);
if(id != INVALID_ITEM)
{
Shop_SetItemPrice(id, g_iPrice);
}
}
public OnSellPriceChange(Handle:hCvar, const String:sOld[], const String:sNew[])
{
g_iSellPrice = GetConVarInt(hCvar);
if(id != INVALID_ITEM)
{
Shop_SetItemSellPrice(id, g_iSellPrice);
}
}
public OnDurationChange(Handle:hCvar, const String:sOld[], const String:sNew[])
{
g_iDuration = GetConVarInt(hCvar);
if(id != INVALID_ITEM)
{
Shop_SetItemValue(id, g_iDuration);
}
}
public OnPluginEnd() Shop_UnregisterMe();
public OnClientDisconnect_Post(iClient) g_bHasSpeed[iClient] = false;
public Shop_Started()
{
new CategoryId:category_id = Shop_RegisterCategory(CATEGORY, "Способности", "");
if (Shop_StartItem(category_id, ITEM))
{
Shop_SetInfo("Скорость", "", g_iPrice, g_iSellPrice, Item_Togglable, g_iDuration);
Shop_SetCallbacks(OnItemRegistered, OnItemUsed, _, OnDisplay);
Shop_EndItem();
}
}
public OnItemRegistered(CategoryId:category_id, const String:category[], const String:item[], ItemId:item_id) id = item_id;
public bool:OnDisplay(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], ShopMenu:menu, &bool:disabled, const String:name[], String:buffer[], maxlen)
{
FormatEx(buffer, maxlen, "Скорость: %.1fx", g_fSpeed);
if (g_bHasSpeed[iClient])
{
disabled = true;
return true;
}
return true;
}
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasSpeed[iClient] = false;
SetEntPropFloat(iClient, Prop_Data, "m_flLaggedMovementValue", 1.0);
return Shop_UseOff;
}
g_bHasSpeed[iClient] = true;
SetEntPropFloat(iClient, Prop_Data, "m_flLaggedMovementValue", g_fSpeed);
return Shop_UseOn;
}
public PlayerSpawn(Handle:event,const String:name[],bool:dontBroadcast)
{
CreateTimer(0.1, SetSpeed, GetEventInt(event, "userid"));
}
public Action:SetSpeed(Handle:timer, any:UserId)
{
new iClient = GetClientOfUserId(UserId);
if(iClient && IsClientInGame(iClient) && IsPlayerAlive(iClient))
{
SetEntPropFloat(iClient, Prop_Data, "m_flLaggedMovementValue", (g_bHasSpeed[iClient]) ? g_fSpeed:1.0);
}
return Plugin_Stop;
}
public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
static iPrevButtons[MAXPLAYERS+1];
if (g_bHasFL[iClient] && (buttons & IN_USE) && !(iPrevButtons[iClient] & IN_USE))
{
if (g_bHasFL[iClient] && OnButtonUsePress(iClient) != Plugin_Continue)
{
buttons &= ~IN_USE;
}
}
else if (!(buttons & IN_USE) && (iPrevButtons[iClient] & IN_USE))
{
OnButtonUseReleased(iClient);
}
iPrevButtons[iClient] = buttons;
return Plugin_Continue;
}
Action:OnButtonUsePress(iClient)
{
if (g_bHasFL[iClient] && IsPlayerAlive(iClient))
{
if (GetEntityMoveType(iClient) == MOVETYPE_FLY) SetEntityMoveType(iClient, MOVETYPE_WALK);
else if (!(GetEntityFlags(iClient) & FL_ONGROUND)) SetEntityMoveType(iClient, MOVETYPE_FLY);
}
return Plugin_Continue;
}
OnButtonUseReleased(iClient)
{
{
SetEntityMoveType(iClient, MOVETYPE_WALK);
}
}
public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
static iPrevButtons[MAXPLAYERS+1];
if (g_bHasFL[iClient] && IsPlayerAlive(iClient))
if ((buttons & IN_USE) && !(iPrevButtons[iClient] & IN_USE))
{
if (OnButtonUsePress(iClient) != Plugin_Continue)
{
buttons &= ~IN_USE;
}
}
else if (!(buttons & IN_USE) && (iPrevButtons[iClient] & IN_USE))
{
OnButtonUseReleased(iClient);
}
iPrevButtons[iClient] = buttons;
return Plugin_Continue;
}
Также:с этим
else CreateTimer(0.1, MessageInvalid, iClient, TIMER_FLAG_NO_MAPCHANGE);
public Action:MessageInvalid(Handle:timer, any:iClient)
{
if (IsClientInGame(iClient)) PrintToChat(iClient,"\x01\04[Swap Team] \x01Вы не купили данную возможность в \x03!shop \x01:)");
return Plugin_Stop;
}
public Action:Command_St(iClient, args)
{
if (iClient) CreateTimer(0.0, SwapTeam, iClient, TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Handled;
}
public Action:SwapTeam(Handle:timer, any:iClient)
{
if(IsClientInGame(iClient))
{
if(g_bHasSP[iClient])
{
if(IsPlayerAlive(iClient)) ForcePlayerSuicide(iClient);
switch (GetClientTeam(iClient))
{
case CS_TEAM_T:
{
CS_SwitchTeam(iClient, CS_TEAM_CT);
PrintToChat(iClient,"\x01\04[Swap Team] \x01Вы сменили команду! \x03[T > CT]");
}
case CS_TEAM_CT:
{
CS_SwitchTeam(iClient, CS_TEAM_T);
PrintToChat(iClient,"\x01\04[Swap Team] \x01Вы сменили команду! \x03[CT > T]");
}
}
}
else PrintToChat(iClient,"\x01\04[Swap Team] \x01Вы не купили данную возможность в \x03!shop \x01:)");
}
return Plugin_Stop;
}
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <shop>
#define CATEGORY "stuff"
new bool:g_bHasFR[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Fast Weapon Reload",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
g_hPrice = CreateConVar("sm_shop_fastreload_price", "5000", "Стоимость покупки быстрой перезарядки.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_fastreload_sellprice", "5000", "Стоимость продажи быстрой перезарядки.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_fastreload_duration", "2592000", "Длительность быстрой перезарядки в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_fastreload", "shop");
HookEvent("weapon_reload", weapon_reload);
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, "Stuff", "");
if (Shop_StartItem(category_id, "fastreload"))
{
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 OnClientPostAdminCheck(iClient) g_bHasFR[iClient] = false;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasFR[iClient] = false;
return Shop_UseOff;
}
g_bHasFR[iClient] = true;
return Shop_UseOn;
}
public Action:weapon_reload(Handle:event, const String:name[], bool:silent, iClient, args)
{
if (g_bHasFR[iClient])
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (GetPlayerWeaponSlot(iClient, 2) > 0)
{
SetEntPropFloat(iClient, Prop_Send, "m_flNextAttack", GetGameTime());
ClientCommand(iClient, "lastinv");
CreateTimer(0.01, LastInv_Timer, iClient, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action:LastInv_Timer(Handle:timer, any:iClient)
{
if (IsClientInGame(iClient)) ClientCommand(iClient, "lastinv");
return Plugin_Stop;
}
Сначала создай и получи iClient, а уже после делай проверки:PHP:public Action:weapon_reload(Handle:event, const String:name[], bool:silent, iClient, args) { if (g_bHasFR[iClient]) { new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
public Action:weapon_reload(Handle:event, const String:name[], bool:silent)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_bHasFR[iClient])
{
//Код.
}
}
#include <sdktools_functions>
#include <shop>
#define CATEGORY "stuff"
new ItemId:id, bool:g_bHasFR[MAXPLAYERS+1], g_iPrice, g_iSellPrice, g_iDuration;
public Plugin:myinfo =
{
name = "[Shop] Fast Weapon Reload",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
if(Shop_IsStarted())
{
HookEvent("weapon_reload", weapon_reload);
decl Handle:h;
HookConVarChange(h = CreateConVar("sm_shop_fastreload_price", "5000", "Стоимость покупки быстрой перезарядки.",_, true, 0.0), ChangeItemPrice);
g_iPrice = GetConVarInt(h);
HookConVarChange(h = CreateConVar("sm_shop_fastreload_sellprice", "5000", "Стоимость продажи быстрой перезарядки.",_, true, 0.0), ChangeSellPrice);
g_iSellPrice = GetConVarInt(h);
HookConVarChange(h = CreateConVar("sm_shop_fastreload_duration", "2592000", "Длительность быстрой перезарядки, сек.",_, true, 0.0), ChangeItemValue);
g_iDuration = GetConVarInt(h);
AutoExecConfig(true, "shop_fastreload", "shop");
Shop_Started();
}
}
public OnPluginEnd() Shop_UnregisterMe();
public ChangeItemPrice(Handle:hCvar, String:oldValue[], String:newValue[])
{
g_iPrice = GetConVarInt(hCvar);
if(id != INVALID_ITEM) Shop_SetItemPrice(id, g_iPrice);
}
public ChangeSellPrice(Handle:hCvar, String:oldValue[], String:newValue[])
{
g_iSellPrice = GetConVarInt(hCvar);
if(id != INVALID_ITEM) Shop_SetItemSellPrice(id, g_iSellPrice);
}
public ChangeItemValue(Handle:hCvar, String:oldValue[], String:newValue[])
{
g_iDuration = GetConVarInt(hCvar);
if(id != INVALID_ITEM) Shop_SetItemValue(id, g_iDuration);
}
public Shop_Started()
{
if(Shop_StartItem(Shop_RegisterCategory(CATEGORY, "Stuff", ""), "fastreload"))
{
Shop_SetInfo("Быстрая перезарядка", "", g_iPrice, g_iSellPrice, Item_Togglable, g_iDuration);
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_bHasFR[iClient] = false;
return Shop_UseOff;
}
g_bHasFR[iClient] = true;
return Shop_UseOn;
}
public OnClientDisconnect_Post(iClient) g_bHasFR[iClient] = false;
public weapon_reload(Handle:event, String:name[], bool:silent)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_bHasFR[iClient] && GetPlayerWeaponSlot(iClient, 2) !=-1)
{
SetEntPropFloat(iClient, Prop_Send, "m_flNextAttack", GetGameTime());
ClientCommand(iClient, "lastinv");
CreateTimer(0.05, LastInv_Timer, iClient, TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action:LastInv_Timer(Handle:timer, any:iClient)
{
if (IsClientInGame(iClient)) ClientCommand(iClient, "lastinv");
return Plugin_Stop;
}
Вот так вот сделал. С твоим исправлением:Полный вариант, что я дал или просто с исправлениями?
К HookEvent("weapon_reload", weapon_reload); добавь ниже HookEvent("weapon_fire_on_empty", weapon_reload);
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_functions>
#include <shop>
#define CATEGORY "stuff"
new bool:g_bHasFR[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Fast Weapon Reload",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
HookEvent("weapon_reload", weapon_reload);
g_hPrice = CreateConVar("sm_shop_fastreload_price", "5000", "Стоимость покупки быстрой перезарядки.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_fastreload_sellprice", "2500", "Стоимость продажи быстрой перезарядки.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_fastreload_duration", "2592000", "Длительность быстрой перезарядки в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_fastreload", "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, "Stuff", "");
if (Shop_StartItem(category_id, "fastreload"))
{
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_bHasFR[iClient] = false;
return Shop_UseOff;
}
g_bHasFR[iClient] = true;
return Shop_UseOn;
}
public OnClientPostAdminCheck(iClient)
{
g_bHasFR[iClient] = false;
}
public Action:weapon_reload(Handle:event, const String:name[], bool:silent)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_bHasFR[iClient])
{
if (GetPlayerWeaponSlot(iClient, 2) > 0)
{
SetEntPropFloat(iClient, Prop_Send, "m_flNextAttack", GetGameTime());
ClientCommand(iClient, "lastinv");
CreateTimer(0.01, LastInv_Timer, iClient, TIMER_FLAG_NO_MAPCHANGE);
}
}
}
public Action:LastInv_Timer(Handle:timer, any:iClient)
{
if (IsClientInGame(iClient)) ClientCommand(iClient, "lastinv");
return Plugin_Stop;
}
А ему нечего выкладывать - ничего не работает, либо с багами, пока полностью не распишешь, как надо. ОффтопЗа него. А подпишется собой)Обязательно if (g_bHasFR[iClient] && iClient), иначе ошибки в логах со временем появятся.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <shop>
new bool:g_bHasFL[MAXPLAYERS+1];
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Fly",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
g_hPrice = CreateConVar("sm_shop_fly_price", "10000", "Стоимость покупки полёта.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_fly_sellprice", "5000", "Стоимость продажи полёта.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_fly_duration", "2592000", "Длительность полёта в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_fly", "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("ability", "Способности", "");
if (Shop_StartItem(category_id, "fly"))
{
Shop_SetInfo("Полёт [E]", "", 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 OnClientPostAdminCheck(iClient) g_bHasFL[iClient] = false;
public ShopAction:OnItemUsed(iClient, CategoryId:category_id, const String:category[], ItemId:item_id, const String:item[], bool:isOn, bool:elapsed)
{
if (isOn || elapsed)
{
g_bHasFL[iClient] = false;
return Shop_UseOff;
}
g_bHasFL[iClient] = true;
return Shop_UseOn;
}
public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
if (g_bHasFL[iClient] && iClient)
{
static bool:UseTriggered[MAXPLAYERS] = {false, ...};
if (!IsPlayerAlive(iClient) || GetEntityMoveType(iClient) == MOVETYPE_LADDER)
{
UseTriggered[iClient] = false;
if (GetEntityMoveType(iClient) == MOVETYPE_FLY) SetEntityMoveType(iClient, MOVETYPE_WALK);
return Plugin_Continue;
}
else if (buttons & IN_USE)
{
new MoveType:mtype = GetEntityMoveType(iClient);
if (GetEntPropEnt(iClient, Prop_Send, "m_hGroundEntity") == 0)
SetEntityMoveType(iClient, MOVETYPE_WALK);
else if (mtype == MOVETYPE_WALK || mtype == MOVETYPE_FLY)
{
if (!UseTriggered[iClient]) {
UseTriggered[iClient] = true;
SetEntityMoveType(iClient, MOVETYPE_FLY);
}
}
}
else if (UseTriggered[iClient])
{
UseTriggered[iClient] = false;
SetEntityMoveType(iClient, MOVETYPE_WALK);
}
}
return Plugin_Continue;
}
#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
public OnPluginStart()
{
for (new i = 1; i <= MaxClients; i++)
{
if (IsValidEntity(i) && IsClientInGame(i)) OnClientPutInServer(i);
}
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
return damagetype & DMG_FALL ? Plugin_Handled : Plugin_Continue;
}
Добавил , скомпилировал , залил на сервер. перезапустил плагин на сервере командой sm plugins reload , не заработало , карту сменил , не заработало , сервер пока перезапустить не смогу людей много.К HookEvent("weapon_reload", weapon_reload); добавь ниже: HookEvent("weapon_fire_on_empty", weapon_reload);