xj_timer
how many times to press the start button?
xj_timer.sma help pleas!
You mean attempt time?
yes
#include < amxmodx >
#include < engine >
#include < hamsandwich >
new g_iMsgSayText, Float:g_flStartDelay, Float:g_flStartTime[ 33 ], Trie:g_tStarts, Trie:g_tStops;
new attempt;
public plugin_init( ) {
register_plugin( "XJ DecimalTimer", "1.0", "xPaw" );
g_iMsgSayText = get_user_msgid( "SayText" );
g_tStarts = TrieCreate( );
g_tStops = TrieCreate( );
new szMap[ 21 ], i;
get_mapname( szMap, 20 );
if( equali( szMap, "kz_a2_bhop_corruo_ez" )
|| equali( szMap, "kz_a2_bhop_corruo_h" )
|| equali( szMap, "kz_a2_godspeed" ) ) {
RegisterHam( Ham_Touch, "func_button", "FwdHamButtonTouch" );
}
else if( equali( szMap, "kz_man_climbrace" ) ) {
RegisterHam( Ham_Think, "func_breakable", "FwdHamBreakableThink" );
RegisterHam( Ham_Touch, "trigger_multiple", "FwdHamMultipleTouch" );
} else {
if( equali( szMap, "kz_cup_storage" ) )
g_flStartDelay = 5.0;
RegisterHam( Ham_Use, "func_button", "FwdHamButtonUse" );
}
register_logevent( "LogEvent_StartRound", 2,"0=World triggered", "1=Round_Start" );
new const szStarts[ ][ ] = {
"counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
"multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
};
new const szStops[ ][ ] = {
"counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
"multi_stop", "stop_counter", "m_counter_end_emi"
};
for( i = 0; i < sizeof szStarts; i++ )
TrieSetCell( g_tStarts, szStarts[ i ], 1 );
for( i = 0; i < sizeof szStops; i++ )
TrieSetCell( g_tStops, szStops[ i ], 1 );
}
public plugin_end( ) {
TrieDestroy( g_tStarts );
TrieDestroy( g_tStops );
}
public client_disconnect( id )
g_flStartTime[ id ] = 0.0;
public LogEvent_StartRound( ) {
arrayset( _:g_flStartTime, _:0.0, 33 );
attempt++;
}
public FwdHamMultipleTouch( const iEntity, const id )
if( is_user_alive( id ) )
Timer_Stop( id );
public FwdHamBreakableThink( const iEntity ) {
new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "a" );
if( iNum )
for( new i; i < iNum; i++ )
Timer_Start( iPlayers[ i ] );
}
public FwdHamButtonUse( const iEntity, const id ) {
if( !is_user_alive( id ) )
return;
new szTarget[ 32 ];
entity_get_string( iEntity, EV_SZ_target, szTarget, 31 );
if( TrieKeyExists( g_tStarts, szTarget ) )
Timer_Start( id );
else if( TrieKeyExists( g_tStops, szTarget ) )
Timer_Stop( id );
}
public FwdHamButtonTouch( const iEntity, const id ) {
if( !is_user_alive( id ) )
return;
static const START[ ] = "gogogo";
static const STOP[ ] = "stop_counter";
new szTarget[ 32 ];
entity_get_string( iEntity, EV_SZ_target, szTarget, 31 );
if( equal( szTarget, START ) )
Timer_Start( id );
else if( equal( szTarget, STOP ) )
Timer_Stop( id );
}
public Timer_Start( const id ) {
if( g_flStartTime[ id ] )
return;
g_flStartTime[ id ] = get_gametime( );
client_print( id, print_chat, "[XJ] You have started the timer!" );
}
Timer_Stop( const id ) {
if( !g_flStartTime[ id ] )
return;
new szTime[ 15 ], szMessage[ 128 ];
ClimbtimeToString( ( get_gametime( ) - g_flStartTime[ id ] - g_flStartDelay ), szTime, 14 );
g_flStartTime[ id ] = 0.0;
formatex( szMessage, 127, "^1[XJ] You finished the map in:^3 %s^1! Congratulations.", szTime );
SendSayText( id, szMessage );
client_print( id, print_chat, "[XJ] Attempt record a demo #%d", (!attempt ? 1 : attempt) );
new iPlayers[ 32 ], iNum;
get_players( iPlayers, iNum, "b" );
if( iNum ) {
new szNick[ 32 ], iPlayer;
get_user_name( id, szNick, 31 );
formatex( szMessage, 127, "^1[XJ]^4 %s^1 has finished the map in:^3 %s^1!", szNick, szTime );
for( new i; i < iNum; i++ ) {
iPlayer = iPlayers[ i ];
// if( ( 1 << entity_get_int( iPlayer, EV_INT_iuser1 ) ) & ( ( 1 << 1 ) | ( 1 << 2 ) | ( 1 << 4 ) ) &&
if( id == entity_get_int( iPlayer, EV_INT_iuser2 ) )
SendSayText( iPlayer, szMessage );
}
}
}
ClimbtimeToString( const Float:flClimbTime, szOutPut[ ], const iLen ) {
new iMinutes = floatround( flClimbTime / 60.0, floatround_floor );
new iSeconds = floatround( flClimbTime - iMinutes * 60, floatround_floor );
new iMiliSeconds = floatround( ( flClimbTime - ( iMinutes * 60 + iSeconds ) ) * 100, floatround_floor );
formatex( szOutPut, iLen, "%02i:%02i.%02i", iMinutes, iSeconds, iMiliSeconds );
}
SendSayText( const id, const szMessage[ ] ) {
message_begin( MSG_ONE_UNRELIABLE, g_iMsgSayText, _, id );
write_byte( id );
write_string( szMessage );
message_end( );
}
Copy from kzdemo, should be work, untested.
This timer kzdemo.amxx??
does not work... start button is pressed once only.
just xj timer + attempt.
You use it for server? or why it need press more than once?
you do not understand. Now do video will show what the Trouble.
That's how I http://www.youtube.com/watch?v=lXawLNjvPt0
here so I need to http://www.youtube.com/watch?v=HwjcEYvPejE&feature=youtu.be
You can press the button once...
and I need to be able to press a lot of times
He wants to make the timer restart each time you press the start button.
Thats not possible/allowed if you want it for recording WR demos.
Unless, of course, someone makes this very neat plugin that allows you to start timer again and again, without sv_restart 1 on WRs :P
What do you think coders? Would that be possible to restart timer/hp/all breakable objects etc, just like after sv_restart 1, except without restarting and just pressing the button one more time.
E.g: use /start command (which teleports you to start) and press the start button for a new run :)
@Melf
As spermis said, you have restart new round before you press start button.
If you it take too long to restart new round, you can try kzdemo.
It only spend 0.1 sec to restart new round.
@spermis
I'm not coder, only know a bit coding knowledge.
Why not use new kzdemo v1.8, you just need bind "key" say /kzdemo, its same thing what you asking, no sv_restart 1, 0.1sec rr and you on the start position.
Thanks for the help guys.
Could you help me understand another problem?
The guys here are such a problem:
plugin (prokreedz)
how to move the "Checkpoint / Gocheck" to the left.
how to swap items on the menu?
how to make a message which show that the person has passed in Spectators.
how to make messages "[XJ] You have started the timer!" and other, show up in the chat.
"Checkpoint/Gocheck" in HUD.
I hope you understand what I need...
I hope for your help guys.
Thanks in advance.
here screenshot: http://cs418927.vk.me/v418927697/4e4c/HDjdZHGqULc.jpg
Sorry for my English... (Google Translate)
Please log in to post replies.