AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run Statistics (https://forums.alliedmods.net/showthread.php?t=232820)

myusername 01-05-2014 10:11

Run Statistics
 
Hi, i need run statistics like in this zombie escape mode. I want to use it in Deathrun server. I've tried to get some code from zombie escape but not working.

Help me.

Here is what ive got so far...
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#include <fun>

#define OFFICIAL_LANG LANG_PLAYER

enum
{
    
RANK_NONE 0,
    
RANK_FIRST,
    
RANK_SECOND,
    
RANK_THIRD
}

enum
{
    
TEAM_T 1,
    
TEAM_CT 2
}

new 
g_WinText[7][64]
new 
Float:delay_hud[33]
new 
g_escape_point[33]
new 
g_MaxPlayersscore_hudstat_hud
new g_escape_rank[4]
new 
g_team_score[6]

public 
plugin_init()
{    
    
register_dictionary("zombie_escape.txt")
    
RegisterHam(Ham_Spawn"player""fw_Spawn_Post"1)
    
    
g_MaxPlayers get_maxplayers()    
    
    
format(g_WinText[TEAM_T], 63"Escape Fail")
    
format(g_WinText[TEAM_CT], 63"Escape Success")        
    
    
score_hud CreateHudSyncObj(2)
}

public 
client_putinserver(id)
{
    
g_escape_point[id] = 0
}

public 
get_stat()
{
    static 
highestcurrent
    highest 
current 0
    
    
// Rank First
    
for(new 0g_MaxPlayersi++)
    {
        if(!
is_user_connected(i))
            continue
        if(!
is_user_alive(i))
            continue
        if(
cs_get_user_team(i) == CS_TEAM_T)
            continue
            
        if(
g_escape_point[i] > highest)
        {
            
current i
            highest 
g_escape_point[i]
        }
    }
    
g_escape_rank[RANK_FIRST] = current
    
    
// Rank Second
    
highest current 0    
    
for(new 0g_MaxPlayersi++)
    {
        if(!
is_user_connected(i))
            continue
        if(!
is_user_alive(i))
            continue
        if(
cs_get_user_team(i) == CS_TEAM_T)
            continue            
        if(
g_escape_rank[RANK_FIRST] == i)
            continue
            
        if(
g_escape_point[i] > highest)
        {
            
current i
            highest 
g_escape_point[i]
        }
    }
    
g_escape_rank[RANK_SECOND] = current        
    
    
// Rank Third
    
highest current 0    
    
for(new 0g_MaxPlayersi++)
    {
        if(!
is_user_connected(i))
            continue
        if(!
is_user_alive(i))
            continue
        if(
cs_get_user_team(i) == CS_TEAM_T)
            continue            
        if(
g_escape_rank[RANK_FIRST] == || g_escape_rank[RANK_SECOND] == i)
            continue
            
        if(
g_escape_point[i] > highest)
        {
            
current i
            highest 
g_escape_point[i]
        }
    }
    
g_escape_rank[RANK_THIRD] = current    
}

public 
client_PostThink(id)
{
    if(!
is_user_connected(id))
        return
    if(
get_gametime() - 1.0 delay_hud[id])
    {
        
// Show Score
        
set_hudmessage(255255255, -1.00.002.02.0)
        
ShowSyncHudMsg(idscore_hud"%L"OFFICIAL_LANG"HUD_SCORE"g_team_score[TEAM_T], g_team_score[TEAM_CT])
        
        
// Add Point for Who is Running Fast
        
if(cs_get_user_team(id) == CS_TEAM_CT)
        {
            static 
Float:Velocity[3], Speed
            
            pev
(idpev_velocityVelocity)
            
Speed floatround(vector_length(Velocity))
            
            switch(
Speed)
            {
                case 
210..229g_escape_point[id] += 1
                
case 230..249g_escape_point[id] += 2
                
case 250..300g_escape_point[id] += 3
            
}
        }
        
        
// Show Stat
        
show_stat(id)
        
delay_hud[id] = get_gametime()
    }
}

public 
show_stat(id)
{
    
get_stat()
    new 
temp_string_first[64], temp_string_second[64], temp_string_third[64], curidPlayer_Name[64], none[32]
    
    
formatex(nonesizeof(none), "%L"OFFICIAL_LANG"RANK_NONE")
    
    
// Rank First
    
curid g_escape_rank[RANK_FIRST]
    if(
is_user_alive(curid) && cs_get_user_team(curid) == CS_TEAM_CT && g_escape_point[curid] != 0)
    {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_firstsizeof(temp_string_first), "%L"OFFICIAL_LANG"RANK_FIRST"Player_Name)
    } else {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_firstsizeof(temp_string_first), "%L"OFFICIAL_LANG"RANK_FIRST"none)    
    }
    
    
// Rank Second
    
curid g_escape_rank[RANK_SECOND]
    if(
is_user_alive(curid) && cs_get_user_team(curid) == CS_TEAM_CT && g_escape_point[curid] != 0)
    {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_secondsizeof(temp_string_second), "%L"OFFICIAL_LANG"RANK_SECOND"Player_Name)
    } else {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_secondsizeof(temp_string_second), "%L"OFFICIAL_LANG"RANK_SECOND"none)    
    }
    
    
// Rank Third
    
curid g_escape_rank[RANK_THIRD]
    if(
is_user_alive(curid) && cs_get_user_team(curid) == CS_TEAM_CT && g_escape_point[curid] != 0)
    {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_thirdsizeof(temp_string_third), "%L"OFFICIAL_LANG"RANK_THIRD"Player_Name)
    } else {
        
get_user_name(curidPlayer_Namesizeof(Player_Name))
        
formatex(temp_string_thirdsizeof(temp_string_third), "%L"OFFICIAL_LANG"RANK_THIRD"none)    
    }    

    
set_hudmessage(025500.050.3002.02.0)
    
ShowSyncHudMsg(idstat_hud"%L^n%s^n%s^n%s"OFFICIAL_LANG"RANK_INFO"temp_string_firsttemp_string_secondtemp_string_third)    
}

public 
fw_Spawn_Post(id)
{
    if(!
is_user_connected(id))
        return 
HAM_IGNORED
    
    g_escape_point
[id] = 0
    
    
return HAM_HANDLED


Gives me this error
PHP Code:

L 01/05/2014 23:01:01HudSyncObject -1 is invalid
L 01
/05/2014 23:01:01: [AMXXDisplaying debug trace (plugin "Statistics.amxx")
L 01/05/2014 23:01:01: [AMXXRun time error 10native error (native "ShowSyncHudMsg")
L 01/05/2014 23:01:01: [AMXX]    [0RunStatistics.sma::show_stat (line 190)
L 01/05/2014 23:01:01: [AMXX]    [1RunStatistics.sma::client_PostThink (line 144


myusername 01-28-2014 08:50

Re: Run Statistics
 
to YamiKaitou: Ive bumped after 14 days :<

Bring
Up
My
Post

YamiKaitou 01-28-2014 09:09

Re: Run Statistics
 
Quote:

Originally Posted by myusername (Post 2092073)
to YamiKaitou: Ive bumped after 14 days :<

Showed 13 on my screen


But, your issue is because stat_hud is not a valid HudSyncObj

myusername 01-29-2014 07:28

Re: Run Statistics
 
Quote:

Originally Posted by YamiKaitou (Post 2092080)
Showed 13 on my screen

But, your issue is because stat_hud is not a valid HudSyncObj

I see in my timezone( +8 ) its 14.

Can you show me example? Its really hard to fix for me.

YamiKaitou 01-30-2014 10:39

Re: Run Statistics
 
Quote:

Originally Posted by myusername (Post 2092415)
Can you show me example? Its really hard to fix for me.

Your example is already in your code, look at score_hud

myusername 01-31-2014 07:18

Re: Run Statistics
 
Oh i see thank you. Solved.


All times are GMT -4. The time now is 19:33.

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