Advertisement
RanAway

[PAWN] Respawn chance

Oct 4th, 2020 (edited)
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.82 KB | None | 0 0
  1. /************ Includes ************/
  2. #include < amxmodx >
  3. #include < fun >
  4. #include < cstrike >
  5. #include < hamsandwich >
  6.  
  7. /************ Defines ************/
  8. #define Prefix "AMXX"
  9. #define Timetowait 150
  10.  
  11. /************ News ************/
  12. new Float: respawnchance[ 32 ]
  13. new bool:RoundEnd = false
  14.  
  15. public plugin_init()
  16. {
  17.     register_plugin( "reviveme", "v1.0", "RanAway" )
  18.    
  19.     // clcmd
  20.     register_clcmd( "say /reviveme", "revive" )
  21.    
  22.     // Start / end round
  23.     register_logevent( "EventRoundStart", 2, "1=Round_Start" )
  24.     register_logevent( "EventEndRound", 2, "1=Round_End" )
  25. }
  26.  
  27. /************ Connect ************/
  28. public client_putinserver( id ) respawnchance[ id ] = get_gametime()
  29.  
  30. /************ Start / End round ************/
  31. public EventRoundStart( ) RoundEnd = false
  32. public EventEndRound( ) RoundEnd = true
  33.  
  34. /************ Respawn chance ************/
  35. public revive( id )
  36. {
  37.     /* if you spectator you can't use reviveme */
  38.     if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR )
  39.         return ColorChat( id, "Spectator can't use reviveme" )
  40.    
  41.     /* if the round ended it will say to wait for the next round */
  42.     if( RoundEnd )
  43.         return ColorChat( id, "The ^3round ended.^1 you dont want to waste your respawn chance" )
  44.    
  45.     /* you have to be dead to use reviveme */
  46.     if( is_user_alive( id ) )
  47.         return ColorChat( id, "You have to be ^3dead^1 before you can attampt to respawn" )
  48.    
  49.     /* countdown from each attempt */
  50.     else if( get_gametime() < respawnchance[ id ] + Timetowait )
  51.         return ColorChat( id, "Sorry you can't try to respawn now. try again in ^3%d^1 seconds", floatround( respawnchance[ id ] + Timetowait - get_gametime() + 1 ) )
  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.            
  63.             ColorChat( id, "yay, you got ^3respawn" )
  64.            
  65.             give_item( id, "weapon_knife" )
  66.             ExecuteHamB( Ham_CS_RoundRespawn, id )
  67.             client_cmd( id, "spk debris/beamstart9" )
  68.         }
  69.         case 34..99: ColorChat( id, "Sorry, you didnt respawn this time" )
  70.     }
  71.    
  72.     respawnchance[ id ] = get_gametime()
  73.     return 1
  74. }
  75.  
  76. /************ Color chat stock ************/
  77. stock ColorChat( const id, const string[], {Float, Sql, Resul,_}:...)
  78. {
  79.     new msg[191], players[32], count = 1
  80.    
  81.     static len
  82.     len = formatex(msg, charsmax(msg), "^3[^1 %s^3 ]^1 ", Prefix )
  83.     vformat(msg[len], charsmax(msg) - len, string, 3)
  84.    
  85.     if( id )
  86.         players[0] = id
  87.     else
  88.         get_players(players,count,"ch")
  89.    
  90.     for (new i = 0; i < count; i++)
  91.     {
  92.         if(is_user_connected(players[i]))
  93.         {
  94.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
  95.             write_byte(players[i])
  96.             write_string(msg)
  97.             message_end()
  98.         }
  99.     }
  100.     return 1
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement