Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <codmod>
  3. #include <sdkhooks>
  4. #include <sdktools>
  5.  
  6.  
  7. new const String:nazwa[] = "[VIP] Exacto";
  8. new const String:opis[] = "Twoje granaty samonaprowadzają się! DMG +int";
  9. new const String:bronie[] = "#weapon_m4a1#weapon_ak47#weapon_glock#weapon_hegrenade";
  10. new const inteligencja = 0;
  11. new const zdrowie = 10;
  12. new const obrazenia = 0;
  13. new const wytrzymalosc = 20;
  14. new const kondycja = 0;
  15.  
  16. #define PREFIX "\x01\x0B \x02[cs-placzabaw.pl]\x01"
  17. #define PENGUIN_REFRESH_RATE 0.1
  18.  
  19. new bool:ma_klase[65];
  20. new sprite_beam,
  21. sprite_halo;
  22.  
  23. ConVar g_PenguinSpeed;
  24. ConVar g_PenguinFuse;
  25. ConVar g_PenguinTimeToSeek;
  26. ConVar g_cooldown;
  27. ///////////////////////////////////////////
  28. stock float floatmin(float x, float y)
  29. {
  30. return x <= y ? x : y;
  31. }
  32. //////////////////////////////////////////
  33.  
  34. public Plugin:myinfo =
  35. {
  36. name = nazwa,
  37. author = "Linux`",
  38. description = "Cod Klasa",
  39. version = "1.0",
  40. url = "http://steamcommunity.com/id/linux2006"
  41. };
  42. public OnPluginStart()
  43. {
  44. cod_register_class(nazwa, opis, bronie, inteligencja, zdrowie, obrazenia, wytrzymalosc, kondycja);
  45. g_PenguinSpeed = CreateConVar("superheromod_penguin_speed", "1500");
  46. g_PenguinFuse = CreateConVar("superheromod_penguin_fuse", "10");
  47. g_PenguinTimeToSeek = CreateConVar("superheromod_penguin_time_to_seek", "1");
  48. g_cooldown = CreateConVar("superheromod_hobgoblin_replenish_cooldown", "15");
  49. HookEvent("hegrenade_detonate", WybuchGranata);
  50. }
  51. public OnMapStart()
  52. {
  53. sprite_beam = PrecacheModel("sprites/laserbeam.vmt");
  54. sprite_halo = PrecacheModel("sprites/glow01.vmt");
  55. }
  56. public cod_class_enabled(client)
  57. {
  58. if(GetUserFlagBits(client) & ADMFLAG_RESERVATION)
  59. {
  60. ma_klase[client] = true;
  61. CreateTimer(g_cooldown.FloatValue, Timer_Grenade, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
  62. return COD_CONTINUE;
  63. }
  64. PrintToChat(client, "%s Klasa dostępna tylko dla posiadaczy VIP", PREFIX);
  65. return COD_STOP;
  66. }
  67. public cod_class_disabled(client)
  68. {
  69. ma_klase[client] = false;
  70. }
  71. public Action:RegisterStart(Handle:timer)
  72. {
  73. cod_register_class(nazwa, opis, bronie, inteligencja, zdrowie, obrazenia, wytrzymalosc, kondycja);
  74. }
  75. public Action Timer_Grenade(Handle timer, any data)
  76. {
  77. int client = GetClientOfUserId(data);
  78.  
  79. if(!IsValidClient(client) || !IsPlayerAlive(client))
  80. return Plugin_Stop;
  81.  
  82. if(!ma_klase[client])
  83. return Plugin_Stop;
  84.  
  85. GiveGrenade(client);
  86. return Plugin_Continue;
  87. }
  88.  
  89. public void GiveGrenade(int client)
  90. {
  91. if(IsPlayerAlive(client))
  92. GivePlayerItem(client, "weapon_hegrenade");
  93. CreateTimer(g_cooldown.FloatValue, Timer_Grenade, GetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
  94. }
  95. public int FindClosestTarget(int client)
  96. {
  97. float playerPos[3];
  98. float targetPos[3];
  99. float distance = 9999999999.0;
  100. int returnclient = -1;
  101. GetClientAbsOrigin(client, playerPos);
  102.  
  103. for (int i = 1; i <= MaxClients;i++)
  104. {
  105. if(!IsValidClient(i) || !IsPlayerAlive(i))
  106. continue;
  107.  
  108. if(GetClientTeam(client) == GetClientTeam(i))
  109. continue;
  110.  
  111. GetClientAbsOrigin(i, targetPos);
  112. float currentdistance = GetVectorDistance(playerPos, targetPos);
  113. distance = floatmin(distance, currentdistance);
  114.  
  115. if(distance == currentdistance)
  116. returnclient = i;
  117. }
  118.  
  119. return returnclient;
  120. }
  121. public void OnEntityCreated(int entity, const char[] classname)
  122. {
  123. if(StrEqual(classname, "hegrenade_projectile"))
  124. SDKHook(entity, SDKHook_SpawnPost, OnGrenadeSpawn);
  125. }
  126.  
  127. public Action OnGrenadeSpawn(int entity)
  128. {
  129. int thrower = GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
  130. if(!IsValidClient(thrower))
  131. return Plugin_Continue;
  132.  
  133. if(!ma_klase[thrower])
  134. return Plugin_Continue;
  135.  
  136. RequestFrame(SetNextThink, EntIndexToEntRef(entity));
  137. CreateTimer(g_PenguinTimeToSeek.FloatValue, Timer_StartSeek, EntIndexToEntRef(entity));
  138.  
  139. return Plugin_Continue;
  140. }
  141.  
  142. public void SetNextThink(any data)
  143. {
  144. int grenade = EntRefToEntIndex(data);
  145. SetEntProp(grenade, Prop_Data, "m_nNextThinkTick", -1);
  146. SetEntPropFloat(grenade, Prop_Data, "m_flElasticity", 5.0);
  147. SetEntPropFloat(grenade, Prop_Data, "m_flGroundSpeed", 100.0);
  148. }
  149.  
  150. public Action Timer_StartSeek(Handle timer, any data)
  151. {
  152. int grenade = EntRefToEntIndex(data);
  153. if(grenade == INVALID_ENT_REFERENCE)
  154. return Plugin_Stop;
  155.  
  156. int client = GetEntPropEnt(grenade, Prop_Data, "m_hOwnerEntity");
  157. if(!IsValidClient(client))
  158. return Plugin_Stop;
  159.  
  160. if(!ma_klase[client])
  161. return Plugin_Stop;
  162.  
  163. SetEntProp(grenade, Prop_Data, "m_takedamage", 2);
  164. SetEntProp(grenade, Prop_Data, "m_iHealth", 1);
  165. SetEntProp(grenade, Prop_Data, "m_CollisionGroup", 1);
  166.  
  167. CreateTimer(g_PenguinFuse.FloatValue, Timer_Detonate, data);
  168. DataPack pack = CreateDataPack();
  169. CreateDataTimer(PENGUIN_REFRESH_RATE, Timer_Seek, pack, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
  170. pack.WriteCell(EntIndexToEntRef(grenade));
  171. pack.WriteCell(GetClientUserId(client));
  172. int target = FindClosestTarget(client);
  173. if(target != INVALID_ENT_REFERENCE)
  174. pack.WriteCell(GetClientOfUserId(target));
  175. else
  176. pack.WriteCell(target);
  177.  
  178. return Plugin_Continue;
  179. }
  180.  
  181. public Action Timer_Detonate(Handle timer, any data)
  182. {
  183. int grenade = EntRefToEntIndex(data);
  184. if(grenade == INVALID_ENT_REFERENCE)
  185. return Plugin_Stop;
  186.  
  187. SetEntProp(grenade, Prop_Data, "m_nNextThinkTick", 1);
  188. SDKHooks_TakeDamage(grenade, grenade, grenade, 1.0);
  189.  
  190. return Plugin_Continue;
  191. }
  192.  
  193. public Action Timer_Seek(Handle timer, DataPack pack)
  194. {
  195. pack.Reset();
  196. int grenade = EntRefToEntIndex(pack.ReadCell());
  197. int thrower = GetClientOfUserId(pack.ReadCell());
  198. int target = pack.ReadCell();
  199. if(target == INVALID_ENT_REFERENCE)
  200. return Plugin_Stop;
  201. else
  202. target = GetClientOfUserId(target);
  203.  
  204. if(grenade == INVALID_ENT_REFERENCE)
  205. return Plugin_Stop;
  206.  
  207. if(!IsValidClient(target) || !IsPlayerAlive(target))
  208. {
  209. target = FindClosestTarget(thrower);
  210. if(!IsValidClient(target))
  211. return Plugin_Stop;
  212. }
  213.  
  214. float targetPos[3];
  215. float nadePos[3];
  216. float direction[3];
  217. GetEntPropVector(grenade, Prop_Send, "m_vecOrigin", nadePos);
  218. GetClientAbsOrigin(target, targetPos);
  219. targetPos[2] += 40.0;
  220. SubtractVectors(targetPos, nadePos, direction);
  221.  
  222. NormalizeVector(direction, direction);
  223. ScaleVector(direction, g_PenguinSpeed.FloatValue);
  224. TeleportEntity(grenade, NULL_VECTOR, NULL_VECTOR, direction);
  225.  
  226. if(GetVectorDistance(targetPos, nadePos) <= 30.0)
  227. {
  228. SetEntProp(grenade, Prop_Data, "m_nNextThinkTick", 1);
  229. SDKHooks_TakeDamage(grenade, grenade, grenade, 1.0);
  230. return Plugin_Stop;
  231. }
  232.  
  233. return Plugin_Continue;
  234. }
  235. public Action:WybuchGranata(Handle:event, const String:name[], bool:dontBroadcast)
  236. {
  237. new client = GetClientOfUserId(GetEventInt(event, "userid"));
  238. if(!IsValidClient(client) || !ma_klase[client])
  239. return Plugin_Continue;
  240.  
  241. new Float:forigin[3], Float:iorigin[3];
  242. forigin[0] = GetEventFloat(event, "x");
  243. forigin[1] = GetEventFloat(event, "y");
  244. forigin[2] = GetEventFloat(event, "z");
  245.  
  246. new obrazenia_gracza = 30+RoundFloat(cod_get_user_maks_intelligence(client)*0.9);
  247. for(new i = 1; i <= MaxClients; i++)
  248. {
  249. if(!IsClientInGame(i) || !IsPlayerAlive(i))
  250. continue;
  251.  
  252. if(GetClientTeam(client) == GetClientTeam(i))
  253. continue;
  254.  
  255. GetClientEyePosition(i, iorigin);
  256. if(GetVectorDistance(forigin, iorigin) <= 200.0)
  257. cod_inflict_damage(i, client, obrazenia_gracza);
  258. }
  259.  
  260. TE_SetupBeamRingPoint(forigin, 20.0, 200.0, sprite_beam, sprite_halo, 0, 10, 0.6, 6.0, 0.0, {0, 255, 0, 128}, 10, 0);
  261. TE_SendToAll();
  262.  
  263. return Plugin_Continue;
  264. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement