Здравствуй.
а можешь добавить vip ws в подарки (от10до30мин).
Оффтоп
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <cstrike>
#include <morecolors>
public Plugin:myinfo =
{
name = "Happy New Year",
author = "Danyas",
description = "",
version = "2k17.b1",
url = ""
}
static const String: sDownloadTable[][] =
{
"models/logandougall/cel/cel_xmas_snowball_16.dx80.vtx",
"models/logandougall/cel/cel_xmas_snowball_16.dx90.vtx",
"models/logandougall/cel/cel_xmas_snowball_16.mdl",
"models/logandougall/cel/cel_xmas_snowball_16.phy",
"models/logandougall/cel/cel_xmas_snowball_16.sw.vtx",
"models/logandougall/cel/cel_xmas_snowball_16.vvd",
"materials/models/logandougall/cel/snow.vmt",
"materials/models/logandougall/cel/snow.vtf",
"models/models_kit/xmas/xmastree.dx80.vtx",
"models/models_kit/xmas/xmastree.dx90.vtx",
"models/models_kit/xmas/xmastree.mdl",
"models/models_kit/xmas/xmastree.phy",
"models/models_kit/xmas/xmastree.sw.vtx",
"models/models_kit/xmas/xmastree.vvd",
"models/models_kit/xmas/xmastree.xbox.vtx",
"models/logandougall/cel/cel_xmas_snowman.dx80.vtx",
"models/logandougall/cel/cel_xmas_snowman.dx90.vtx",
"models/logandougall/cel/cel_xmas_snowman.mdl",
"models/logandougall/cel/cel_xmas_snowman.phy",
"models/logandougall/cel/cel_xmas_snowman.sw.vtx",
"models/logandougall/cel/cel_xmas_snowman.vvd",
"materials/models/logandougall/cel/carrot.vtf",
"materials/models/logandougall/cel/carrot.vmt",
"materials/models/logandougall/cel/toolsblack.vmt",
"materials/models/logandougall/cel/bark.vmt",
"materials/models/logandougall/cel/bark.vtf",
"materials/models/logandougall/cel/snow.vmt",
"materials/models/logandougall/cel/snow.vtf",
"models/models_kit/xmas/giftbox_mini_quad.dx80.vtx",
"models/models_kit/xmas/giftbox_mini_quad.dx90.vtx",
"models/models_kit/xmas/giftbox_mini_quad.mdl",
"models/models_kit/xmas/giftbox_mini_quad.phy",
"models/models_kit/xmas/giftbox_mini_quad.sw.vtx",
"models/models_kit/xmas/giftbox_mini_quad.vvd",
"models/models_kit/xmas/giftbox_mini_quad.xbox.vtx",
"materials/models/models_kit/xmas/giftbox.vmt",
"materials/models/models_kit/xmas/giftbox.vtf",
"models/models_kit/xmas/xmastree_mini.dx80.vtx",
"models/models_kit/xmas/xmastree_mini.dx90.vtx",
"models/models_kit/xmas/xmastree_mini.mdl",
"models/models_kit/xmas/xmastree_mini.phy",
"models/models_kit/xmas/xmastree_mini.sw.vtx",
"models/models_kit/xmas/xmastree_mini.vvd",
"models/models_kit/xmas/xmastree_mini.xbox.vtx",
"materials/models/models_kit/xmas/xmastree_miscA.vmt",
"materials/models/models_kit/xmas/xmastree_miscA.vtf",
"materials/models/models_kit/xmas/xmastree_miscA_skin2.vmt",
"materials/models/models_kit/xmas/xmastree_miscA_skin2.vtf",
"materials/models/models_kit/xmas/xmastree_miscB.vmt",
"materials/models/models_kit/xmas/xmastree_miscB.vtf",
"materials/models/models_kit/xmas/xmastree_miscB_skin2.vmt",
"materials/models/models_kit/xmas/xmastree_miscB_skin2.vtf",
"materials/models/models_kit/xmas/xmastree_miscB_spec.vtf"
}
static const String: sApt_text[][] =
{
"маленькая аптечка",
"средняя аптечка",
"большая аптечка"
};
static const sAptMin[] = { 5, 10, 25};
static const sAptMax[] = {10, 20, 50};
new m_iHealth;
new m_iAccount;
new bool:g_bActive, g_iAnswer, String:g_sFile[64], g_iAvailableSnow[64];
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
HookEvent("round_start", Event_RoundStart);
m_iAccount = UTIL_FindSendPropOffs("CCSPlayer", "m_iAccount");
m_iHealth = UTIL_FindSendPropOffs("CCSPlayer", "m_iHealth");
RegAdminCmd("sm_gift", GiftMe, ADMFLAG_ROOT);
RegAdminCmd("sm_tree", CreateTree, ADMFLAG_ROOT);
RegAdminCmd("sm_del", DeleteTree, ADMFLAG_ROOT);
RegAdminCmd("sm_snowman", CreateSnowman, ADMFLAG_ROOT);
RegAdminCmd("sm_large", CreateLarge, ADMFLAG_ROOT);
RegConsoleCmd("sm_snow", Snow);
CreateTimer(60.0, Question, _, TIMER_REPEAT);
}
public OnMapStart()
{
for(new i; i < sizeof(sDownloadTable); i++)
{
AddFileToDownloadsTable(sDownloadTable);
}
PrecacheModel("sprites/glow01.spr", true);
PrecacheModel("models/models_kit/xmas/giftbox_mini_quad.mdl", true);
PrecacheModel("models/models_kit/xmas/xmastree_mini.mdl", true);
PrecacheModel("models/logandougall/cel/cel_xmas_snowman.mdl", true);
PrecacheModel("models/models_kit/xmas/xmas_teddybear.mdl", true);
PrecacheModel("models/models_kit/xmas/xmastree.mdl", true);
PrecacheModel("models/logandougall/cel/cel_xmas_snowball_16.mdl", true);
decl String: g_sCurrentMap[32];
GetCurrentMap(g_sCurrentMap, sizeof(g_sCurrentMap));
if(!DirExists("addons/sourcemod/configs/newyear/"))
{
CreateDirectory("addons/sourcemod/configs/newyear/", 511);
}
FormatEx(g_sFile, sizeof(g_sFile), "addons/sourcemod/configs/newyear/%s.cfg", g_sCurrentMap);
}
public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
{
if(g_bActive && StringToInt(sArgs) == g_iAnswer)
{
CreateTimer(1.0, Gift, GetClientUserId(client));
CPrintToChat(client, "{fullred}NY {darkgrey}| {white}Вы первым успешно ответили на вопрос{darkgrey}! {white}Подарок около Вас{darkgrey}!");
g_bActive = false;
}
}
public Action:Question(Handle:timer)
{
CreateTimer(20.0, Timer_QuestionTimeLeft);
new a = GetRandomInt(50, 250);
new b = GetRandomInt(1, 50);
new op = GetRandomInt(0,1);
g_bActive = true;
if (op)
{
g_iAnswer = a + b;
CPrintToChatAll("{fullred}Дед Мороз{darkgrey}: {fullblue}Хо{darkgrey}-{fullblue}Хо{darkgrey}-{fullblue}Хо{darkgrey}! {white}Сколько будет {aqua}%i {darkgrey}+ {aqua}%i{darkgrey}?", a , b);
}
else
{
g_iAnswer = a - b;
CPrintToChatAll("{fullred}Дед Мороз{darkgrey}: {fullblue}Хо{darkgrey}-{fullblue}Хо{darkgrey}-{fullblue}Хо{darkgrey}! {white}Сколько будет {aqua}%i {darkgrey}- {aqua}%i{darkgrey}?", a , b);
}
return Plugin_Continue;
}
public Action:Timer_QuestionTimeLeft(Handle:timer)
{
g_bActive = false;
}
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsClientInGame(client))
{
CreateTimer(2.0, Gift, GetClientUserId(client));
}
}
public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
new Handle:kv = CreateKeyValues("tree");
if (FileToKeyValues(kv, g_sFile) && KvGotoFirstSubKey(kv))
{
decl String:KeyName[50];
do
{
if (KvGetSectionName(kv, KeyName, 50))
{
decl Float:g_fOrigin[3], Float:g_fAngles[3], String:type[20];
KvGetVector(kv, "1", g_fOrigin);
KvGetVector(kv, "2", g_fAngles);
KvGetString(kv, "type", type, sizeof(type));
if (StrEqual(type, "tree") || StrEqual(type, ""))
{
SpawnTree(g_fOrigin, g_fAngles);
new w_color[4] = { 0, 0, 0, 255 };
decl String: color[20], Float: Ori[3];
g_fOrigin[2] += 10;
for (new i = 1; i<= 10; i++)
{
for (new q = 0; q < 3; q++) w_color[q] = GetRandomInt(10, 255);
for (new a = 0; a < 3; a++) Ori[a] = g_fOrigin[a]
FormatEx(color, sizeof(color), "%i %i %i", w_color[0], w_color[1], w_color[2]);
new index = CreateEntityByName("env_sprite");
DispatchKeyValue(index, "rendermode", "5");
DispatchKeyValue(index, "rendercolor", color);
DispatchKeyValue(index, "renderamt", "255");
DispatchKeyValue(index, "scale", "0.6");
DispatchKeyValue(index, "model", "sprites/glow01.spr");
DispatchSpawn(index);
AcceptEntityInput(index, "ShowSprite");
new Float:crd;
switch(i)
{
case 1: crd = 27.0;
case 2: crd = -27.0;
case 3: crd = 22.0;
case 4: crd = -22.0;
case 5: crd = 17.0;
case 6: crd = -17.0;
case 7: crd = 12.0;
case 8: crd = -12.0;
case 9: crd = 7.0;
case 10: crd = -7.0;
}
Ori[2] += 10*i;
Ori[0] += crd;
Ori[1] += crd;
TeleportEntity(index, Ori, g_fAngles, NULL_VECTOR);
}
}
if (StrEqual(type, "snowman"))
{
SpawnSnowMan(g_fOrigin, g_fAngles);
}
if (StrEqual(type, "large"))
{
SpawnLarge(g_fOrigin, g_fAngles);
}
}
}
while (KvGotoNextKey(kv));
}
CloseHandle(kv);
}
public Action:Gift(Handle:timer, any:userid)
{
new i = GetClientOfUserId(userid);
if (i && IsClientInGame(i))
{
new iEntity = CreateEntityByName("prop_dynamic");
if (iEntity)
{
decl Float:fPos[3], String:clr[20];
new String:sTargetName[32],
String:sBufer[70],
Float:fTime = 10.0;
GetClientAbsOrigin(i, fPos);
fPos[0] += 50.0;
if (!IsPlayerAlive(i))
{
fPos[2] -= 40.0;
}
Format(sTargetName, sizeof(sTargetName), "xmasgift_%i", iEntity);
DispatchKeyValueVector(iEntity, "origin", fPos);
DispatchKeyValue(iEntity, "solid", "6");
DispatchKeyValue(iEntity, "model", "models/models_kit/xmas/giftbox_mini_quad.mdl");
DispatchKeyValue(iEntity, "targetname", sTargetName);
SetVariantString(sTargetName);
DispatchSpawn(iEntity);
SetEntProp(iEntity, Prop_Send, "m_usSolidFlags", 8);
SetEntProp(iEntity, Prop_Send, "m_CollisionGroup", 1);
Format(sBufer, sizeof(sBufer), "OnUser1 !self:kill::%0.2f:-1", fTime);
SetVariantString(sBufer);
AcceptEntityInput(iEntity, "AddOutput");
AcceptEntityInput(iEntity, "FireUser1");
new iRotating = CreateEntityByName("func_rotating", -1);
DispatchKeyValueVector(iRotating, "origin", fPos);
DispatchKeyValue(iRotating, "targetname", sTargetName);
DispatchKeyValue(iRotating, "maxspeed", "180");
DispatchKeyValue(iRotating, "friction", "0");
DispatchKeyValue(iRotating, "dmg", "0");
DispatchKeyValue(iRotating, "solid", "0");
DispatchKeyValue(iRotating, "spawnflags", "64");
DispatchSpawn(iRotating);
SetVariantString("!activator");
AcceptEntityInput(iEntity, "SetParent", iRotating, iRotating);
AcceptEntityInput(iRotating, "Start", -1, -1);
SetEntProp(iRotating, Prop_Send, "m_CollisionGroup", 1);
Format(sBufer, sizeof(sBufer), "OnUser1 !self:kill::%0.2f:-1", fTime);
SetVariantString(sBufer);
AcceptEntityInput(iRotating, "AddOutput");
AcceptEntityInput(iRotating, "FireUser1");
SetEntPropEnt(iEntity, Prop_Send, "m_hEffectEntity", iRotating);
Format(clr, sizeof(clr), "%i %i %i", GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255));
new index5 = CreateEntityByName("env_sprite");
DispatchKeyValue(index5, "rendermode", "5");
DispatchKeyValue(index5, "rendercolor", String:clr);
DispatchKeyValue(index5, "renderamt", "255");
DispatchKeyValue(index5, "scale", "1");
DispatchKeyValue(index5, "model", "sprites/glow01.spr");
DispatchKeyValueVector(index5, "origin", fPos);
DispatchSpawn(index5);
SetVariantString("!activator");
AcceptEntityInput(index5, "SetParent", iEntity);
SDKHook(iEntity, SDKHook_StartTouch, Hook_GiftStartTouch);
}
}
return Plugin_Stop;
}
public Hook_GiftStartTouch(iEntity, activator)
{
if (activator > 0 && activator <= MaxClients)
{
switch (GetRandomInt(1,5))
{
case 1:
{
new iMoney;
if(GetRandomInt(0,1))
{
new randommoney = GetRandomInt(100, 5000);
iMoney = GetEntData(activator, m_iAccount) + randommoney;
SetEntData(activator, m_iAccount, iMoney);
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}В подарке оказались деньги {darkgrey}- {fullblue}$%i", randommoney);
}
else
{
new randommoney = GetRandomInt(0, 500);
iMoney = GetEntData(activator, m_iAccount) - randommoney;
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}В подарке оказался {lime}Гринч{darkgrey}, {white}который отжал {fullblue}$%i", randommoney);
}
SetEntData(activator, m_iAccount, iMoney);
}
case 2:
{
if(GetRandomInt(0,1))
{
SetEntProp(activator, Prop_Data, "m_iFrags", GetClientFrags(activator) + 2);
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}Подарок прибавил {fullblue}2 {white}фрага");
}
else
{
SetEntProp(activator, Prop_Data, "m_iDeaths", GetClientDeaths(activator) - 2);
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}Подарок снял {fullblue}2 {white}смерти");
}
}
case 3:
{
new r = GetRandomInt(0,2);
SetEntData(activator, m_iHealth, GetEntData(activator, m_iHealth) + GetRandomInt(sAptMin[r], sAptMax[r]));
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}В Подарке оказалась {fullblue}%s", sApt_text[r]);
}
default:
{
CPrintToChat(activator,"{fullred}NY {darkgrey}| {white}К сожалению{darkgrey}, {white}подарок сп*здил {lime}Гринч {white}:D");
}
}
}
if(IsValidEdict(iEntity))
{
new iRotating = GetEntPropEnt(iEntity, Prop_Send, "m_hEffectEntity");
if(iRotating && IsValidEdict(iRotating))
{
AcceptEntityInput(iRotating, "Kill");
}
AcceptEntityInput(iEntity, "Kill");
}
}
public Action:GiftMe(client, args)
{
CreateTimer(0.1, Gift, GetClientUserId(client));
return Plugin_Handled;
}
public Action:CreateTree(client, args)
{
CreateSomethink(client, "tree");
return Plugin_Handled;
}
public Action:CreateLarge(client, args)
{
CreateSomethink(client, "large");
return Plugin_Handled;
}
public Action:CreateSnowman(client, args)
{
CreateSomethink(client, "snowman");
return Plugin_Handled;
}
public bool:Trace_FilterPlayers(entity, contentsMask, any:data){
if(entity != data && entity > MaxClients)
return true;
return false;
}
CreateSomethink(client, const String: sType[])
{
decl Float:g_fOrigin[3], Float:g_fAngles[3];
GetClientEyePosition(client, g_fOrigin);
GetClientEyeAngles(client, g_fAngles);
TR_TraceRayFilter(g_fOrigin, g_fAngles, MASK_SOLID, RayType_Infinite, Trace_FilterPlayers, client);
if(TR_DidHit(INVALID_HANDLE))
{
TR_GetEndPosition(g_fOrigin, INVALID_HANDLE);
TR_GetPlaneNormal(INVALID_HANDLE, g_fAngles);
GetVectorAngles(g_fAngles, g_fAngles);
g_fAngles[0] += 90.0;
switch(sType[0])
{
case 't': SpawnTree(g_fOrigin, g_fAngles);
case 'l': SpawnLarge(g_fOrigin, g_fAngles);
case 's': SpawnSnowMan(g_fOrigin, g_fAngles);
}
new Handle:kv = CreateKeyValues("tree");
FileToKeyValues(kv, g_sFile);
decl String:info[60];
FormatEx(info, sizeof(info), "%f,%f",g_fOrigin[0], g_fOrigin[1]);
KvJumpToKey(kv, info, true);
KvSetVector(kv, "1", g_fOrigin);
KvSetVector(kv, "2", g_fAngles);
KvSetString(kv, "type", sType);
KvRewind(kv);
KeyValuesToFile(kv, g_sFile);
CloseHandle(kv);
}
}
SpawnTree(const Float:g_fOrigin[3], const Float:g_fAngles[3])
{
new index = CreateEntityByName("prop_dynamic");
DispatchKeyValue(index, "model", "models/models_kit/xmas/xmastree_mini.mdl");
DispatchKeyValue(index, "Solid", "6");
DispatchSpawn(index);
TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
SetEntityMoveType(index, MOVETYPE_VPHYSICS);
}
SpawnLarge(const Float:g_fOrigin[3], const Float:g_fAngles[3])
{
new index = CreateEntityByName("prop_dynamic_override");
if (index == -1) return;
DispatchKeyValue(index, "model", "models/models_kit/xmas/xmastree.mdl");
DispatchKeyValue(index, "Solid", "6");
DispatchSpawn(index);
TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
SetEntityMoveType(index, MOVETYPE_VPHYSICS);
}
SpawnSnowMan(const Float:g_fOrigin[3], const Float:g_fAngles[3])
{
new index = CreateEntityByName("prop_dynamic");
DispatchKeyValue(index, "model", "models/logandougall/cel/cel_xmas_snowman.mdl");
DispatchKeyValue(index, "Solid", "6");
DispatchSpawn(index);
TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
SetEntityMoveType(index, MOVETYPE_VPHYSICS);
}
public Action:DeleteTree(client, args)
{
new index = GetClientAimTarget(client, false);
if (index == -1) return Plugin_Handled;
decl Float:vec[3]; decl String:coord[15]; decl String:coord1[15], String:buf3[2][25], String:buf4[2][25];
GetEntPropVector(index, Prop_Data, "m_vecAbsOrigin", vec);
FloatToString(vec[0], coord, sizeof(coord));
FloatToString(vec[1], coord1, sizeof(coord1));
ExplodeString(coord, ".", buf3, 2, 25);
ExplodeString(coord1, ".", buf4, 2, 25);
new Handle:kv = CreateKeyValues("tree");
if (FileToKeyValues(kv, g_sFile) && KvGotoFirstSubKey(kv))
{
decl String:KeyName[35];
do
{
if (KvGetSectionName(kv, KeyName, 35))
{
decl String:buf[2][25],String:buf1[2][25],String:buf2[2][25];
ExplodeString(String:KeyName, ",", String:buf, 2, 25);
ExplodeString(String:buf[0], ".", String:buf1, 2, 25);
ExplodeString(String:buf[1], ".", String:buf2, 2, 25);
if (StrEqual(buf1[0], buf3[0]) && StrEqual(buf2[0], buf4[0]))
{
AcceptEntityInput(index, "Kill");
KvDeleteThis(kv);
KvRewind(kv);
KeyValuesToFile(kv, g_sFile);
}
}
}
while (KvGotoNextKey(kv));
}
CloseHandle(kv);
return Plugin_Handled;
}
public Action:Snow(client, args)
{
if (GetClientTeam(client) > 1 && IsPlayerAlive(client))
{
new time = GetTime();
if (time > g_iAvailableSnow[client])
{
g_iAvailableSnow[client] = time + 10;
decl Float:clienteyeangle[3], Float:anglevector[3], Float:clienteyeposition[3], Float:resultposition[3];
GetClientEyeAngles(client, clienteyeangle);
GetClientEyePosition(client, clienteyeposition);
GetAngleVectors(clienteyeangle, anglevector, NULL_VECTOR, NULL_VECTOR);
NormalizeVector(anglevector, anglevector);
AddVectors(clienteyeposition, anglevector, resultposition);
NormalizeVector(anglevector, anglevector);
ScaleVector(anglevector, 800.0);
new entity = CreateEntityByName("hegrenade_projectile");
SetEntityMoveType(entity, MOVETYPE_FLY);
DispatchSpawn(entity);
SetEntityModel(entity, "models/logandougall/cel/cel_xmas_snowball_16.mdl");
TeleportEntity(entity, resultposition, clienteyeangle, anglevector);
CreateTimer(3.0, Go, entity);
}
else
{
CPrintToChat(client, "{fullred}NY {darkgrey}| {white}Бросок снежком будет доступен через {fullblue}%i {white}сек", g_iAvailableSnow[client] - time);
}
}
else
{
CPrintToChat(client, "{fullred}NY {darkgrey}| {white}Вы должны быть живы и не находиться в наблюдателях");
}
return Plugin_Handled;
}
public Action:Go(Handle:timer, any:val)
{
if (IsValidEntity(val))
{
AcceptEntityInput(val, "Kill");
}
}
UTIL_FindSendPropOffs(const String:sNetClass[], const String:sPropertyName[])
{
new iOffset = FindSendPropInfo(sNetClass, sPropertyName);
if (iOffset == -1) SetFailState("Fatal Error: Unable to find offset: \"%s::%s\"", sNetClass, sPropertyName);
return iOffset;
}