Advertisement
Guest User

Untitled

a guest
Dec 26th, 2015
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. #pragma semicolon 1
  5.  
  6. #define PLUGIN_VERSION "1.0"
  7. #define PLUGIN_AUTHOR "tuty"
  8.  
  9. #define SOUND_FILE "misc/medic.wav"
  10.  
  11. new Handle:gPluginEnabled = INVALID_HANDLE;
  12. new Handle:gHealthAmount = INVALID_HANDLE;
  13. new Handle:gMinHealth = INVALID_HANDLE;
  14. new Handle:gMedicCost = INVALID_HANDLE;
  15. new Handle:gShowInChat = INVALID_HANDLE;
  16. new Handle:gMaxTimeUse = INVALID_HANDLE;
  17.  
  18. new gPlayerMoney;
  19. new gUsedMedic[ 33 ];
  20.  
  21.  
  22. public Plugin:myinfo =
  23. {
  24. name = "CSS Medic",
  25. author = PLUGIN_AUTHOR,
  26. description = "You can call a medic.",
  27. version = PLUGIN_VERSION,
  28. url = "www.ligs.us"
  29. };
  30. public OnPluginStart()
  31. {
  32. HookEvent( "player_spawn", Event_PlayerSpawn );
  33. RegAdminCmd( "sm_medic", Command_Medic, ADMFLAG_RESERVATION );
  34. RegAdminCmd( "sm_doctor", Command_Medic, ADMFLAG_RESERVATION );
  35. RegConsoleCmd("sm_medic", Kloc);
  36. RegConsoleCmd("sm_doctor", Kloc);
  37.  
  38. CreateConVar( "cssmedic_version", PLUGIN_VERSION, "CSS Medic Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY );
  39.  
  40. gPluginEnabled = CreateConVar( "css_medic", "1" );
  41. gMinHealth = CreateConVar( "css_medic_minhealth", "40" );
  42. gHealthAmount = CreateConVar( "css_medic_healhealth", "100" );
  43. gMedicCost = CreateConVar( "css_medic_cost", "2000" );
  44. gShowInChat = CreateConVar( "css_medic_showcall", "1" );
  45. gMaxTimeUse = CreateConVar( "css_medic_maxuse", "1" );
  46.  
  47. gPlayerMoney = FindSendPropOffs( "CCSPlayer", "m_iAccount" );
  48. }
  49. public Action:Kloc(client, args)
  50. {
  51. PrintToChatAll( "\x04[\x03VIP\x04]\x01 Zakup vipa, aby miec dostep do komendy");
  52. return Plugin_Handled;
  53. }
  54. public OnClientConnected( id )
  55. {
  56. gUsedMedic[ id ] = 0;
  57. }
  58. public OnClientDisconnect( id )
  59. {
  60. gUsedMedic[ id ] = 0;
  61. }
  62. public OnMapStart()
  63. {
  64. decl String:MedicSound[ 100 ];
  65. FormatEx( MedicSound, sizeof( MedicSound ) - 1, "sound/%s", SOUND_FILE );
  66.  
  67. if( FileExists( MedicSound ) )
  68. {
  69. AddFileToDownloadsTable( MedicSound );
  70. PrecacheSound( SOUND_FILE, true );
  71. }
  72. }
  73. public Action:Event_PlayerSpawn( Handle:event, const String:name[], bool:dontBroadcast )
  74. {
  75. if( GetConVarInt( gPluginEnabled ) == 1 )
  76. {
  77. new id = GetClientOfUserId( GetEventInt( event, "userid" ) );
  78.  
  79. gUsedMedic[ id ] = 0;
  80. }
  81. }
  82. public Action:Command_Medic( id, args )
  83. {
  84. decl String:Said[ 128 ];
  85.  
  86. GetCmdArgString( Said, sizeof( Said ) - 1 );
  87. StripQuotes( Said );
  88. TrimString( Said );
  89.  
  90. if( StrEqual( Said, "!medic" ) || StrEqual( Said, "!doctor" ) )
  91. {
  92. if( GetConVarInt( gPluginEnabled ) == 0 )
  93. {
  94. PrintToChat( id, "\x03[CSS Medic] \x01Sorry, you can't call a \x04Medic\x01 !" );
  95.  
  96. return Plugin_Continue;
  97. }
  98.  
  99. if( !IsPlayerAlive( id ) )
  100. {
  101. PrintToChat( id, "\x03[CSS Medic] \x01You can't call \x04Medic \x01while you are dead!" );
  102.  
  103. return Plugin_Continue;
  104. }
  105.  
  106. new maxtime = GetConVarInt( gMaxTimeUse );
  107.  
  108. if( gUsedMedic[ id ] >= maxtime )
  109. {
  110. PrintToChat( id, "\x03[CSS Medic] \x01You can call \x04Medic \x01only \x03%d \x01times per round!", maxtime );
  111.  
  112. return Plugin_Continue;
  113. }
  114.  
  115. new money = GetClientMoney( id );
  116. new cost = GetConVarInt( gMedicCost );
  117.  
  118. if( money < cost )
  119. {
  120. PrintToChat( id, "\x03[CSS Medic] \x01You don't have enough money to call a \x04Medic\x01 ! You need %d$", cost );
  121.  
  122. return Plugin_Continue;
  123. }
  124.  
  125. if( GetClientHealth( id ) >= GetConVarInt( gMinHealth ) )
  126. {
  127. PrintToChat( id, "\x03[CSS Medic] \x01Hey dude! You have enough health, and you don't need a \x04Medic \x01! Go back to fight!" );
  128.  
  129. return Plugin_Continue;
  130. }
  131.  
  132. gUsedMedic[ id ]++;
  133.  
  134. SetEntProp( id, Prop_Data, "m_iHealth", GetConVarInt( gHealthAmount ) );
  135. SetClientMoney( id, money - cost );
  136. PrintToChat( id, "\x03[CSS Medic] \x01Successfully called a \x04Medic\x01 ! You are now healed." );
  137.  
  138. if( GetConVarInt( gShowInChat ) != 0 )
  139. {
  140. decl String:Name[ 32 ];
  141. GetClientName( id, Name, sizeof( Name ) - 1 );
  142.  
  143. PrintToChatAll( "\x03%s \x01(CALLED): \x04Medic!", Name );
  144. }
  145.  
  146. new Float:fOrigin[ 3 ];
  147. GetClientAbsOrigin( id, Float:fOrigin );
  148.  
  149. EmitAmbientSound( SOUND_FILE, fOrigin, id, SNDLEVEL_CONVO );
  150. AttachClientIcon( id );
  151. }
  152.  
  153. return Plugin_Continue;
  154. }
  155. stock SetClientMoney( index, money )
  156. {
  157. if( gPlayerMoney != -1 )
  158. {
  159. SetEntData( index, gPlayerMoney, money );
  160. }
  161. }
  162. stock GetClientMoney( index )
  163. {
  164. if( gPlayerMoney != -1 )
  165. {
  166. return GetEntData( index, gPlayerMoney );
  167. }
  168.  
  169. return 0;
  170. }
  171. stock AttachClientIcon( index )
  172. {
  173. TE_Start( "RadioIcon" );
  174. TE_WriteNum( "m_iAttachToClient", index );
  175. TE_SendToAll();
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement