Raised This Month: $ Target: $400
 0% 

get_gametime mismatch


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 05-07-2010 , 18:45   Re: get_gametime mismatch
Reply With Quote #3

yeah, I went wrong there.. I fixed it, but it says it isnt working "as expected"

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>
#include <fun>
#include <fvault>
#include <hamsandwich>

#define PLUGIN "TFC XP Mod"
#define VERSION "1.0"
#define AUTHOR "Master"

#define VAULTNAME "tfc_xp_mod"

new PlayerXP[33], PlayerLevel[33]
new 
amx_xp_hsbonusamx_xp_killreward

new const LEVELS[2] = {
    
100,
    
200
}

new 
Float:g_healthtime[33]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""deathmsg""a")
    
amx_xp_hsbonus register_cvar("amx_xp_hsbonus","20")
    
amx_xp_killreward register_cvar("amx_xp_killreward","60")
    
RegisterHam(Ham_Spawn,"player","Player_Spawn",1)
    
register_clcmd("say /xp","DisplayHud")
    
register_clcmd("say_team /xp","DisplayHud")
    
register_clcmd("say !time","DisplayTime")
}

public 
client_connect(id)
{
    if( !
is_user_bot(id) )
    {
        
LoadData(id)
    }
}

public 
client_disconnect(id)
{
    new 
steamid[33]
    
get_user_authid(id,steamid,32)
    if( !
is_user_bot(id) )
    {
        new 
savedxp[65]
        
num_to_str(PlayerXP[id],savedxp,64)
        
fvault_set_data(VAULTNAME,steamid,savedxp)
    }
}

public 
deathmsg()
{
    new 
killerid read_data(1)
    
//new victimid = read_data(2)
    
new headshot read_data(3)
    
    
PlayerXP[killerid] += get_pcvar_num(amx_xp_killreward)
    
    if( 
headshot )
        
PlayerXP[killerid] += get_pcvar_num(amx_xp_hsbonus)
    
    
    
    if(
PlayerXP[killerid] >= LEVELS[PlayerLevel[killerid]])
    {
        
PlayerLevel[killerid] += 1
        client_print
(killeridprint_chat"[AMXX] Congratulations! You are level %i!",PlayerLevel[killerid])
    }
    
DisplayHud(killerid)
    
SaveData(killerid)
}

public 
DisplayHud(id)
{
    
set_hudmessage(02552550.750.0106.015.0)
    
show_hudmessage(id"Level: %i^nXP: %i",PlayerLevel[id],PlayerXP[id])
}

public 
SaveData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-xPmoD",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
    
fvault_set_data(VAULTNAME,vaultkey,vaultdata)
    return 
PLUGIN_CONTINUE
}
public 
LoadData(id)
{
    new 
AuthID[35]
    
get_user_authid(id,AuthID,34)
    
    new 
vaultkey[64],vaultdata[256]
    
format(vaultkey,63,"%s-xPmoD",AuthID)
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
    
fvault_get_data(VAULTNAME,vaultkey,vaultdata,255)
    
    
replace_all(vaultdata255"#"" ")
    
    new 
playerxp[32], playerlevel[32]
    
    
parse(vaultdataplayerxp31playerlevel31)
    
    
PlayerXP[id] = str_to_num(playerxp)
    
PlayerLevel[id] = str_to_num(playerlevel)
    
    return 
PLUGIN_CONTINUE
}

public 
Player_Spawn(id)
{
    new class = 
entity_get_int(idEV_INT_playerclass)
    switch(class)
    {
        case 
0:
        {
            
set_task(0.1,"Player_Spawn",id)
        }
        case 
.. 10:
        {
            
Health_Regen(id)
        }
    }
}

public 
Health_Regen(id)
{
    if(
g_healthtime[id] == 0)
        
g_healthtime[id] = get_gametime()
    switch(
LEVELS[id])
    {
        case 
1:
        {
            while(
g_healthtime[id] == get_gametime())
            {
                new 
health get_user_health(id)
                
set_user_health(id, (health 3) )
                
g_healthtime[id] = get_gametime() + 5.0
            
}
            
        }
        case 
2:
        {
            while( 
g_healthtime[id] == get_gametime() )
            {
                new 
health get_user_health(id)
                
set_user_health(id, (health 5) )
                
g_healthtime[id] = get_gametime() + 3.0
            
}
        }
    }    
}

public 
DisplayTime(id)
{
    new 
Float:currenttime get_gametime()
    new 
Float:timeplusfive = ( get_gametime() + 5.0 )
    
client_print(id,print_chat,"[AMXX] Gametime:%f Next Check:%f Your Time:%f",currenttime,timeplusfive,g_healthtime[id])

this is obviously a very rough prototype, but "my time" is always less than next check and the current gametime, am I using the "while" loop wrong?
__________________
+|- KARMA Respectively

HLM 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 03:46.


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