xj_timer

Started by Melf
18/05/2013 00:16
Page 1 of 1
Melf18/05/2013 00:16

how many times to press the start button?
xj_timer.sma help pleas!

Xunfop18/05/2013 01:50(edited 18/05/2013 01:53)

You mean attempt time?

Melf18/05/2013 09:10

yes

Xunfop18/05/2013 16:48(edited 18/05/2013 16:49)


#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.

Melf18/05/2013 19:23

This timer kzdemo.amxx??

Melf18/05/2013 19:35

does not work... start button is pressed once only.

Xunfop18/05/2013 20:01

just xj timer + attempt.

You use it for server? or why it need press more than once?

Melf18/05/2013 20:14

you do not understand. Now do video will show what the Trouble.

Melf18/05/2013 20:35

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

Melf18/05/2013 20:37

You can press the button once...
and I need to be able to press a lot of times

spermis18/05/2013 22:24(edited 18/05/2013 22:27)

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 :)

Xunfop19/05/2013 01:56

@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.

random Tournament #319/05/2013 13:59

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.

Melf20/05/2013 22:47

Thanks for the help guys.
Could you help me understand another problem?

Melf20/05/2013 23:39

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)

Page 1 of 1

Please log in to post replies.