Raised This Month: $32 Target: $400
 8% 

[L4D] Average Distance detect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
guilty80100
Member
Join Date: Jul 2009
Old 09-29-2009 , 23:04   [L4D] Average Distance detect
Reply With Quote #1

Hi guys, i wanna detect the average distance in l4d for my scoring system plugin i tryed a lot of logger but no one catch the average distance changes.
Can someone know how to detect it ?
guilty80100 is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 10-01-2009 , 08:56   Re: [L4D] Average Distance detect
Reply With Quote #2

You mean, average distance the Survivors travelled in a map?

Its "m_iVersusDistance" in the entity "CTerrorGameRulesProxy"



Since im bored right now i even whipped you up a function

PHP Code:
GetVersusDistance()
{
    new 
ent = -1maxents GetMaxEntities();
    
decl String:netclass[64];
    for (new 
MaxClients+1<= maxentsi++)
    {
        if (
IsValidEntity(i))
        {

            
GetEntityNetClass(inetclasssizeof(netclass));

            if (
StrEqual(netclass"CTerrorGameRulesProxy"false))
            {
                
ent i;
                break;
            }
        }
    }

    if (
ent > -1)
    {
        new 
offset FindSendPropInfo("CTerrorGameRulesProxy""m_iVersusDistance");
        if (
offset 0)
        {
            if (
GetEntData(entoffset))
            {
                return 
GetEntData(entoffset);
            }
        }
    }
    return -
1;


EDIT: fixed sloppy string decl inside a a loop ... it only gets executed 10-20 times but still

Last edited by AtomicStryker; 10-03-2009 at 08:18.
AtomicStryker is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-01-2009 , 18:38   Re: [L4D] Average Distance detect
Reply With Quote #3

sorry i'm a noob at c++ but how can i get the value ? because when i get with GetVersusDistance it's give me a ~5500 points value
guilty80100 is offline
olj
Veteran Member
Join Date: Jun 2009
Old 10-02-2009 , 08:24   Re: [L4D] Average Distance detect
Reply With Quote #4

Post your code, or at least the part where you getting it.

You should be doing something like

PHP Code:
new distance

distance 
GetVersusDistance() 
Then you can use distance variable to print out the distance for example.

PHP Code:
PrintToChatAll("Distance travelled: %i"distance
If it still produces some weird numbers like 5000 - then distance in versus is measured this way. You should then just somehow convert this to percentage (like 5000 - 50% of map travelled or whatever it will be). But i dont know a formula for that.
__________________
olj is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-02-2009 , 19:15   Re: [L4D] Average Distance detect
Reply With Quote #5

now it's return me -1
guilty80100 is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-06-2009 , 14:37   Re: [L4D] Average Distance detect
Reply With Quote #6

can somebody help me ?
guilty80100 is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-09-2009 , 04:39   Re: [L4D] Average Distance detect
Reply With Quote #7

it's one of my last part of my plugin bug can someone help me plz
guilty80100 is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-09-2009 , 06:42   Re: [L4D] Average Distance detect
Reply With Quote #8

well if it can help i post here the beginning of the code
PHP Code:
#include <sourcemod>
#include <sdktools>

#define SCORE_DEBUG     1

#define L4D_TEAM_SURVIVORS 2
#define L4D_TEAM_INFECTED 3
#define L4D_TEAM_SPECTATE 1



new Handle:pm_var_max_hunters                 INVALID_HANDLE;
new 
Handle:pm_var_start_heal_pts             INVALID_HANDLE;
new 
Handle:pm_var_pts_gain_map_completion     INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_kit                 INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_pills             INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_incap             INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_per_second         INVALID_HANDLE;
new 
Handle:pm_var_endmap_pts_loss_yellow     INVALID_HANDLE;
new 
Handle:pm_var_endmap_pts_loss_red         INVALID_HANDLE;
new 
Handle:pm_var_pts_win_witch_killed         INVALID_HANDLE;
new 
Handle:pm_var_pts_win_tank_killed         INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_per_ff             INVALID_HANDLE;
new 
Handle:pm_var_pts_loss_per_damage         INVALID_HANDLE;
new 
Handle:pm_var_death_percentage_loss     INVALID_HANDLE
new 
Handle:pm_var_show_details                 INVALID_HANDLE;
new 
Handle:pm_var_seconds                     INVALID_HANDLE;

new 
timerMin;
new 
survAlive;
new 
mapFinished;
new 
mapCompletion;
new 
finishAlive;
new 
timerSec;
new 
currentScore;
new 
roundStarted;
new 
roundFinished;


public 
Plugin:myinfo =
{
    
name "L4Pro",
    
author "rodounet",
    
description "Promod made for l4dfrance",
    
version "0.0.0.1",
    
url "http://www.l4dfrance.com/"
}
 
public 
OnPluginStart()
{
    
LoadTranslations("common.phrases");
    
    
RegAdminCmd("pm_reset"Command_ResetADMFLAG_BAN);
    
RegAdminCmd("pm_getscore"Command_GetScoreADMFLAG_BAN);
    
RegAdminCmd("pm_displayvars"Command_DisplayVarsADMFLAG_BAN);
    
    
    
RegConsoleCmd("say"Command_Say);
    
RegConsoleCmd("say_team"Command_Say);

    
    
pm_var_max_hunters                     CreateConVar("pm_var_max_hunters""3""TODO: Maximum number of hunters.");
    
pm_var_start_heal_pts                CreateConVar("pm_var_start_heal_pts""800""Starting Heal points.");
    
pm_var_pts_gain_map_completion         CreateConVar("pm_var_pts_gain_map_completion""100""TODO: Points given per player for map completion.");
    
pm_var_death_percentage_loss        CreateConVar("pm_var_death_percentage_loss""33""Points lost on each damage received.");
    
pm_var_pts_loss_kit                    CreateConVar("pm_var_pts_loss_kit""0""Points lost when kit is used.");
    
pm_var_pts_loss_pills                CreateConVar("pm_var_pts_loss_pills""0""Points lost when pills are used.");
    
pm_var_pts_loss_incap                CreateConVar("pm_var_pts_loss_incap""0""Points lost when survivor is incapacitated.");
    
pm_var_pts_loss_per_second            CreateConVar("pm_var_pts_loss_per_second""0""Points lost each second.");
    
pm_var_pts_loss_per_ff                CreateConVar("pm_var_pts_loss_per_ff""1""Points lost on friendly fire.");
    
pm_var_pts_loss_per_damage            CreateConVar("pm_var_pts_loss_per_damage""1""Points lost on each damage received.");
    
pm_var_pts_win_witch_killed            CreateConVar("pm_var_pts_loss_witch_killed""0""Points earned for killing a witch.");
    
pm_var_pts_win_tank_killed            CreateConVar("pm_var_pts_win_tank_killed""0""Points earned for killing a tank.");
    
pm_var_endmap_pts_loss_yellow        CreateConVar("pm_var_endmap_pts_loss_yellow""0""TODO: Points lost at the end of map if a player is yellow.");
    
pm_var_endmap_pts_loss_red            CreateConVar("pm_var_endmap_pts_loss_red""0""TODO: Points lost at the end of map if a player is red.");
    
pm_var_show_details                    CreateConVar("pm_var_show_details""1""Display everything.");
    
pm_var_seconds                        CreateConVar("pm_var_seconds""1""secondes");
    
    
roundStarted 0;
    
    
HookEvent("player_left_start_area"Event_PlayerLeftStartArea);
    
HookEvent("round_end"Event_RoundEndEventHookMode_PostNoCopy);    
    
HookEvent("heal_success"Event_HealSuccess);
    
HookEvent("pills_used"Event_PillsUsed);
    
HookEvent("player_incapacitated"Event_Incap);
    
HookEvent("witch_killed"Event_WitchKilled);
    
HookEvent("tank_killed"Event_TankKilled);
    
HookEvent("friendly_fire"Event_FriendlyFire);
    
HookEvent("player_hurt_concise"Event_PlayerHurt);
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);

    
AutoExecConfig(true"plugin_pRoDmod");
}

public 
Action:Event_PlayerLeftStartArea(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
roundStarted)
    {
        
StartScoring();
        
survAlive 4;
        
finishAlive 4;
        
timerMin 0;
        
timerSec 0;
        
mapCompletion GetVersusDistance();
        
PrintToChatAll("The Round is Started, GL & HF");
        
DebugPrintToAll("finish alive : %d mapCompletion : %d map Finished : %d survAlive : %d"finishAlivemapCompletionmapFinishedsurvAlive);
        return 
Plugin_Handled;
    }
    else
    {
        
PrintToChatAll("The Round is already started");
    }
    return 
Plugin_Continue;
}

public 
Action:Command_Say(clientargs)
{
    if (
roundStarted)
        return 
Plugin_Continue;
    
    
decl String:sayWord[MAX_NAME_LENGTH];
    
GetCmdArg(1sayWordsizeof(sayWord));
    
    new 
idx = (sayWord[0] == '!' && sayWord[1] == 'r' && sayWord[2] == 'e' && sayWord[3] == 's' && sayWord[4] == 'e' && sayWord[5] == 't');
    if (
idx)
    {
        
Reset();
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;
}

StartScoring()
{
    if (
roundStarted)
    {
        
PrintToChatAll("=== ERROR: round already started. ===");
        return;
    }
    
    
currentScore GetConVarInt(pm_var_start_heal_pts);
    
    
PrintToChatAll("=== Round Started ===");
    
PrintToChatAll("Starting points : %d"currentScore);
    
CreateTimer(1.0Event_TimerSecond_TIMER_REPEAT);
    
roundStarted 1;
    
    
DrawClientPanel();
}

GetVersusDistance()
{
    new 
ent = -1maxents GetMaxEntities();
    
decl String:netclass[64];
    for (new 
MaxClients+1<= maxentsi++)
    {
        if (
IsValidEntity(i))
        {

            
GetEntityNetClass(inetclasssizeof(netclass));

            if (
StrEqual(netclass"CTerrorGameRulesProxy"false))
            {
                
ent i;
                break;
            }
        }
    }

    if (
ent > -1)
    {
        new 
offset FindSendPropInfo("CTerrorGameRulesProxy""m_iVersusDistance");
        if (
offset 0)
        {
            if (
GetEntData(entoffset))
            {
                return 
GetEntData(entoffset);
            }
        }
    }
    return -
1;


public 
DrawClientPanel()
{
    
decl String:scoreStr[1024];
    
Format(scoreStr1024"-> Score: %d pts."currentScore);

    
decl String:timerStr[1024];
    
Format(timerStr1024"-> Timer: %d min %d sec."timerMintimerSec);

    
decl String:survStr[1024];
    
Format(survStr1024"-> Survivor : %d."survAlive);

    
decl String:percentStr[1024];
    
Format(percentStr1024"-> Percent Travelled : %d."mapCompletion);

    new 
Handle:panel CreatePanel();
    
DrawPanelText(panelscoreStr);
    
DrawPanelText(paneltimerStr);
    
DrawPanelText(panelsurvStr);
    
DrawPanelText(panelpercentStr);
    
    for (new 
19i++) 
    {
        if(
IsClientInGameHuman(i)) 
        {
            
SendPanelToClient(paneliMenu_Panel2);
            
            
/*
            #if READY_DEBUG
            PrintToChat(i, "[DEBUG] You have been sent the Panel.");
            #endif
            */
        
}
    }
    
CloseHandle(panel);
}

public 
Menu_Panel(Handle:menuMenuAction:actionparam1param2) { return; } 

Last edited by guilty80100; 10-09-2009 at 06:45.
guilty80100 is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 10-09-2009 , 07:29   Re: [L4D] Average Distance detect
Reply With Quote #9

If you check the travelled Distance in the Moment of leaving the saferoom (which you do), i imagine -1 is a completely valid return.
AtomicStryker is offline
guilty80100
Member
Join Date: Jul 2009
Old 10-09-2009 , 09:47   Re: [L4D] Average Distance detect
Reply With Quote #10

yes but when i go on it's don't change the value
guilty80100 is offline
Reply


Thread Tools
Display Modes

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 02:24.


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