Stopwatch Plugin

Started by s1gh
19/03/2008 20:34
Page 2 of 2
stask0 Tournament #220/03/2008 23:56(edited 20/03/2008 23:57)

Click me

you have to put it at cstrike/addons/amxmodx/scripting/include

poison_art21/03/2008 14:11

thx!!

SchlumPF21/03/2008 16:52(edited 21/03/2008 16:57)

new small bug... the fix i posted needs to eb fixed :) stopwatch will also be satrted if you touch worldspawn
fix:


/* Plugin generated by AMXX-Studio */

#include
#include
#include

#pragma semicolon 1

new const g_Plugin[] = "Stopwatch";
new const g_Version[] = "0.12";
new const g_Author[] = "SchlumPF";

new g_bStopwatchStarted[33];

new g_iLocId[2][33];
new Float:g_fLoc[2][33][3];
#define START 0
#define STOP 1

public plugin_init( )
{
register_plugin( g_Plugin, g_Version, g_Author );

register_clcmd( "say /stopwatch", "menuDisplay" );

register_menucmd( register_menuid( "\rStopwatch - SchlumPF^n^n" ), 1023, "menuAction" );

register_forward( FM_Touch, "fwdTouch" );
}

public menuDisplay( plr )
{
static menu[2048];
static 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" );
case 1: fnCreateLoc( plr, "stop" );
case 2: fnResetLocs( plr );
case 9: show_menu( plr, 0, "" );
}

if( key < 9 )
menuDisplay( plr );

return PLUGIN_HANDLED;
}

public fnCreateLoc( plr, type[] )
{
if( equali( type, "start" ) )
{
if( g_iLocId[START][plr] )
{
client_print( plr, print_chat, "^x04[Stopwatch] ^x01You have to delete locs first" );
return 0;
}
}
else if( equali( type, "stop" ) )
{
if( g_iLocId[STOP][plr] )
{
client_print( plr, print_chat, "^x04[Stopwatch] ^x01You have to delete locs first" );
return 0;
}
}

static 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[START][plr] = ent;

g_fLoc[START][plr][0] = origin[0];
g_fLoc[START][plr][1] = origin[1];
g_fLoc[START][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[STOP][plr] = ent;

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

return 1;
}

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

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

return 1;
}

public fwdTouch( touched, plr )
{
if( !is_user_alive( plr ) )
return FMRES_IGNORED;

static Float:fTime[33];

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

client_print( plr, print_center, "stopwatch started" );
}
else if( touched == g_iLocId[STOP][plr] && g_iLocId[STOP][plr] != 0 && g_bStopwatchStarted[plr] )
{
new Float:fStopTime = get_gametime( ) - fTime[plr];
g_bStopwatchStarted[plr] = false;

client_print( plr, print_center, "stopwatch stopped" );
client_print( plr, print_chat, "^x04[Stopwatch] ^x01You have wasted %f seconds of time :E", fStopTime );
}

return FMRES_HANDLED;
}

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



edit:
haha im just stupid :E forgot to remove some code in it which i needed for testing. hope this is the final update ^^ did compile fine but did not test

Alucard^21/03/2008 23:50(edited 21/03/2008 23:53)

/home/groups/amxmodx/tmp3/texto1agLF.sma(5) : fatal error 100: cannot read from file: "fakemeta_util"

help plz

stask0 Tournament #222/03/2008 01:08(edited 22/03/2008 01:08)

Originally posted by stask0
Click me - fakemeta_util.inc

you have to put it at cstrike/addons/amxmodx/scripting/include

wRath` mapper22/03/2008 02:02

So can anyone upload a fixed version?
I don't want to start adding this and that, to make it right.

SchlumPF22/03/2008 14:38

http://rapidshare.de/files/38897246/Stopwatch.rar.html

wRath` mapper22/03/2008 18:05

Thank you schlumPF!

Cr34t!v320/05/2008 20:27

schkumPF, put on prees +use, no in touch :D.

My bad English...

SchlumPF21/05/2008 16:19

i wont sry

Page 2 of 2

Please log in to post replies.