IsraelNevo

[PAWN] Respawn chance

Jul 22nd, 2020
1,213
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <fun>
  3. #include <cstrike>
  4. #include <colorchat>
  5. #include <hamsandwich>
  6.  
  7. new Float: respawnchance[ 32 ]
  8. new bool:RoundEnd = false
  9.  
  10. public plugin_init()
  11. {
  12.     register_plugin( "reviveme", "v1.0", "shon" )
  13.    
  14.     register_clcmd( "say /reviveme", "revive" )
  15.    
  16.     register_logevent( "EventRoundStart", 2, "1=Round_Start" )
  17.     register_logevent( "EventEndRound", 2, "1=Round_End" )
  18. }
  19.  
  20. public EventRoundStart( )
  21. {
  22.     RoundEnd = false
  23. }
  24.  
  25. public EventEndRound( )
  26. {
  27.     RoundEnd = true
  28. }
  29.  
  30. public revive( id )
  31. {  
  32.     if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
  33.     {
  34.         ColorChat( id, NORMAL, "Spectator can't use reviveme" )
  35.         return PLUGIN_HANDLED
  36.     }
  37.     if( RoundEnd )
  38.     {
  39.         ColorChat( id, NORMAL, "The ^3round ended.^1 you dont want to waste your respawn chance" )
  40.         return PLUGIN_HANDLED
  41.     }
  42.     if( is_user_alive( id ) == 1 )
  43.     {
  44.         ColorChat( id, NORMAL, "You have to be ^3dead^1 before you can attampt to respawn" )
  45.         return PLUGIN_HANDLED
  46.     }
  47.     else if( get_gametime() < respawnchance[ id ] + 150 )
  48.     {
  49.         ColorChat( id, NORMAL, "Sorry you can't try to respawn now. try again in ^3%d^1 seconds", floatround(respawnchance[ id ] + 150 - get_gametime() + 1))
  50.         return PLUGIN_HANDLED
  51.     }
  52.    
  53.     switch( random_num( 1, 99 ))
  54.     {
  55.         case 1..33:
  56.         {
  57.             new name[ 32 ]
  58.             get_user_name( id, name, 32 )
  59.            
  60.             set_hudmessage( random( 255 ), random( 255 ), random( 255 ),-1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1 )
  61.             show_hudmessage( 0, "%s won and has been respawned", name )
  62.             ColorChat( id, NORMAL, "yay, you got ^3respawn" )
  63.  
  64.            
  65.             ExecuteHamB( Ham_CS_RoundRespawn, id )
  66.             give_item(id,"weapon_knife")
  67.             client_cmd( id, "spk debris/beamstart9" )
  68.         }
  69.         case 34..99: ColorChat( id, NORMAL, "Sorry, you didnt respawn this time" )
  70.     }
  71.     respawnchance[ id ] = get_gametime()
  72.     return PLUGIN_HANDLED
  73. }
RAW Paste Data