Hello.Recently, Ive been trying to do a duel system, yeah, I have done it, it works, but it has one feature that I want to implement into it that is getting some off values.I want to know where am I making a mistake.Here is the part of the code:
Note: Difference is declared as new Float: Difference; not as array.
PHP Code:
public fwdUse(ent, id)
{
if(!g_bUserRacing[id])
return PLUGIN_CONTINUE
new target[33]
pev( ent, pev_target, target, sizeof target - 1 )
if( equali( target, "counter_start" ) || equali( target, "clockstartbutton" ) || equali( target, "firsttimerelay" ) )
{
g_fHisTime[id] = get_gametime()
g_fHisTime[g_iAsker[id]] = get_gametime()
}
else if( equali( target, "counter_off" ) || equali( target, "clockstopbutton" ) || equali( target, "clockstop" ) )
{
new szBuffer[64];
get_user_name(id, szBuffer, 63)
g_fHisTime[id] = get_gametime() - g_fHisTime[id];
g_fHisTime[g_iAsker[id]] = get_gametime() - g_fHisTime[g_iAsker[id]];
if(g_fHisTime[id] > g_fHisTime[g_iAsker[id]])
{
Difference = g_fHisTime[id] - g_fHisTime[g_iAsker[id]];
show_finish_message(id, g_fHisTime[id])
}else
{
Difference = g_fHisTime[g_iAsker[id]] - g_fHisTime[id];
show_finish_message(id, g_fHisTime[g_iAsker[id]]);
}
ColorChat(id, RED, "[%s] ^x01You won! :]", g_szPrefix);
ColorChat(g_iAsker[id], RED, "[%s] ^x01You lost! :F", g_szPrefix);
g_bUserRacing[id] = false;
g_bUserRacing[g_iAsker[id]] = false;
g_fHisTime[id] = 0.0
g_fHisTime[g_iAsker[id]] = 0.0
g_iAsker[g_iAsker[id]] = 0;
g_iAsker[id] = 0;
}
return FMRES_IGNORED;
}
public show_finish_message(id, Float:dueltime)
{
new name[32]
new imin,isec,ims
imin = floatround(dueltime / 60.0, floatround_floor)
isec = floatround(dueltime - imin * 60.0,floatround_floor)
ims = floatround( ( dueltime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
get_user_name(id, name, 31);
//Difference
new dmin, dsec, dms;
dmin = floatround(Difference / 60.0, floatround_floor)
dsec = floatround(Difference - dmin * 60.0, floatround_floor)
dms = floatround((Difference - (dmin * 60.0 + dsec)) * 100.0, floatround_floor)
ColorChat(0, RED, "[%s]^x04 %s^x01 won the duel with time ^x04 %02i:%02i.%02i^x01[^x03 Difference: ^x04%02i:%02i.%02i^x01 ] Congratulations!", g_szPrefix, name, imin, isec, ims, dmin, dsec, dms)
}
The problem lies here: When two players are dueling and if the first one finishes, it shows this chat message:
Quote:
|
[Kreedz Duels] unnamed won the duel with time 01:40.69(Difference: 00:00.00)
|
Any ideas?