smoke96
Участник
- Сообщения
- 1,134
- Реакции
- 175
Прошу проверить код на правильность
Вот код . Это для шопа. Купил и когда стреляешь в голову то она взрывается. Компилируется без ошибок , но проверить пока нет возможности. Прошу проверить, все ли у меня правильно.
Проверил, сам нашел ошибку, я сделал всё наоборот , т.е я купил в шопе и если меня убивают то моя голова взрывается. Как исправить :?
Вот код . Это для шопа. Купил и когда стреляешь в голову то она взрывается. Компилируется без ошибок , но проверить пока нет возможности. Прошу проверить, все ли у меня правильно.
PHP:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <sdktools_functions>
#include <shop>
#define EXPLODE_SOUND "ambient/explosions/explode_8.wav"
#define CATEGORY "stuff"
new bool:g_bHasBB[MAXPLAYERS+1];
new Float:iNormal[3] = { 0.0, 0.0, 1.0 };
new g_ExplosionSprite;
new g_SmokeSprite;
new Handle:g_hPrice,
Handle:g_hSellPrice,
Handle:g_hDuration,
ItemId:id;
public Plugin:myinfo =
{
name = "[Shop] Boom Bullet",
author = "Smoke",
version = "1.0"
};
public OnPluginStart()
{
HookEvent("player_death", Boom_Head);
g_hPrice = CreateConVar("sm_shop_boombullet_price", "10000", "Стоимость покупки взрывной пули.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hSellPrice = CreateConVar("sm_shop_boombullet_sellprice", "5000", "Стоимость продажи взрывной пули.");
HookConVarChange(g_hPrice, OnConVarChange);
g_hDuration = CreateConVar("sm_shop_boombullet_duration", "2592000", "Длительность взрывной пули в секундах.");
HookConVarChange(g_hDuration, OnConVarChange);
AutoExecConfig(true, "shop_boombullet", "shop");
if (Shop_IsStarted()) Shop_Started();
}
public OnMapStart()
{
PrecacheSound(EXPLODE_SOUND, true);
g_ExplosionSprite = PrecacheModel("sprites/blueglow2.vmt");
g_SmokeSprite = PrecacheModel("sprites/steam1.vmt");
}
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, "boombullet"))
{
Shop_SetInfo("Взрывная пуля [HS]", "", 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_bHasBB[iClient] = false;
return Shop_UseOff;
}
g_bHasBB[iClient] = true;
return Shop_UseOn;
}
public OnClientPostAdminCheck(iClient)
{
g_bHasBB[iClient] = false;
}
public Action:Boom_Head(Handle:event, const String:name[], bool:dontBroadcast)
{
new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
if(g_bHasBB[iClient] && iClient)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
if(victim == attacker)
{
return Plugin_Handled;
}
new Float:iVec[3];
GetClientAbsOrigin(victim, Float:iVec);
if(GetEventBool(event, "headshot"))
{
TE_SetupExplosion(iVec, g_ExplosionSprite, 5.0, 1, 0, 50, 40, iNormal);
TE_SendToAll();
TE_SetupSmoke(iVec, g_SmokeSprite, 10.0, 3);
TE_SendToAll();
EmitAmbientSound(EXPLODE_SOUND, iVec, victim, SNDLEVEL_NORMAL);
}
}
return Plugin_Continue;
}
Последнее редактирование модератором: