Advertisement
RanAway

[ Pawn - small plugins ] respawn chance

Oct 4th, 2020 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.45 KB | None | 0 0
  1. //-------------------- Includes --------------------//
  2. #include < amxmodx >
  3. #include < engine >
  4.  
  5. //-------------------- Defines --------------------//
  6. #define Prefix                  "AMXX"
  7. #define Timetowait              180    
  8. #define Chancetowin             33      // ( 33 / 100 ) | 33 to win - 67 to lose
  9.  
  10. //-------------------- Functions --------------------//
  11. new Timeleft[ 32 ], bool:RoundEnd = false
  12.  
  13. //-------------------- Plugin init --------------------//
  14. public plugin_init()
  15. {
  16.     register_plugin( "reviveme", "v1.0", "RanAway" )
  17.  
  18.     //-------------------- commands --------------------//
  19.     register_clcmd( "say /reviveme", "revive" )
  20.  
  21.     //-------------------- Start / end round --------------------//
  22.     register_logevent( "newround", 2, "1=Round_Start" )
  23.     register_logevent( "endround", 2, "1=Round_End" )
  24. }
  25.  
  26. //-------------------- Authorized --------------------//
  27. public client_authorized( id ) Timeleft[ id ] = Timetowait, set_task( 1.0, "AddTime", id, _, _, "b" )
  28.  
  29. //-------------------- Start / end round --------------------//
  30. public newround() RoundEnd = false
  31. public endround() RoundEnd = true
  32.  
  33. //-------------------- Task for timeleft --------------------//
  34. public AddTime( id ) if( --Timeleft[ id ] <= 0 ) remove_task( id )
  35.  
  36. //-------------------- Respawn chance --------------------//
  37. public revive( id )
  38. {
  39.     //-------------------- to prevent heap low --------------------//
  40.     if( !is_user_connected( id ) ) return 0
  41.  
  42.     //--------- if you spectator you can't use reviveme ---------//
  43.     if( get_user_team( id ) == 3 ) return ColorChat( id, "Spectator can't use reviveme." )
  44.  
  45.     //--------- if the round ended it will say to wait for the next round ---------//
  46.     if( RoundEnd ) return ColorChat( id, "Cant use ^3reviveme^1 because the round has ended." )
  47.  
  48.     //--------- you have to be dead to use reviveme ---------//
  49.     if( is_user_alive( id ) ) return ColorChat( id, "You have to be ^3dead^1 in order to use ^3reviveme^1." )
  50.  
  51.     //--------- countdown from each attempt ---------//
  52.     if( Timeleft[ id ] > 0 )
  53.     {
  54.         new text[ 64 ]
  55.         format_time( text, charsmax( text ), "^3%M^1:^3%S^1", Timeleft[ id ] )
  56.         return ColorChat( id, "sorry you cant respawn at the moment please try again in %s %s%s.", text, Timeleft[ id ] >= 60 ? "minute" : "second", Timeleft[ id ] / ( Timeleft[ id ] >= 60 ? 60 : 1 ) != 1 ? "s" : "" )
  57.     }
  58.  
  59.     //--------- the change for respawn ---------//
  60.     new number = random_num( 1, 99 )
  61.     if( number >= Chancetowin )
  62.     {
  63.         set_hudmessage( random( 255 ), random( 255 ), random( 255 ), -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1 )
  64.         show_hudmessage( 0, "%n won and has been respawned", id )
  65.         DispatchSpawn( id )
  66.         client_cmd( id, "spk debris/beamstart9" )
  67.     }
  68.  
  69.     Timeleft[ id ] = Timetowait
  70.     set_task( 1.0, "AddTime", id, _, _, "b" )
  71.     return ColorChat( id, number >= Chancetowin ? "yay, you got ^3respawn." : "Sorry, you didnt respawn this time." )
  72. }
  73.  
  74. //-------------------- Stocks - ColorChat --------------------//
  75. stock ColorChat( id, const string[], any:... )
  76. {
  77.     new msg[ 191 ], players[ 32 ], count = 1
  78.  
  79.     new len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  80.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  81.  
  82.     if( id )
  83.         players[ 0 ] = id
  84.     else
  85.         get_players( players, count, "ch" )
  86.  
  87.     for( new i = 0; i < count; i++ )
  88.     {
  89.         if( is_user_connected( players[ i ] ) )
  90.         {
  91.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
  92.             write_byte( players[ i ] )
  93.             write_string( msg )
  94.             message_end()
  95.         }
  96.     }
  97.     return 1
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement