Raised This Month: $ Target: $400
 0% 

Global Timer variable mismatch


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
iNvectus
Member
Join Date: Sep 2014
Location: Bulgaria
Old 03-17-2017 , 05:26   Global Timer variable mismatch
Reply With Quote #1

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(entid

       if(!
g_bUserRacing[id])
        return 
PLUGIN_CONTINUE
   
  
new target[33
  
peventpev_targettargetsizeof target 
   
  if( 
equalitarget"counter_start" ) || equalitarget"clockstartbutton" ) || equalitarget"firsttimerelay" ) ) 
  { 
    
g_fHisTime[id] = get_gametime()
    
g_fHisTime[g_iAsker[id]] = get_gametime()
  } 
  else if( 
equalitarget"counter_off" ) || equalitarget"clockstopbutton" ) || equalitarget"clockstop" ) ) 
  { 
    new 
szBuffer[64];
    
get_user_name(idszBuffer63)
    
    
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(idg_fHisTime[id])
    }else
    {
        
Difference g_fHisTime[g_iAsker[id]] - g_fHisTime[id];
        
show_finish_message(idg_fHisTime[g_iAsker[id]]);
    }
    
    
ColorChat(idRED"[%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(idFloat:dueltime)
{
    new 
name[32]
    new 
imin,isec,ims
    imin 
floatround(dueltime 60.0floatround_floor)
    
isec floatround(dueltime imin 60.0,floatround_floor)
    
ims floatround( ( dueltime - ( imin 60.0 isec ) ) * 100.0floatround_floor )
    
get_user_name(idname31);
    
    
//Difference
    
new dmindsecdms;
    
dmin floatround(Difference 60.0floatround_floor)
    
dsec floatround(Difference dmin 60.0floatround_floor)
    
dms floatround((Difference - (dmin 60.0 dsec)) * 100.0floatround_floor)
    
    
ColorChat(0RED"[%s]^x04 %s^x01 won the duel with time ^x04 %02i:%02i.%02i^x01[^x03 Difference: ^x04%02i:%02i.%02i^x01 ] Congratulations!"g_szPrefixnameiminisecimsdmindsecdms)

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?

Last edited by iNvectus; 03-17-2017 at 05:27.
iNvectus is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode