HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4.  
  5. #define PLUGIN_DESCRIPTION "Sprintelés."
  6. #define PLUGIN_VERSION "0.0.1a"
  7.  
  8. #define YELLOW 0x01
  9. #define NAME_TEAMCOLOR 0x02
  10. #define TEAMCOLOR 0x03
  11. #define GREEN 0x04
  12.  
  13. new Handle:sm_sprintsource_enabled;
  14. new Handle:sm_sprintsource_time;
  15. new Handle:sm_sprintsource_cooldown;
  16. new Handle:sm_sprintsource_sprintspeed;
  17.  
  18. new bool:client_connected[MAXPLAYERS+1];
  19. new bool:client_sprintusing[MAXPLAYERS+1];
  20. new bool:client_sprintcool[MAXPLAYERS+1];
  21.  
  22. public Plugin:myinfo =
  23. {
  24. name = "Sprint: Source Plugin",
  25. author = "Alican 'AlicanC' Çubukçuoğlu",
  26. description = PLUGIN_DESCRIPTION,
  27. version = PLUGIN_VERSION,
  28. url = "http://www.sourcemod.net/"
  29. }
  30.  
  31. public OnPluginStart()
  32. {
  33. LoadTranslations("plugin.sprintsource.base");
  34.  
  35. CreateConVar("sprintsource_version", PLUGIN_VERSION, "Sprint: Source Version", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  36.  
  37. sm_sprintsource_enabled= CreateConVar("sm_sprintsource_enable", "1", "Kikapcs./bekapcsolás", FCVAR_PLUGIN|FCVAR_NOTIFY);
  38. sm_sprintsource_time= CreateConVar("sm_sprintsource_time", "3", "Sprint Idő", FCVAR_PLUGIN|FCVAR_NOTIFY);
  39. sm_sprintsource_cooldown= CreateConVar("sm_sprintsource_cooldown", "10", "lefagyás ideje", FCVAR_PLUGIN|FCVAR_NOTIFY);
  40. sm_sprintsource_sprintspeed= CreateConVar("sm_sprintsource_sprintspeed", "2", "Sprint sebessége", FCVAR_PLUGIN|FCVAR_NOTIFY);
  41.  
  42. HookEvent("round_start", Event_RoundStart);
  43.  
  44. //RegAdminCmd("sm_sprint_take", Cmd_TakeSprint, ADMFLAG_GENERIC);
  45. //RegAdminCmd("sm_sprint_give", Cmd_GiveSprint, ADMFLAG_GENERIC);
  46. RegConsoleCmd("ss_sprint", Cmd_StartSprint);
  47. }
  48.  
  49.  
  50. public OnClientPutInServer(client)
  51. {
  52. if(!GetConVarBool(sm_sprintsource_enabled))
  53. return;
  54. //
  55. client_connected[client]= true;
  56. //
  57. Skill_Sprint_Reset(client);
  58. //
  59. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource Running", PLUGIN_VERSION);
  60. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource Command");
  61. //
  62. return;
  63. }
  64.  
  65. public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  66. {
  67. if(!GetConVarBool(sm_sprintsource_enabled))
  68. return;
  69. //Get clients
  70. new clients= GetMaxClients();
  71. //
  72. for(new client= 1; client<=clients; client++)
  73. {
  74. //
  75. if(IsClientInGame(client))
  76. {
  77. Skill_Sprint_Reset(client);
  78. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource Command");
  79. }
  80. }
  81. }
  82.  
  83. public Skill_Sprint_Reset(client)
  84. {
  85. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0);
  86. client_sprintusing[client]=false;
  87. client_sprintcool[client]=true;
  88. }
  89.  
  90. public Action:Cmd_StartSprint(client, args)
  91. {
  92. if(!GetConVarBool(sm_sprintsource_enabled))
  93. return;
  94. if(client_sprintusing[client])
  95. {
  96. return;
  97. }
  98. if(!client_sprintcool[client])
  99. {
  100. return;
  101. }
  102. client_sprintusing[client]=true;
  103. client_sprintcool[client]=false;
  104. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", GetConVarFloat(sm_sprintsource_sprintspeed));
  105. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource Start");
  106. CreateTimer(GetConVarFloat(sm_sprintsource_time), Timer_SprintEnd, client);
  107. }
  108.  
  109. public Action:Timer_SprintEnd(Handle:timer, any:client)
  110. {
  111. SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", 1.0);
  112. if(!client_sprintusing[client])
  113. {
  114. return;
  115. }
  116. client_sprintusing[client]=false;
  117. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource End");
  118. CreateTimer(GetConVarFloat(sm_sprintsource_cooldown), Timer_SprintCooldown, client);
  119. }
  120.  
  121. public Action:Timer_SprintCooldown(Handle:timer, any:client)
  122. {
  123. if(client_sprintcool[client])
  124. {
  125. return;
  126. }
  127. client_sprintcool[client]=true;
  128. PrintToChat(client, "%c[Sprint]%c %t", GREEN, YELLOW, "SprintSource Cool");
  129. }