HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* USP Ninjas Mod v1.1
  2.  
  3. Features:
  4.  
  5. -USP Silence
  6. -Footsteps
  7. -No Fall Damage
  8. -Slay Upon Unislenced Kill
  9. -Rules
  10. -Team Swaps
  11. -Extreme Fun
  12.  
  13.  
  14. Credits:
  15.  
  16. ConnorMcLeod - Helping with the correct USP silence code and freeze
  17. IneedHelp - Providing a helpful base for the plugin
  18. Exolent - Helping with the Team Switch small team define problem
  19. Seta00 - Helping with the Team Switch small team define problem
  20. crazeyeffect - MultiLangual Help
  21. */
  22.  
  23. #include <amxmodx>
  24. #include <cstrike>
  25. #include <hamsandwich>
  26. #include <engine>
  27. #include <fun>
  28. #include <fakemeta>
  29.  
  30. #define PLUGIN_NAME "USP Ninjas"
  31. #define PLUGIN_VERS "1.1"
  32. #define PLUGIN_AUTH "wrecked"
  33.  
  34. #define EXTRAOFFSET_WEAPONS 4
  35. #define m_pPlayer 41
  36. #define m_flNextSecondaryAttack 47
  37. #define OFFSET_SILENCER_FIREMODE 74
  38.  
  39. #define TASK_ID 19966
  40.  
  41. #define set_usp_silent(%1) set_pdata_int(%1, OFFSET_SILENCER_FIREMODE, USP_SILENCED, EXTRAOFFSET_WEAPONS)
  42. #define get_weapon_owner(%1) get_pdata_cbase(%1, m_pPlayer, EXTRAOFFSET_WEAPONS)
  43.  
  44. const USP_SILENCED = (1<<0)
  45.  
  46. const MAX_PLAYERS = 32
  47.  
  48. const XTRA_OFS_PLAYER = 5
  49. const m_pActiveItem = 373
  50.  
  51. const Ham:Ham_Player_ResetMaxSpeed = Ham_Item_PreFrame
  52.  
  53. new const g_iHudColors[3] = { 255, 255, 255 }
  54.  
  55. new bool:g_bNoFallDamage[MAX_PLAYERS+1]
  56.  
  57. new g_iMaxPlayers
  58. new g_iHudSyncMsg
  59. new g_pRestartPointer
  60. new pNoFallDamage
  61. new pHideTimer
  62. new pRulesFile
  63.  
  64. new bool:g_bSilencer[33]
  65.  
  66. new bool:b_RulesExist
  67.  
  68. new HamHook:g_iHhResetMaxSpeed
  69.  
  70. new freezetime
  71.  
  72. public plugin_init()
  73. {
  74. register_plugin( PLUGIN_NAME, PLUGIN_VERS, PLUGIN_AUTH )
  75.  
  76. new szMapName[32]
  77. get_mapname( szMapName, 31 )
  78. if( !containi( szMapName, "usp_" ) )
  79. {
  80. pause( "a" )
  81. }
  82.  
  83. if( file_exists( "motd2.html" ) == 1 )
  84. {
  85. b_RulesExist = true
  86. }
  87. else
  88. {
  89. b_RulesExist = false
  90.  
  91. log_amx( "A %s fájl nem található. Kérlek szerezd be, vagy az USP szabályok nem lesznek megjelenítve!", pRulesFile )
  92. }
  93.  
  94. register_clcmd( "say usprules", "uspRules", ADMIN_ALL, "Megjeleníti a MOTD Szabályokat" )
  95. register_clcmd( "say_team usprules", "uspRules", ADMIN_ALL, "Megjeleníti a MOTD Szabályokat" )
  96. register_clcmd( "say /usprules", "uspRules", ADMIN_ALL, "Megjeleníti a MOTD Szabályokat" )
  97. register_clcmd( "say_team /usprules", "uspRules", ADMIN_ALL, "Megjeleníti a MOTD Szabályokat" )
  98.  
  99. server_cmd( "mp_footsteps 0" )
  100.  
  101. pNoFallDamage = register_cvar( "un_nofalldamage", "1" ) // Gives the option to set no fall damage
  102. pHideTimer = register_cvar( "un_hidetimer", "25" ) // Time the hiders get to hide for
  103. pRulesFile = register_cvar( "un_rulesfile", "motd2.html" ) // Rules file to read from
  104. freezetime = get_cvar_pointer( "mp_freezetime" )
  105.  
  106. register_cvar( "usp_version", PLUGIN_VERS, FCVAR_SERVER|FCVAR_SPONLY )
  107.  
  108. g_iMaxPlayers = get_maxplayers( )
  109. g_iHudSyncMsg = CreateHudSyncObj( )
  110. g_pRestartPointer = get_cvar_pointer( "sv_restart" );
  111.  
  112. register_event( "HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0" )
  113.  
  114. register_logevent( "LogEvent_RoundStart", 2, "1=Round_Start" )
  115. register_logevent( "LogEvent_RoundEnd", 2, "0=World triggered", "1=Round_Draw", "1=Round_End" );
  116.  
  117. RegisterHam( Ham_Spawn, "player", "Fwd_PlayerSpawn_Post", 1 )
  118. RegisterHam( Ham_Killed, "player", "Fwd_PlayerKilled_Pre", 0 )
  119. RegisterHam( Ham_TakeDamage, "player", "Ham_CBasePlayer_TakeDamage_Pre" )
  120. RegisterHam( Ham_Item_Deploy, "weapon_usp", "Fwd_Usp_Deploy", 1 )
  121. RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_usp", "Fwd_Usp_SecondaryAttack", 1 )
  122. g_iHhResetMaxSpeed = RegisterHam( Ham_Player_ResetMaxSpeed, "player", "CBasePlayer_ResetMaxSpeed", 1 )
  123.  
  124. register_dictionary( "uspninjas.txt" )
  125. }
  126.  
  127. public Fwd_Usp_Deploy( iEnt )
  128. {
  129. set_usp_silent( iEnt )
  130.  
  131. SendWeaponAnim( get_weapon_owner( iEnt ), 6 )
  132. }
  133.  
  134. public Fwd_Usp_SecondaryAttack( iEnt )
  135. {
  136. set_usp_silent( iEnt )
  137. SendWeaponAnim( get_weapon_owner( iEnt ), 0 )
  138.  
  139. set_pdata_float( iEnt, m_flNextSecondaryAttack, 9999.9, EXTRAOFFSET_WEAPONS )
  140. }
  141.  
  142. public Event_HLTV_New_Round()
  143. {
  144. EnableHamForward( g_iHhResetMaxSpeed )
  145. }
  146.  
  147. public LogEvent_RoundEnd()
  148. {
  149. hideTimer()
  150.  
  151. if ( !GetTeam( CS_TEAM_T ) )
  152. {
  153. set_hudmessage(g_iHudColors[0], g_iHudColors[1], g_iHudColors[2], -1.0, 0.35, 0, 2.0, 2.0, 0.1, 0.2, -1)
  154. ShowSyncHudMsg(0, g_iHudSyncMsg, "- %L", LANG_PLAYER, "CT_WIN")
  155.  
  156. TeamSwitch()
  157. }
  158. else if ( !GetTeam( CS_TEAM_CT ) )
  159. {
  160. set_hudmessage(g_iHudColors[0], g_iHudColors[1], g_iHudColors[2], -1.0, 0.35, 0, 2.0, 2.0, 0.1, 0.2, -1)
  161. ShowSyncHudMsg(0, g_iHudSyncMsg, "- %L", LANG_PLAYER, "T_WIN")
  162. }
  163. else
  164. {
  165. set_hudmessage(g_iHudColors[0], g_iHudColors[1], g_iHudColors[2], -1.0, 0.35, 0, 2.0, 2.0, 0.1, 0.2, -1)
  166. ShowSyncHudMsg(0, g_iHudSyncMsg, "- %L -", LANG_PLAYER, "ROUND_DRAW")
  167. }
  168. }
  169.  
  170. public LogEvent_RoundStart()
  171. {
  172. DisableHamForward( g_iHhResetMaxSpeed )
  173. }
  174.  
  175. public CBasePlayer_ResetMaxSpeed( id )
  176. {
  177. if( is_user_connected( id ) && cs_get_user_team( id ) == CS_TEAM_T )
  178. {
  179. new Float:flMaxSpeed
  180.  
  181. new iActiveItem = get_pdata_cbase( id, m_pActiveItem, XTRA_OFS_PLAYER )
  182. if( iActiveItem > 0 )
  183. {
  184. ExecuteHam( Ham_CS_Item_GetMaxSpeed, iActiveItem, flMaxSpeed )
  185. }
  186. else
  187. {
  188. flMaxSpeed = 250.0
  189. }
  190.  
  191. set_pev( id, pev_maxspeed, flMaxSpeed )
  192. }
  193. }
  194.  
  195. public Fwd_PlayerSpawn_Post( id )
  196. {
  197. if ( !is_user_alive( id ) )
  198. return PLUGIN_HANDLED
  199.  
  200. else
  201. {
  202. new UspEntity = find_ent_by_owner( -1, "weapon_usp", id )
  203. new CsTeams:team = cs_get_user_team( id )
  204.  
  205. strip_user_weapons( id )
  206.  
  207. give_item ( id, "weapon_usp" )
  208. cs_set_user_bpammo ( id, 16, 24 )
  209. g_bSilencer[id] = bool:cs_get_weapon_silen(UspEntity)
  210.  
  211. give_item ( id, "weapon_knife" )
  212.  
  213. if( team == CS_TEAM_T )
  214. {
  215. g_bNoFallDamage[ id ] = false
  216. }
  217.  
  218. if( team != CS_TEAM_T )
  219. {
  220. set_pev( id, pev_takedamage, 0 )
  221.  
  222. set_task( 15.0, "removeSpawnProtect", id + TASK_ID )
  223.  
  224. g_bNoFallDamage[ id ] = true
  225. }
  226.  
  227. client_print( id, print_chat, "[USP] %L", id, "USP_RULES" )
  228.  
  229. return PLUGIN_CONTINUE
  230. }
  231. return PLUGIN_CONTINUE
  232. }
  233.  
  234. public Fwd_PlayerKilled_Pre(attacker, victim, gib)
  235. {
  236. if (!is_user_connected(victim))
  237. return
  238.  
  239. if (attacker == victim)
  240. return
  241.  
  242. new vName[32], aName[32]
  243.  
  244. get_user_name(victim, vName, 31)
  245. get_user_name(attacker, aName, 31)
  246.  
  247. if (!g_bSilencer[victim])
  248. {
  249. user_silentkill(attacker)
  250. user_silentkill(victim)
  251.  
  252. client_print(0, print_chat, "[USP] %L", LANG_PLAYER, "USP_KILLED_NOSILENCE", vName, aName)
  253. }
  254. }
  255.  
  256. public Ham_CBasePlayer_TakeDamage_Pre( const id, const iInflictor, const iAttacker, const Float:flDamage, const iDamageType )
  257. {
  258. if( iDamageType == DMG_FALL && g_bNoFallDamage[id] && get_pcvar_num( pNoFallDamage ) == 1 )
  259. {
  260. SetHamReturnInteger(0)
  261.  
  262. return HAM_SUPERCEDE
  263. }
  264. return HAM_IGNORED
  265. }
  266.  
  267. public removeSpawnProtect( get_id )
  268. {
  269. new protectid = get_id - TASK_ID
  270.  
  271. if( is_user_alive( protectid ) )
  272. set_pev( protectid, pev_takedamage, 1 )
  273. }
  274.  
  275. public uspRules( id )
  276. {
  277. if( b_RulesExist )
  278. {
  279. show_motd( id, "motd2.html" )
  280.  
  281. client_print( 0, print_chat, "%L", LANG_PLAYER, "USP_ADVERTISE", PLUGIN_NAME, PLUGIN_VERS )
  282. }
  283. else
  284. {
  285. client_print( id, print_chat, "[USP] %L", id, "USP_RULES_NOTFOUND" )
  286.  
  287. client_print( 0, print_chat, "%L", LANG_PLAYER, "USP_ADVERTISE", PLUGIN_NAME, PLUGIN_VERS )
  288. }
  289. }
  290.  
  291. public hideTimer()
  292. {
  293. if( get_pcvar_num( pHideTimer ) <= 0 )
  294. {
  295. set_pcvar_num( freezetime, 0 )
  296. }
  297. else
  298. {
  299. set_pcvar_num( freezetime, get_pcvar_num( pHideTimer ) )
  300. }
  301. return PLUGIN_CONTINUE
  302. }
  303.  
  304. GetTeam(CsTeams:iteam)
  305. {
  306. static Team
  307. Team = 0
  308.  
  309. for (new i = 1; i <= g_iMaxPlayers; i++)
  310. {
  311. if ( !is_user_alive(i) )
  312. continue;
  313.  
  314. if ( cs_get_user_team(i) == iteam )
  315. Team++
  316. }
  317. return Team
  318. }
  319.  
  320. SendWeaponAnim(id, iAnim)
  321. {
  322. entity_set_int( id, EV_INT_weaponanim, iAnim )
  323.  
  324. message_begin( MSG_ONE, SVC_WEAPONANIM, _, id )
  325. write_byte( iAnim )
  326. write_byte( entity_get_int( id, EV_INT_body ) )
  327. message_end( )
  328. }
  329.  
  330. TeamSwitch()
  331. {
  332. new CsTeams:Team
  333.  
  334. for (new i = 1; i <= g_iMaxPlayers; i++)
  335. {
  336. if (!is_user_connected(i))
  337. continue;
  338.  
  339. Team = cs_get_user_team(i)
  340.  
  341. switch(Team)
  342. {
  343. case CS_TEAM_CT: cs_set_user_team(i, CS_TEAM_T)
  344. case CS_TEAM_T: cs_set_user_team(i, CS_TEAM_CT)
  345. }
  346. }
  347. set_pcvar_num(g_pRestartPointer, 1)
  348. }
  349.