Stopwatch (with start and stop position)

Started by SchlumPF
9 Jun 2008, 17:54
Page 1 of 1
9 Jun 2008, 17:54(edited 26 Jun 2008, 12:28)

This plugin is SAFE for demo recording. -Fatalis

Stopwatch

Description
This plugin allows every player to create a startpostion and endposition which are marked by a green (start) and red (stop) glowing c4-model. On touch a timer will be started which will show you the time you needed to move from the startpositon to the endposition. This plugin is especially made for those who like to record demos and do not know which way is the fastest.

More information in the readme.txt!

DOWNLOAD ME!

18 Mar 2009, 13:29

Big, big thanks from me!

18 Mar 2009, 15:05

reupload please

18 Mar 2009, 17:51

the dl link is still available

8 Oct 2009, 13:43

thank you, thank you very very much.

23 Nov 2009, 15:41

thanks man great plugin

23 Nov 2009, 17:37

Oh ,nice.

I can now improve my time on kz_kzdk_templebhop climb -,,,-

30 Jan 2010, 14:48

can u post a stopwatch plugin, after u press start -do run- press stop and it prints in chat what time u got ? thx

27 Jul 2014, 03:09

Can someone reupload the .sma for this?

27 Jul 2014, 03:56

you could use 1 of this
https://www.sendspace.com/file/6rqrpt

27 Jul 2014, 04:08

Originally posted by KarLi
you could use 1 of this
https://www.sendspace.com/file/6rqrpt

Thanks, but this isn't what I'm looking for. I'm looking for SchlumPF's version.

27 Jul 2014, 04:46(edited 27 Jul 2014, 04:49)

well i think thats the source


#include
#include
#include

#pragma semicolon 1

new g_bStopwatchStarted[33];

new g_iLocId[2][33];
new Float:g_fLoc[2][33][3];

new g_iMaxPlayers;
new g_iSayText;

public plugin_init( )
{
register_plugin( "Stopwatch", "1.1b", "SchlumPF*" );
register_clcmd( "say /stopwatch", "menuDisplay" );
register_menucmd( register_menuid( "\rStopwatch - SchlumPF^n^n" ), 1023, "menuAction" );
register_forward( FM_Touch, "fwdTouch" );

g_iSayText = get_user_msgid( "SayText" );
g_iMaxPlayers = get_maxplayers( );
}

public menuDisplay( plr )
{
static menu[2048];
new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<9 );

new len = format( menu, sizeof menu - 1, "\rStopwatch - SchlumPF^n^n" );

len += format( menu[len], sizeof menu - len, "\r01. \wStart Loc^n" );
len += format( menu[len], sizeof menu - len, "\r02. \wFinish Loc^n" );
len += format( menu[len], sizeof menu - len, "\r03. \wReset Locs^n^n" );
len += format( menu[len], sizeof menu - len, "\r00. \wExit" );

show_menu( plr, keys, menu, -1 );

return PLUGIN_HANDLED;
}

public menuAction( plr, key )
{
switch( key )
{
case 0:
{
fnCreateLoc( plr, "start" );
menuDisplay( plr );
}
case 1:
{
fnCreateLoc( plr, "stop" );
menuDisplay( plr );
}
case 2:
{
fnResetLocs( plr );
menuDisplay( plr );
}
case 9: show_menu( plr, 0, "" );
}

return PLUGIN_HANDLED;
}

public fnCreateLoc( plr, type[] )
{
if( equali( type, "start" ) )
{
if( g_iLocId[0][plr] )
{
fnGreenChat( plr, "[Stopwatch] ^x01You have to delete the loc first" );
return 0;
}
}
else if( equali( type, "stop" ) )
{
if( g_iLocId[1][plr] )
{
fnGreenChat( plr, "[Stopwatch] ^x01You have to delete the loc first" );
return 0;
}
}

new Float:origin[3];
pev( plr, pev_origin, origin );

new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );

set_pev( ent, pev_solid, SOLID_TRIGGER );
set_pev( ent, pev_movetype, MOVETYPE_NONE );
engfunc( EngFunc_SetModel, ent, "models/w_c4.mdl" );
engfunc( EngFunc_SetSize, ent, Float:{ -16.0, -16.0, -16.0 }, Float:{ 16.0, 16.0, 16.0 } );
engfunc( EngFunc_SetOrigin, ent, origin );

