Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.89 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4. #include <cstrike>
  5. #tryinclude <shop>
  6.  
  7. public Plugin:myinfo =
  8. {
  9. name = "[CS:GO] Vanoce na http://popfrag.eu",
  10. author = "Despi",
  11. description = "Vánoce jsou svátek",
  12. version = "1.0 beta",
  13. url = "https://www.popfrag.eu"
  14. }
  15.  
  16. static const String: sDownloadTable[][] =
  17. {
  18. "models/logandougall/cel/cel_xmas_snowball_16.dx80.vtx",
  19. "models/logandougall/cel/cel_xmas_snowball_16.dx90.vtx",
  20. "models/logandougall/cel/cel_xmas_snowball_16.mdl",
  21. "models/logandougall/cel/cel_xmas_snowball_16.phy",
  22. "models/logandougall/cel/cel_xmas_snowball_16.sw.vtx",
  23. "models/logandougall/cel/cel_xmas_snowball_16.vvd",
  24. "materials/models/logandougall/cel/snow.vmt",
  25. "materials/models/logandougall/cel/snow.vtf",
  26. "models/models_kit/xmas/xmastree.dx80.vtx",
  27. "models/models_kit/xmas/xmastree.dx90.vtx",
  28. "models/models_kit/xmas/xmastree.mdl",
  29. "models/models_kit/xmas/xmastree.phy",
  30. "models/models_kit/xmas/xmastree.sw.vtx",
  31. "models/models_kit/xmas/xmastree.vvd",
  32. "models/models_kit/xmas/xmastree.xbox.vtx",
  33. "models/logandougall/cel/cel_xmas_snowman.dx80.vtx",
  34. "models/logandougall/cel/cel_xmas_snowman.dx90.vtx",
  35. "models/logandougall/cel/cel_xmas_snowman.mdl",
  36. "models/logandougall/cel/cel_xmas_snowman.phy",
  37. "models/logandougall/cel/cel_xmas_snowman.sw.vtx",
  38. "models/logandougall/cel/cel_xmas_snowman.vvd",
  39. "materials/models/logandougall/cel/carrot.vtf",
  40. "materials/models/logandougall/cel/carrot.vmt",
  41. "materials/models/logandougall/cel/toolsblack.vmt",
  42. "materials/models/logandougall/cel/bark.vmt",
  43. "materials/models/logandougall/cel/bark.vtf",
  44. "materials/models/logandougall/cel/snow.vmt",
  45. "materials/models/logandougall/cel/snow.vtf",
  46. "models/models_kit/xmas/giftbox_mini_quad.dx80.vtx",
  47. "models/models_kit/xmas/giftbox_mini_quad.dx90.vtx",
  48. "models/models_kit/xmas/giftbox_mini_quad.mdl",
  49. "models/models_kit/xmas/giftbox_mini_quad.phy",
  50. "models/models_kit/xmas/giftbox_mini_quad.sw.vtx",
  51. "models/models_kit/xmas/giftbox_mini_quad.vvd",
  52. "models/models_kit/xmas/giftbox_mini_quad.xbox.vtx",
  53. "materials/models/models_kit/xmas/giftbox.vmt",
  54. "materials/models/models_kit/xmas/giftbox.vtf",
  55. "models/models_kit/xmas/xmastree_mini.dx80.vtx",
  56. "models/models_kit/xmas/xmastree_mini.dx90.vtx",
  57. "models/models_kit/xmas/xmastree_mini.mdl",
  58. "models/models_kit/xmas/xmastree_mini.phy",
  59. "models/models_kit/xmas/xmastree_mini.sw.vtx",
  60. "models/models_kit/xmas/xmastree_mini.vvd",
  61. "models/models_kit/xmas/xmastree_mini.xbox.vtx",
  62. "materials/models/models_kit/xmas/xmastree_miscA.vmt",
  63. "materials/models/models_kit/xmas/xmastree_miscA.vtf",
  64. "materials/models/models_kit/xmas/xmastree_miscA_skin2.vmt",
  65. "materials/models/models_kit/xmas/xmastree_miscA_skin2.vtf",
  66. "materials/models/models_kit/xmas/xmastree_miscB.vmt",
  67. "materials/models/models_kit/xmas/xmastree_miscB.vtf",
  68. "materials/models/models_kit/xmas/xmastree_miscB_skin2.vmt",
  69. "materials/models/models_kit/xmas/xmastree_miscB_skin2.vtf",
  70. "materials/models/models_kit/xmas/xmastree_miscB_spec.vtf"
  71. }
  72.  
  73. static const String: g_sGrens[][] =
  74. {
  75. "weapon_hegrenade",
  76. "weapon_flashbang",
  77. "weapon_smokegrenade"
  78. };
  79.  
  80. static const String: g_sGrens_text[][] =
  81. {
  82. "výbušný granát",
  83. "oslepující granát",
  84. "smoke granát"
  85. };
  86.  
  87. static const String: sApt_text[][] =
  88. {
  89. "malou lékarníčku",
  90. "lékárnička",
  91. "velká lékárnička"
  92. };
  93.  
  94. static const sAptMin[] = { 5, 10, 25};
  95. static const sAptMax[] = {10, 20, 50};
  96.  
  97. new m_iHealth;
  98. new m_fSpeed;
  99. new m_iAccount;
  100. new bool:g_bActive, g_iAnswer, String:g_sFile[64], g_iAvailableSnow[64];
  101.  
  102. public OnPluginStart()
  103. {
  104. HookEvent("player_death", Event_PlayerDeath);
  105. HookEvent("round_start", Event_RoundStart);
  106.  
  107. m_iAccount = UTIL_FindSendPropOffs("CCSPlayer", "m_iAccount");
  108. m_iHealth = UTIL_FindSendPropOffs("CCSPlayer", "m_iHealth");
  109. m_fSpeed = UTIL_FindSendPropOffs("CCSPlayer", "m_flLaggedMovementValue");
  110.  
  111. RegAdminCmd("sm_gift", GiftMe, ADMFLAG_ROOT);
  112. RegAdminCmd("sm_tree", CreateTree, ADMFLAG_ROOT);
  113. RegAdminCmd("sm_del", DeleteTree, ADMFLAG_ROOT);
  114. RegAdminCmd("sm_snowman", CreateSnowman, ADMFLAG_ROOT);
  115. RegAdminCmd("sm_large", CreateLarge, ADMFLAG_ROOT);
  116.  
  117. RegConsoleCmd("sm_snow", Snow);
  118.  
  119.  
  120. CreateTimer(60.0, Question, _, TIMER_REPEAT);
  121. }
  122.  
  123. public OnMapStart()
  124. {
  125. for(new i; i < sizeof(sDownloadTable); i++)
  126. {
  127. AddFileToDownloadsTable(sDownloadTable[i]);
  128. }
  129.  
  130. PrecacheModel("sprites/glow01.spr", true);
  131. PrecacheModel("models/models_kit/xmas/giftbox_mini_quad.mdl", true);
  132. PrecacheModel("models/models_kit/xmas/xmastree_mini.mdl", true);
  133. PrecacheModel("models/logandougall/cel/cel_xmas_snowman.mdl", true);
  134. PrecacheModel("models/models_kit/xmas/xmas_teddybear.mdl", true);
  135. PrecacheModel("models/models_kit/xmas/xmastree.mdl", true);
  136. PrecacheModel("models/logandougall/cel/cel_xmas_snowball_16.mdl", true);
  137.  
  138. decl String: g_sCurrentMap[32];
  139. GetCurrentMap(g_sCurrentMap, sizeof(g_sCurrentMap));
  140.  
  141. if(!DirExists("addons/sourcemod/configs/newyear/"))
  142. {
  143. CreateDirectory("addons/sourcemod/configs/newyear/", 511);
  144. }
  145. FormatEx(g_sFile, sizeof(g_sFile), "addons/sourcemod/configs/newyear/%s.cfg", g_sCurrentMap);
  146. }
  147.  
  148. public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
  149. {
  150. if(g_bActive && StringToInt(sArgs) == g_iAnswer)
  151. {
  152. CreateTimer(1.0, Gift, GetClientUserId(client));
  153. PrintToChat(client, "\x04Jako první jsi odpověděl na příklad správně! Dáreček byl vytvořen ve tvém blízkém okolí!");
  154. g_bActive = false;
  155. }
  156. }
  157.  
  158.  
  159. public Action:Question(Handle:timer)
  160. {
  161. CreateTimer(15.0, Timer_QuestionTimeLeft);
  162. new a = GetRandomInt(50, 250);
  163. new b = GetRandomInt(1, 50);
  164. new op = GetRandomInt(0,1);
  165. g_bActive = true;
  166.  
  167. if (op)
  168. {
  169. g_iAnswer = a + b;
  170. PrintToChatAll("\x04Ježíšek píše\x01: Jaký je výsledek příkladu \x04%i\x01 + \x04%i\x01?", a , b);
  171. }
  172. else
  173. {
  174. g_iAnswer = a - b;
  175. PrintToChatAll("\x04Ježíšek píše \x01: Jaký je výsledek příkladu \x04%i\x01 - \x04%i\x01?", a , b);
  176. }
  177.  
  178. return Plugin_Continue;
  179. }
  180.  
  181. public Action:Timer_QuestionTimeLeft(Handle:timer)
  182. {
  183. g_bActive = false;
  184. }
  185.  
  186. public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  187. {
  188. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  189. if (IsClientInGame(client))
  190. {
  191. CreateTimer(2.0, Gift, GetClientUserId(client));
  192. }
  193. }
  194.  
  195. public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  196. {
  197. new Handle:kv = CreateKeyValues("tree");
  198. if (FileToKeyValues(kv, g_sFile) && KvGotoFirstSubKey(kv))
  199. {
  200. decl String:KeyName[50];
  201. do
  202. {
  203. if (KvGetSectionName(kv, KeyName, 50))
  204. {
  205. decl Float:g_fOrigin[3], Float:g_fAngles[3], String:type[20];
  206. KvGetVector(kv, "1", g_fOrigin);
  207. KvGetVector(kv, "2", g_fAngles);
  208. KvGetString(kv, "type", type, sizeof(type));
  209. if (StrEqual(type, "tree") || StrEqual(type, ""))
  210. {
  211. SpawnTree(g_fOrigin, g_fAngles);
  212. new w_color[4] = { 0, 0, 0, 255 };
  213. decl String: color[20], Float: Ori[3];
  214. g_fOrigin[2] += 10;
  215. for (new i = 1; i<= 10; i++)
  216. {
  217. for (new q = 0; q < 3; q++) w_color[q] = GetRandomInt(10, 255);
  218. for (new a = 0; a < 3; a++) Ori[a] = g_fOrigin[a]
  219.  
  220. FormatEx(color, sizeof(color), "%i %i %i", w_color[0], w_color[1], w_color[2]);
  221.  
  222. new index = CreateEntityByName("env_sprite");
  223. DispatchKeyValue(index, "rendermode", "5");
  224. DispatchKeyValue(index, "rendercolor", color);
  225. DispatchKeyValue(index, "renderamt", "255");
  226. DispatchKeyValue(index, "scale", "0.6");
  227. DispatchKeyValue(index, "model", "sprites/glow01.spr");
  228. DispatchSpawn(index);
  229. AcceptEntityInput(index, "ShowSprite");
  230. new Float:crd;
  231. switch(i)
  232. {
  233. case 1: crd = 27.0;
  234. case 2: crd = -27.0;
  235. case 3: crd = 22.0;
  236. case 4: crd = -22.0;
  237. case 5: crd = 17.0;
  238. case 6: crd = -17.0;
  239. case 7: crd = 12.0;
  240. case 8: crd = -12.0;
  241. case 9: crd = 7.0;
  242. case 10: crd = -7.0;
  243. }
  244.  
  245. Ori[2] += 10*i;
  246. Ori[0] += crd;
  247. Ori[1] += crd;
  248. TeleportEntity(index, Ori, g_fAngles, NULL_VECTOR);
  249. }
  250. }
  251. if (StrEqual(type, "snowman"))
  252. {
  253. SpawnSnowMan(g_fOrigin, g_fAngles);
  254. }
  255. if (StrEqual(type, "large"))
  256. {
  257. SpawnLarge(g_fOrigin, g_fAngles);
  258. }
  259. }
  260. }
  261. while (KvGotoNextKey(kv));
  262. }
  263.  
  264. CloseHandle(kv);
  265. }
  266.  
  267. public Action:Gift(Handle:timer, any:userid)
  268. {
  269. new i = GetClientOfUserId(userid);
  270.  
  271. if (i && IsClientInGame(i))
  272. {
  273. new iEntity = CreateEntityByName("prop_dynamic");
  274. if (iEntity)
  275. {
  276. decl Float:fPos[3], String:clr[20];
  277. new String:sTargetName[32],
  278. String:sBufer[70],
  279. Float:fTime = 30.0;
  280.  
  281. GetClientAbsOrigin(i, fPos);
  282. fPos[0] += 50.0;
  283.  
  284. if (!IsPlayerAlive(i))
  285. {
  286. fPos[2] -= 40.0;
  287. }
  288.  
  289. Format(sTargetName, sizeof(sTargetName), "xmasgift_%i", iEntity);
  290. DispatchKeyValueVector(iEntity, "origin", fPos);
  291. DispatchKeyValue(iEntity, "solid", "6");
  292. DispatchKeyValue(iEntity, "model", "models/models_kit/xmas/giftbox_mini_quad.mdl");
  293. DispatchKeyValue(iEntity, "targetname", sTargetName);
  294. SetVariantString(sTargetName);
  295. DispatchSpawn(iEntity);
  296. SetEntProp(iEntity, Prop_Send, "m_usSolidFlags", 8);
  297. SetEntProp(iEntity, Prop_Send, "m_CollisionGroup", 1);
  298. Format(sBufer, sizeof(sBufer), "OnUser1 !self:kill::%0.2f:-1", fTime);
  299. SetVariantString(sBufer);
  300. AcceptEntityInput(iEntity, "AddOutput");
  301. AcceptEntityInput(iEntity, "FireUser1");
  302.  
  303.  
  304. new iRotating = CreateEntityByName("func_rotating", -1);
  305. DispatchKeyValueVector(iRotating, "origin", fPos);
  306. DispatchKeyValue(iRotating, "targetname", sTargetName);
  307. DispatchKeyValue(iRotating, "maxspeed", "180");
  308. DispatchKeyValue(iRotating, "friction", "0");
  309. DispatchKeyValue(iRotating, "dmg", "0");
  310. DispatchKeyValue(iRotating, "solid", "0");
  311. DispatchKeyValue(iRotating, "spawnflags", "64");
  312. DispatchSpawn(iRotating);
  313. SetVariantString("!activator");
  314. AcceptEntityInput(iEntity, "SetParent", iRotating, iRotating);
  315. AcceptEntityInput(iRotating, "Start", -1, -1);
  316. SetEntProp(iRotating, Prop_Send, "m_CollisionGroup", 1);
  317. Format(sBufer, sizeof(sBufer), "OnUser1 !self:kill::%0.2f:-1", fTime);
  318. SetVariantString(sBufer);
  319. AcceptEntityInput(iRotating, "AddOutput");
  320. AcceptEntityInput(iRotating, "FireUser1");
  321. SetEntPropEnt(iEntity, Prop_Send, "m_hEffectEntity", iRotating);
  322.  
  323. Format(clr, sizeof(clr), "%i %i %i", GetRandomInt(0,255),GetRandomInt(0,255),GetRandomInt(0,255));
  324. new index5 = CreateEntityByName("env_sprite");
  325. DispatchKeyValue(index5, "rendermode", "5");
  326. DispatchKeyValue(index5, "rendercolor", String:clr);
  327. DispatchKeyValue(index5, "renderamt", "255");
  328. DispatchKeyValue(index5, "scale", "1");
  329. DispatchKeyValue(index5, "model", "sprites/glow01.spr");
  330. DispatchKeyValueVector(index5, "origin", fPos);
  331. DispatchSpawn(index5);
  332. SetVariantString("!activator");
  333. AcceptEntityInput(index5, "SetParent", iEntity);
  334.  
  335.  
  336. SDKHook(iEntity, SDKHook_StartTouch, Hook_GiftStartTouch);
  337. }
  338. }
  339. return Plugin_Stop;
  340. }
  341.  
  342. public Hook_GiftStartTouch(iEntity, activator)
  343. {
  344. if (activator > 0 && activator <= MaxClients)
  345. {
  346. switch (GetRandomInt(1,9))
  347. {
  348. case 1:
  349. {
  350. new iMoney;
  351.  
  352. if(GetRandomInt(0,1))
  353. {
  354. new randommoney = GetRandomInt(0, 5000);
  355. iMoney = GetEntData(activator, m_iAccount) + randommoney;
  356. SetEntData(activator, m_iAccount, iMoney);
  357. PrintToChat(activator,"\x04[Vánoce]\x01 Z dárečku jsi obdržel: \x03%i$", randommoney);
  358. }
  359. else
  360. {
  361. new randommoney = GetRandomInt(0, 500);
  362. iMoney = GetEntData(activator, m_iAccount) - randommoney;
  363. PrintToChat(activator,"\x04[Vánoce]\x01 Z dárečku jsi obdržel: \x03%i$", randommoney);
  364. }
  365.  
  366. SetEntData(activator, m_iAccount, iMoney);
  367. }
  368.  
  369. case 2:
  370. {
  371. if(GetRandomInt(0,1))
  372. {
  373. SetEntProp(activator, Prop_Data, "m_iFrags", GetClientFrags(activator) + 2);
  374. PrintToChat(activator,"\x04[Vánoce]\x01 K účtu byl přidán dárek \x032\x01.");
  375. }
  376. else
  377. {
  378. SetEntProp(activator, Prop_Data, "m_iDeaths", GetClientDeaths(activator) - 2);
  379. PrintToChat(activator,"\x04[Vánoce]\x01 Dárek byl z účtu odebrán \x032\x01 za smrt.");
  380. }
  381. }
  382.  
  383. case 3:
  384. {
  385. new r = GetRandomInt(0,2);
  386. SetEntData(activator, m_iHealth, GetEntData(activator, m_iHealth) + GetRandomInt(sAptMin[r], sAptMax[r]));
  387. PrintToChat(activator,"\x04[Vánoce]\x01 V dárečku se nachází \x03%s", sApt_text[r]);
  388. }
  389.  
  390. case 4:
  391. {
  392. new r = GetRandomInt(0,2);
  393. GivePlayerItem(activator, g_sGrens[r]);
  394. PrintToChat(activator,"\x04[Vánoce]\x01 V dárku se nachází \x03%s", g_sGrens_text[r]);
  395. }
  396.  
  397. case 5:
  398. {
  399. new Float:randomspeed = GetRandomFloat(0.9, 1.2);
  400. SetEntDataFloat(activator, m_fSpeed, GetEntDataFloat(activator, m_fSpeed) * randomspeed);
  401. PrintToChat(activator, "\x04[Vánoce]\x01 V dárečku byl Vánoční drink, který změnil tvoji rychlost na: \x03%.2f%%", 100.0*randomspeed);
  402. }
  403.  
  404. #if defined _shop_included
  405. case 6:
  406. {
  407. new shopwin = GetRandomInt(0,100);
  408.  
  409. if (shopwin <= 10)
  410. PrintToChat(activator,"\x04[Vánoce]\x01 Dárek má roztrženou loterii s výhrou\x03%i\x01!",;Shop_GiveClientCredits(activator, GetRandomInt(1,5), CREDITS_BY_NATIVE));
  411.  
  412. else if (shopwin <= 50)
  413. PrintToChat(activator,"\x04[Vánoce]\x01
  414. Současnost se ukázala jako levná loterijní jízdenka s výhrou \x03%i\x01 body! ", Shop_GiveClientCredits(activator, GetRandomInt(5,25), CREDITS_BY_NATIVE));
  415.  
  416. else if (shopwin <= 70)
  417. PrintToChat(activator,"\x04[Vánoce]\x01 Současnost se ukázala jako loterijní výhra s výhrou \x03%i\x01 body! ", Shop_GiveClientCredits(activator, GetRandomInt(25,75), CREDITS_BY_NATIVE));
  418.  
  419. else if (shopwin <= 85)
  420. PrintToChat(activator,"\x04[Vánoce]\x01 Současnost se ukázala jako drahá loterie s výhrou \x03%i\x01 body! ", Shop_GiveClientCredits(activator, GetRandomInt(75,150), CREDITS_BY_NATIVE));
  421.  
  422. else if (shopwin <= 99)
  423. PrintToChat(activator,"\x04[Vánoce]\x01 V dárku se ukázalo být \x03VIP\x01 loteirní hráč - \x03%i\x01 body! ", Shop_GiveClientCredits(activator, GetRandomInt(150,250), CREDITS_BY_NATIVE));
  424.  
  425. else
  426. {
  427. switch (GetRandomInt(0,3))
  428. {
  429. case 1: {PrintToChat(activator,"\x04[Vánoce]\x01 V Dárku byla loterijní karta s \x03JACKPOTEM\x01 velikosti s \x03%i\x01 body! ", Shop_GiveClientCredits(activator, 250, CREDITS_BY_NATIVE));}
  430. case 2: {PrintToChat(activator,"\x04[Vánoce]\x01 V Dárku byla loterijní karta s \x03JACKPOTEM\x01 velikosti s \x03%i\x01 body! ", Shop_GiveClientCredits(activator, 500, CREDITS_BY_NATIVE));}
  431. case 3: {PrintToChat(activator,"\x04[Vánoce]\x01 V Dárku byla loterijní karta s \x03JACKPOTEM\x01 velikosti s \x03%i\x01 body! ", Shop_GiveClientCredits(activator, 1000, CREDITS_BY_NATIVE));}
  432. default: PrintToChat(activator,"\x04[Vánoce]\x01 Přítomnost se ukázala být zkaženou loterií s \x03ДЖЕКПОТОМ\x01.");
  433. }
  434. }
  435. }
  436. #endif
  437.  
  438. default: {PrintToChat(activator,"\x04[Vánoce]\x01 Omlouváme se, ale dárek byl prázdný..");}
  439. }
  440. }
  441.  
  442. if(IsValidEdict(iEntity))
  443. {
  444. new iRotating = GetEntPropEnt(iEntity, Prop_Send, "m_hEffectEntity");
  445. if(iRotating && IsValidEdict(iRotating))
  446. {
  447. AcceptEntityInput(iRotating, "Kill");
  448. }
  449.  
  450. AcceptEntityInput(iEntity, "Kill");
  451. }
  452. }
  453.  
  454.  
  455.  
  456. public Action:GiftMe(client, args)
  457. {
  458. CreateTimer(0.1, Gift, GetClientUserId(client));
  459. return Plugin_Handled;
  460. }
  461.  
  462. public Action:CreateTree(client, args)
  463. {
  464. CreateSomethink(client, "tree");
  465. return Plugin_Handled;
  466. }
  467.  
  468. public Action:CreateLarge(client, args)
  469. {
  470. CreateSomethink(client, "large");
  471. return Plugin_Handled;
  472. }
  473.  
  474. public Action:CreateSnowman(client, args)
  475. {
  476. CreateSomethink(client, "snowman");
  477. return Plugin_Handled;
  478. }
  479.  
  480. public bool:Trace_FilterPlayers(entity, contentsMask, any:data){
  481. if(entity != data && entity > MaxClients)
  482. return true;
  483. return false;
  484. }
  485.  
  486. CreateSomethink(client, const String: sType[])
  487. {
  488. decl Float:g_fOrigin[3], Float:g_fAngles[3];
  489. GetClientEyePosition(client, g_fOrigin);
  490. GetClientEyeAngles(client, g_fAngles);
  491.  
  492. TR_TraceRayFilter(g_fOrigin, g_fAngles, MASK_SOLID, RayType_Infinite, Trace_FilterPlayers, client);
  493.  
  494. if(TR_DidHit(INVALID_HANDLE))
  495. {
  496. TR_GetEndPosition(g_fOrigin, INVALID_HANDLE);
  497. TR_GetPlaneNormal(INVALID_HANDLE, g_fAngles);
  498. GetVectorAngles(g_fAngles, g_fAngles);
  499. g_fAngles[0] += 90.0;
  500. switch(sType[0])
  501. {
  502. case 't': SpawnTree(g_fOrigin, g_fAngles);
  503. case 'l': SpawnLarge(g_fOrigin, g_fAngles);
  504. case 's': SpawnSnowMan(g_fOrigin, g_fAngles);
  505. }
  506.  
  507. new Handle:kv = CreateKeyValues("tree");
  508. FileToKeyValues(kv, g_sFile);
  509. decl String:info[60];
  510. FormatEx(info, sizeof(info), "%f,%f",g_fOrigin[0], g_fOrigin[1]);
  511. KvJumpToKey(kv, info, true);
  512. KvSetVector(kv, "1", g_fOrigin);
  513. KvSetVector(kv, "2", g_fAngles);
  514. KvSetString(kv, "type", sType);
  515. KvRewind(kv);
  516. KeyValuesToFile(kv, g_sFile);
  517. CloseHandle(kv);
  518. }
  519. }
  520.  
  521. SpawnTree(const Float:g_fOrigin[3], const Float:g_fAngles[3])
  522. {
  523. new index = CreateEntityByName("prop_dynamic");
  524. DispatchKeyValue(index, "model", "models/models_kit/xmas/xmastree_mini.mdl");
  525. DispatchKeyValue(index, "Solid", "6");
  526. DispatchSpawn(index);
  527. TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
  528. SetEntityMoveType(index, MOVETYPE_VPHYSICS);
  529. }
  530.  
  531. SpawnLarge(const Float:g_fOrigin[3], const Float:g_fAngles[3])
  532. {
  533. new index = CreateEntityByName("prop_dynamic_override");
  534. if (index == -1) return;
  535. DispatchKeyValue(index, "model", "models/models_kit/xmas/xmastree.mdl");
  536. DispatchKeyValue(index, "Solid", "6");
  537. DispatchSpawn(index);
  538. TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
  539. SetEntityMoveType(index, MOVETYPE_VPHYSICS);
  540. }
  541.  
  542. SpawnSnowMan(const Float:g_fOrigin[3], const Float:g_fAngles[3])
  543. {
  544. new index = CreateEntityByName("prop_dynamic");
  545. DispatchKeyValue(index, "model", "models/logandougall/cel/cel_xmas_snowman.mdl");
  546. DispatchKeyValue(index, "Solid", "6");
  547. DispatchSpawn(index);
  548. TeleportEntity(index, g_fOrigin, g_fAngles, NULL_VECTOR);
  549. SetEntityMoveType(index, MOVETYPE_VPHYSICS);
  550. }
  551.  
  552. public Action:DeleteTree(client, args)
  553. {
  554. new index = GetClientAimTarget(client, false);
  555. if (index == -1) return Plugin_Handled;
  556.  
  557. decl Float:vec[3]; decl String:coord[15]; decl String:coord1[15], String:buf3[2][25], String:buf4[2][25];
  558. GetEntPropVector(index, Prop_Data, "m_vecAbsOrigin", vec);
  559. FloatToString(vec[0], coord, sizeof(coord));
  560. FloatToString(vec[1], coord1, sizeof(coord1));
  561. ExplodeString(coord, ".", buf3, 2, 25);
  562. ExplodeString(coord1, ".", buf4, 2, 25);
  563.  
  564. new Handle:kv = CreateKeyValues("tree");
  565. if (FileToKeyValues(kv, g_sFile) && KvGotoFirstSubKey(kv))
  566. {
  567. decl String:KeyName[35];
  568. do
  569. {
  570. if (KvGetSectionName(kv, KeyName, 35))
  571. {
  572. decl String:buf[2][25],String:buf1[2][25],String:buf2[2][25];
  573. ExplodeString(String:KeyName, ",", String:buf, 2, 25);
  574. ExplodeString(String:buf[0], ".", String:buf1, 2, 25);
  575. ExplodeString(String:buf[1], ".", String:buf2, 2, 25);
  576. if (StrEqual(buf1[0], buf3[0]) && StrEqual(buf2[0], buf4[0]))
  577. {
  578. AcceptEntityInput(index, "Kill");
  579. KvDeleteThis(kv);
  580. KvRewind(kv);
  581. KeyValuesToFile(kv, g_sFile);
  582. }
  583. }
  584. }
  585. while (KvGotoNextKey(kv));
  586.  
  587. }
  588. CloseHandle(kv);
  589. return Plugin_Handled;
  590. }
  591.  
  592. public Action:Snow(client, args)
  593. {
  594. if (GetClientTeam(client) > 1 && IsPlayerAlive(client))
  595. {
  596. new time = GetTime();
  597. if (time > g_iAvailableSnow[client])
  598. {
  599. g_iAvailableSnow[client] = time + 10;
  600.  
  601. decl Float:clienteyeangle[3], Float:anglevector[3], Float:clienteyeposition[3], Float:resultposition[3];
  602. GetClientEyeAngles(client, clienteyeangle);
  603. GetClientEyePosition(client, clienteyeposition);
  604. GetAngleVectors(clienteyeangle, anglevector, NULL_VECTOR, NULL_VECTOR);
  605. NormalizeVector(anglevector, anglevector);
  606. AddVectors(clienteyeposition, anglevector, resultposition);
  607. NormalizeVector(anglevector, anglevector);
  608. ScaleVector(anglevector, 800.0);
  609. new entity = CreateEntityByName("hegrenade_projectile");
  610. SetEntityMoveType(entity, MOVETYPE_FLY);
  611. DispatchSpawn(entity);
  612. SetEntityModel(entity, "models/logandougall/cel/cel_xmas_snowball_16.mdl");
  613. TeleportEntity(entity, resultposition, clienteyeangle, anglevector);
  614. CreateTimer(3.0, Go, entity);
  615. }
  616. else
  617. {
  618. PrintToChat(client, "Házet sněhovou kouli bude k dispozici za: %i sekund.", g_iAvailableSnow[client] - time);
  619. }
  620. }
  621. else PrintToChat(client, "Musíš být naživu! (Ve spectu nejde pužívat Vánoční event!)");
  622.  
  623. return Plugin_Handled;
  624. }
  625.  
  626. public Action:Go(Handle:timer, any:val)
  627. {
  628. if (IsValidEntity(val))
  629. {
  630. AcceptEntityInput(val, "Kill");
  631. }
  632. }
  633.  
  634. UTIL_FindSendPropOffs(const String:sNetClass[], const String:sPropertyName[])
  635. {
  636. new iOffset = FindSendPropInfo(sNetClass, sPropertyName);
  637. if (iOffset == -1) SetFailState("Na tomto serveru nefunguje: \"%s::%s\"", sNetClass, sPropertyName);
  638. return iOffset;
  639. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement