AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fix this code plz (https://forums.alliedmods.net/showthread.php?t=110158)

Guld-Fisk 11-25-2009 19:51

Fix this code plz
 
Can someone fix this code?

PHP Code:

#include <amxmodx>
#include <colorchat>
#include <geoip>

public plugin_init() {
    
register_plugin("connecting info""1.0""you")
}

public 
client_connect(id)
{
    new 
Name[32], Authid[32], Country[46], IP[21]
    
get_user_name(idName31)
    
get_user_authid(idAuthid31)
    
get_user_ip(idIP20)
    
geoip_country (IPCountry45)
    
ColorChat(0GREY"^x01**^x04%s ^x01[^x04%s^x01]^3 has connected from ^x01%s**"NameAuthidCountry)
}

public 
client_disconnect(id)
{
    new 
Name[32], Authid[32], Country[46], IP[21]
    
get_user_name(idName31)
    
get_user_authid(idAuthid31)
    
get_user_ip(idIP20)
    
geoip_country (IPCountry45)
    
ColorChat(0GREY"^x01**^x04%s ^x01[^x04%s^x01]^3 has connected from ^x01%s**"NameAuthidCountry)



Bugsy 11-25-2009 21:54

Re: Fix this code plz
 
What is the problem you are having? Providing this makes it easier\faster for others to find your mistake. One major mistake I see is you are calling functions on the player in client_disconnect(); this should be never done because the player may already be gone at this point. You should cache the values from when they are called at client_putinserver() so they can safely be used at client_disconnect().

Try this (untested)
PHP Code:

#include <amxmodx>
#include <colorchat>
#include <geoip>

enum PlayerData
{
    
szName32 ],
    
szAuthID32 ],
    
szIP16 ],
    
szCountry46 ]
}

new 
PData33 ][ PlayerData ];

public 
plugin_init() 
{
    
register_plugin"connecting info" "1.0" "you" );
}

public 
client_putinserver(id)
{
    
get_user_nameid PDataid ][ szName ] , 31 );
    
get_user_authidid PDataid ][ szAuthID ] , 31);
    
get_user_ipid PDataid ][ szIP ] , 15 );
    
geoip_countryPDataid ][ szIP ] , PDataid ][ szCountry ] , 45 );
    
ColorChat(0GREY"^x01**^x04%s ^x01[^x04%s^x01]^3 has connected from ^x01%s**"PDataid ][ szName ] , PDataid ][ szAuthID ] , PDataid ][ szCountry ] );
}

public 
client_disconnect(id)
{
    
ColorChat(0GREY"^x01**^x04%s ^x01[^x04%s^x01]^3 has connected from ^x01%s**"PDataid ][ szName ] , PDataid ][ szAuthID ] , PDataid ][ szCountry ] );
    
PDataid ][ szName ][ ] = EOS;
    
PDataid ][ szAuthID ][ ] = EOS;
    
PDataid ][ szIP ][ ] = EOS;
    
PDataid ][ szCountry ][ ] = EOS;



Guld-Fisk 11-26-2009 08:15

Re: Fix this code plz
 
Thanks will test it now !

EDIT: when i compile i get this:

C:\Användare\Administratör\Skrivbord\Pawn Studio\temp206.inc(0) : fatal error 100: cannot read from file: "C:\Användare\Administratör\Skrivbord\Paw n Studio\temp206.inc"

Bugsy 11-26-2009 08:36

Re: Fix this code plz
 
Quote:

Originally Posted by Guld-Fisk (Post 999496)
Thanks will test it now !

EDIT: when i compile i get this:

C:\Användare\Administratör\Skrivbord\Pawn Studio\temp206.inc(0) : fatal error 100: cannot read from file: "C:\Användare\Administratör\Skrivbord\Paw n Studio\temp206.inc"

You probably do not have the colorchat include because it isn't shipped with AMX-X.

See http://forums.alliedmods.net/showthread.php?t=94960


All times are GMT -4. The time now is 13:39.

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