Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------- Includes --------------------//
- #include < amxmodx >
- #include < engine >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX" // prefix
- #define RespawnTaskID 1550 // TaskID
- #define Timetowait 180 // default time
- #define Chancetowin 33 // ( 33 / 100 ) | 33 to win - 67 to lose
- //-------------------- commands listt --------------------//
- new cmdlist[][] = { "reviveme", "/reviveme", "respawn", "/respawn" }
- //-------------------- Functions --------------------//
- new Timeleft[ 32 ], bool:RoundEnd = false
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "reviveme", "v1.0", "RanAway`" )
- //-------------------- commands --------------------//
- for( new i = 0; i < sizeof( cmdlist ); i++ ) register_clcmd( fmt( "say %s", cmdlist[ i ] ), "revive" )
- //-------------------- Start / end round --------------------//
- register_logevent( "newround", 2, "1=Round_Start" )
- register_logevent( "endround", 2, "1=Round_End" )
- }
- //-------------------- Authorized --------------------//
- public client_authorized( id ) Timeleft[ id ] = Timetowait, set_task( 1.0, "RespawnTimeLeft", id + RespawnTaskID, .flags = "b" )
- //-------------------- Start / end round --------------------//
- public newround() RoundEnd = false
- public endround() RoundEnd = true
- //-------------------- Task for timeleft --------------------//
- public RespawnTimeLeft( id ) if( --Timeleft[ id ] <= 0 && task_exists( id + RespawnTaskID ) ) remove_task( id + RespawnTaskID )
- //-------------------- Respawn chance --------------------//
- public revive( id )
- {
- //-------------------- if the player not connected --------------------//
- if( !is_user_connected( id ) ) return 0
- //--------- if the player is spectator ---------//
- if( get_user_team( id ) == 3 ) return ColorChat( id, "Spectator can't use reviveme." )
- //--------- if the round ended it will say to wait for the next round ---------//
- if( RoundEnd ) return ColorChat( id, "Cant use ^3reviveme^1 because the round has ended." )
- //--------- if the player is dead ---------//
- if( is_user_alive( id ) ) return ColorChat( id, "You have to be ^3dead^1 in order to use ^3reviveme^1." )
- //--------- countdown from each attempt ---------//
- if( Timeleft[ id ] > 0 )
- {
- new text[ 64 ]
- format_time( text, charsmax( text ), "^3%M^1:^3%S^1", Timeleft[ id ] )
- 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" : "" )
- }
- //--------- the chance for respawn ---------//
- new number = random_num( 1, 99 )
- if( number >= Chancetowin )
- {
- set_hudmessage( random( 255 ), random( 255 ), random( 255 ), -1.0, 0.30, 0, 6.0, 6.0, 0.5, 0.15, 1 )
- show_hudmessage( 0, "%n won and has been respawned", id )
- DispatchSpawn( id )
- client_cmd( id, "spk debris/beamstart9" )
- }
- Timeleft[ id ] = Timetowait
- set_task( 1.0, "RespawnTimeLeft", id + RespawnTaskID, .flags = "b" )
- return ColorChat( id, number >= Chancetowin ? "yay, you got ^3respawn^1." : "Sorry, you didnt respawn this time." )
- }
- //-------------------- Stocks - ColorChat --------------------//
- stock ColorChat( id, const string[], any:... )
- {
- new msg[ 191 ], len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- client_print_color( id, print_team_default, msg )
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement