Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-------------------- Includes --------------------//
- #include < amxmodx >
- #include < engine >
- //-------------------- Defines --------------------//
- #define Prefix "AMXX"
- #define Timetowait 180
- #define Chancetowin 33 // ( 33 / 100 ) | 33 to win - 67 to lose
- //-------------------- Functions --------------------//
- new Timeleft[ 32 ], bool:RoundEnd = false
- //-------------------- Plugin init --------------------//
- public plugin_init()
- {
- register_plugin( "reviveme", "v1.0", "RanAway" )
- //-------------------- commands --------------------//
- register_clcmd( "say /reviveme", "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, "AddTime", id, _, _, "b" )
- //-------------------- Start / end round --------------------//
- public newround() RoundEnd = false
- public endround() RoundEnd = true
- //-------------------- Task for timeleft --------------------//
- public AddTime( id ) if( --Timeleft[ id ] <= 0 ) remove_task( id )
- //-------------------- Respawn chance --------------------//
- public revive( id )
- {
- //-------------------- to prevent heap low --------------------//
- if( !is_user_connected( id ) ) return 0
- //--------- if you spectator you can't use reviveme ---------//
- 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." )
- //--------- you have to be dead to use reviveme ---------//
- 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 change 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, "AddTime", id, _, _, "b" )
- return ColorChat( id, number >= Chancetowin ? "yay, you got ^3respawn." : "Sorry, you didnt respawn this time." )
- }
- //-------------------- Stocks - ColorChat --------------------//
- stock ColorChat( id, const string[], any:... )
- {
- new msg[ 191 ], players[ 32 ], count = 1
- new len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
- vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
- if( id )
- players[ 0 ] = id
- else
- get_players( players, count, "ch" )
- for( new i = 0; i < count; i++ )
- {
- if( is_user_connected( players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
- write_byte( players[ i ] )
- write_string( msg )
- message_end()
- }
- }
- return 1
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement