AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compare IP from a file (https://forums.alliedmods.net/showthread.php?t=210832)

rubbe 03-15-2013 05:47

Compare IP from a file
 
Hey i'm currently trying to compare a ip that i have in a file with the one of a player taking damage.
I tried to use my external visual basic program to read it but it seems that it's having trouble reading it while the plugin checks and changes in the files so instead i decided to do the check in the plugin and let the program activate whenever the file is simply modified.
So here is what i've

Code:

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

new gszNewFile[128];

public plugin_init() {
        register_plugin("CS Mr.GeCo", "1.0", "Micael")
       
        RegisterHam( Ham_TakeDamage, "player", "HAM_TakeDamage_Post", 1 );
       
        register_cvar("geco_ip","192.168.0.1");
        new szDir[64];
        get_basedir(szDir, 64);
        add(szDir, 64, "/mrgeco");

        if (!dir_exists(szDir))
        {
                mkdir(szDir);
        }
        formatex(gszNewFile, 96, "%s/damage.geco", szDir);
}
public HAM_TakeDamage_Post( victim, inflictor, attacker, float:damage, damagebits )
{
        new szIP[32];
        get_user_ip(0, szIP, charsmax(szIP), false);
        if(szIP[0] == get_cvar_string("geco_ip")){
                new file = fopen(gszNewFile, "wt");
                new szData[128];
                formatex(szData, 128, "%s", victim);
                fputs(file, szData);
                fclose(file);
        }
        return HAM_IGNORED;
}

To put it simply, check for damage, check the one taking damages ip, if it's equal to the cvar geco_ip write the ip to the file damage.geco

Thanks in advance for pointers and suggestions :)

naven 03-15-2013 07:16

Re: Compare IP from a file
 
Um, what's the problem?

jimaway 03-15-2013 10:34

Re: Compare IP from a file
 
if(szIP[0] == get_cvar_string("geco_ip")){
that will compare first cell of szIP to the cvar value, use equal() to compare strings


All times are GMT -4. The time now is 21:35.

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