if( equali( type, "start" ) )
{
set_pev( ent, pev_classname, "start" );
fm_set_rendering( ent, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16 );

g_iLocId[0][plr] = ent;

g_fLoc[0][plr][0] = origin[0];
g_fLoc[0][plr][1] = origin[1];
g_fLoc[0][plr][2] = origin[2];
}
else if( equali( type, "stop" ) )
{
set_pev( ent, pev_classname, "stop" );
fm_set_rendering( ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 16 );

g_iLocId[1][plr] = ent;

g_fLoc[1][plr][0] = origin[0];
g_fLoc[1][plr][1] = origin[1];
g_fLoc[1][plr][2] = origin[2];
}

return 1;
}

public fnResetLocs( plr )
{
if( g_iLocId[0][plr] )
{
engfunc( EngFunc_RemoveEntity, g_iLocId[0][plr] );
g_iLocId[0][plr] = 0;
}

if( g_iLocId[1][plr] )
{
engfunc( EngFunc_RemoveEntity, g_iLocId[1][plr] );
g_iLocId[1][plr] = 0;
}
}

public fwdTouch( touched, plr )
{
if( is_user_alive( plr ) )
{
static Float:kztime[33];

if( touched == g_iLocId[0][plr] && touched )
{
kztime[plr] = get_gametime( );
g_bStopwatchStarted[plr] = true;

client_print( plr, print_center, "stopwatch started" );
}
else if( touched == g_iLocId[1][plr] && touched && g_bStopwatchStarted[plr] )
{
g_bStopwatchStarted[plr] = false;

client_print( plr, print_center, "stopwatch stopped" );
fnGreenChat( plr, "[Stopwatch] ^x01You have wasted %f seconds of time ", get_gametime( ) - kztime[plr] );
}
}
}

public client_connect( plr )
g_bStopwatchStarted[plr] = false;

public client_disconnect( plr )
fnResetLocs( plr );

// by fatalis
fnGreenChat( plr, const message[], {Float,Sql,Result,_}:... )
{
static msg[192];
msg[0] = 0x04;

vformat( msg[1], sizeof msg - 2, message, 3 );

if( plr > 0 && plr <= g_iMaxPlayers )
{
message_begin( MSG_ONE, g_iSayText, { 0, 0, 0 }, plr );
write_byte( plr );
write_string( msg );
message_end( );
}
else if( plr == 0 )
{
for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( !is_user_connected( i ) )
continue;

message_begin( MSG_ONE, g_iSayText, { 0, 0, 0 }, i );
write_byte( i );
write_string( msg );
message_end( );
}
}

return 1;
}

peace

27 Jul 2014, 04:48

Thank you KarLi!

27 Jul 2014, 04:49

anytime =)

reupload pls

9 Apr 2015, 21:24

p0ker just go to this site : https://www.amxmodx.org/webcompiler.cgi

and there copy this text (Karli's one has bad #including)

#include 
#include
#include
#pragma semicolon 1

new g_bStopwatchStarted[33];

new g_iLocId[2][33];
new Float:g_fLoc[2][33][3];

new g_iMaxPlayers;
new g_iSayText;

public plugin_init( )
{
register_plugin( "Stopwatch", "1.1b", "SchlumPF*" );
register_clcmd( "say /stopwatch", "menuDisplay" );
register_menucmd( register_menuid( "rStopwatch - SchlumPF^n^n" ), 1023, "menuAction" );
register_forward( FM_Touch, "fwdTouch" );

g_iSayText = get_user_msgid( "SayText" );
g_iMaxPlayers = get_maxplayers( );
}

public menuDisplay( plr )
{
static menu[2048];
new keys = ( 1<<0 | 1<<1 | 1<<2 | 1<<9 );

new len = format( menu, sizeof menu - 1, "rStopwatch - SchlumPF^n^n" );

len += format( menu[len], sizeof menu - len, "r01. wStart Loc^n" );
len += format( menu[len], sizeof menu - len, "r02. wFinish Loc^n" );
len += format( menu[len], sizeof menu - len, "r03. wReset Locs^n^n" );
len += format( menu[len], sizeof menu - len, "r00. wExit" );

show_menu( plr, keys, menu, -1 );

return PLUGIN_HANDLED;
}

public menuAction( plr, key )
{
switch( key )
{
case 0:
{
fnCreateLoc( plr, "start" );
menuDisplay( plr );
}
case 1:
{
fnCreateLoc( plr, "stop" );
menuDisplay( plr );
}
case 2:
{
fnResetLocs( plr );
menuDisplay( plr );
}
case 9: show_menu( plr, 0, "" );
}

return PLUGIN_HANDLED;
}

public fnCreateLoc( plr, type[] )
{
if( equali( type, "start" ) )
{
if( g_iLocId[0][plr] )
{
fnGreenChat( plr, "[Stopwatch] ^x01You have to delete the loc first" );
return 0;
}
}
else if( equali( type, "stop" ) )
{
if( g_iLocId[1][plr] )
{
fnGreenChat( plr, "[Stopwatch] ^x01You have to delete the loc first" );
return 0;
}
}

new Float:origin[3];
pev( plr, pev_origin, origin );

new ent = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "info_target" ) );

