Advertisement
RanAway

[ Pawn - small plugins ] respawn chance

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