set_pev( ent, pev_solid, SOLID_TRIGGER );
set_pev( ent, pev_movetype, MOVETYPE_NONE );
engfunc( EngFunc_SetModel, ent, "models/w_c4.mdl" );
engfunc( EngFunc_SetSize, ent, Float:{ -16.0, -16.0, -16.0 }, Float:{ 16.0, 16.0, 16.0 } );
engfunc( EngFunc_SetOrigin, ent, origin );

if( equali( type, "start" ) )
{
set_pev( ent, pev_classname, "start" );
fm_set_rendering( ent, kRenderFxGlowShell, 0, 255, 0, kRenderNormal, 16 );

g_iLocId[0][plr] = ent;

g_fLoc[0][plr][0] = origin[0];
g_fLoc[0][plr][1] = origin[1];
g_fLoc[0][plr][2] = origin[2];
}
else if( equali( type, "stop" ) )
{
set_pev( ent, pev_classname, "stop" );
fm_set_rendering( ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 16 );

g_iLocId[1][plr] = ent;

g_fLoc[1][plr][0] = origin[0];
g_fLoc[1][plr][1] = origin[1];
g_fLoc[1][plr][2] = origin[2];
}

return 1;
}

public fnResetLocs( plr )
{
if( g_iLocId[0][plr] )
{
engfunc( EngFunc_RemoveEntity, g_iLocId[0][plr] );
g_iLocId[0][plr] = 0;
}

if( g_iLocId[1][plr] )
{
engfunc( EngFunc_RemoveEntity, g_iLocId[1][plr] );
g_iLocId[1][plr] = 0;
}
}

public fwdTouch( touched, plr )
{
if( is_user_alive( plr ) )
{
static Float:kztime[33];

if( touched == g_iLocId[0][plr] && touched )
{
kztime[plr] = get_gametime( );
g_bStopwatchStarted[plr] = true;

client_print( plr, print_center, "stopwatch started" );
}
else if( touched == g_iLocId[1][plr] && touched && g_bStopwatchStarted[plr] )
{
g_bStopwatchStarted[plr] = false;

client_print( plr, print_center, "stopwatch stopped" );
fnGreenChat( plr, "[Stopwatch] ^x01You have wasted %f seconds of time ", get_gametime( ) - kztime[plr] );
}
}
}

public client_connect( plr )
g_bStopwatchStarted[plr] = false;

public client_disconnect( plr )
fnResetLocs( plr );

// by fatalis
fnGreenChat( plr, const message[], {Float,Sql,Result,_}:... )
{
static msg[192];
msg[0] = 0x04;

vformat( msg[1], sizeof msg - 2, message, 3 );

if( plr > 0 && plr <= g_iMaxPlayers )
{
message_begin( MSG_ONE, g_iSayText, { 0, 0, 0 }, plr );
write_byte( plr );
write_string( msg );
message_end( );
}
else if( plr == 0 )
{
for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( !is_user_connected( i ) )
continue;

message_begin( MSG_ONE, g_iSayText, { 0, 0, 0 }, i );
write_byte( i );
write_string( msg );
message_end( );
}
}

return 1;
}


and then just download it, and put it on your /plguins folder and plugins.ini

29 Jan 2019, 16:43(edited 29 Jan 2019, 16:44)

Image

[blockquote]Modes:
- Touch (be inside the zone)
- Jump (jump inside the zone)
- Touch + ONGROUND (STAND inside the zone)
[/blockquote]

DOWNLOAD

1 Feb 2019, 20:05

thx juice, very nice :)
the "current marks best time" is not working for me however. but maybe im just dumb :D
gj

Page 1 of 1

Reply

Please log in to post replies.