Raised This Month: $ Target: $400
 0% 

.............


Post New Thread Reply   
 
Thread Tools Display Modes
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-22-2015 , 10:32   Re: On ban ID, ban IP.
Reply With Quote #21

If you made a mistake, you can just edit your post instead of deleting and posting again..

I think the way you handle your variable is incorrect and could eventually cause trouble if two people are being banned at (almost) the same time.

If two bans occurs at the exact same time (which ... they probably don't, but still), then there would be a chance that your timers only use the IP of the last ban.

Timers > Passing Data
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Sdg
BANNED
Join Date: Mar 2014
Old 04-22-2015 , 10:59   Re: On ban ID, ban IP.
Reply With Quote #22

How would you do it correctly?
Is there another way?

I can shorten the timers to "0.3" to decrease the margin of error if another ban ocurred at the same time...

Sorry if my english is bad!

Last edited by Sdg; 04-25-2015 at 15:33.
Sdg is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-22-2015 , 14:04   Re: On ban ID, ban IP.
Reply With Quote #23

You can see a full explanation on passing parameters through timers at the link I gave you above.

Also, if you are doing it that way, you do not need to have multiple timer callbacks, you can pass the time towards the callback.

Code:
public Action:OnBanClient(client, time, flags, const String:reason[], const String:kick_message[], const String:command[], any:admin)
{
    new String:ip[46];
    GetClientIP(client, ip, sizeof(ip));
    new Handle:timerPack;

    CreateDataTimer(1.0, Timer_OnBanClient, timerPack);
    WritePackString(timerPack, ip);
    WritePackCell(timerPack, time);

    if (StrEqual(command, "SMAC"))
    {
        PrintToChatAll("[SMAC] %N Banned. (%s) ", client, reason);
    }
}

public Action:Timer_OnBanClient(Handle:timer, Handle:timerPack)
{
    new String:ip[46];
    new time;
    ResetPack(timerPack);
    ReadPackString(timerPack, ip, sizeof(ip));
    time = ReadPackCell(timerPack);

    if (time == 0)
    {
        ServerCommand("sm_banip %s 8000", ip);
    }
    else
    {
        ServerCommand("sm_banip %s 5", ip);
    }
}
NOTE: The time in OnBanClient will not be accurate together with SourceBans, as SourceBans only bans the client for 5 minutes, and then re-checks its database if a client returns after that (while his/her ban is still valid).
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].

Last edited by DarkDeviL; 04-22-2015 at 14:09.
DarkDeviL is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-22-2015 , 15:07   Re: On ban ID, ban IP.
Reply With Quote #24

y not use BanIdentity?
PHP Code:
public Action OnBanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany admin)
{
    
char ip[46];
    
GetClientIP(clientipsizeof(ip));
    
BanIdentity(iptime == 8000 5BANFLAG_IPreason);
    if (
StrEqual(command"SMAC"))
        
PrintToChatAll("[SMAC] %N Banned. (%s) "clientreason);
    return 
Plugin_Continue;

__________________

Last edited by WildCard65; 04-26-2015 at 20:06.
WildCard65 is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 04-22-2015 , 15:18   Re: On ban ID, ban IP.
Reply With Quote #25

Quote:
Originally Posted by WildCard65 View Post
y not use BanIdentity?
PHP Code:
public Action OnBanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany admin)
{
    
char[] ip[46];
    
GetClientIP(clientipsizeof(ip));
    
BanIdentity(iptime == 8000 5BANFLAG_IPreason);
    if (
StrEqual(command"SMAC"))
        
PrintToChatAll("[SMAC] %N Banned. (%s) "clientreason);
    return 
Plugin_Continue;

I just re-built his original code.

But you're right, BanIdentity is more simple, and requires less code than the other.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Sdg
BANNED
Join Date: Mar 2014
Old 04-22-2015 , 17:37   Re: On ban ID, ban IP.
Reply With Quote #26

Thanks guys!

If i take code from WildCard65, I'm having the same problem as before unable to change the message (Added to banned list.), Right?
On the other hand, when I compile this, shoot me some errors.

Arne1288, I testing your code, seems to work fine!
Sdg is offline
Sdg
BANNED
Join Date: Mar 2014
Old 04-25-2015 , 15:35   Re: On ban ID, ban IP.
Reply With Quote #27

Wild:

I get the following errors when trying to compile this.

Quote:
Originally Posted by WildCard65 View Post
y not use BanIdentity?
PHP Code:
public Action OnBanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany admin)
{
    
char[] ip[46];
    
GetClientIP(clientipsizeof(ip));
    
BanIdentity(iptime == 8000 5BANFLAG_IPreason);
    if (
StrEqual(command"SMAC"))
        
PrintToChatAll("[SMAC] %N Banned. (%s) "clientreason);
    return 
Plugin_Continue;

symbol already defined: "Action"
symbol already defined: "PrintToChatAll"
symbol is never used "OnBanClient"
Sdg is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-25-2015 , 15:54   Re: On ban ID, ban IP.
Reply With Quote #28

I wrote it in 1.7 syntax.
__________________
WildCard65 is offline
Sdg
BANNED
Join Date: Mar 2014
Old 04-25-2015 , 15:58   Re: On ban ID, ban IP.
Reply With Quote #29

Quote:
Originally Posted by WildCard65 View Post
I wrote it in 1.7 syntax.

SourcePawn Compiler 1.7.0-manual
plugin.sp(17) : error 140: new-style array types cannot specify dimension sizes as part of their type
plugin.sp(17) : warning 215: expression has no effect
plugin.sp(17) : error 001: expected token: ";", but found "]"
plugin.sp(17) : error 029: invalid expression, assumed zero
plugin.sp(17) : fatal error 187: too many error messages on one line

Last edited by Sdg; 04-26-2015 at 19:44.
Sdg is offline
Sdg
BANNED
Join Date: Mar 2014
Old 04-25-2015 , 16:01   Re: On ban ID, ban IP.
Reply With Quote #30

You know why this line not appear?

PHP Code:
PrintToConsole(client"========== Test ============\nNombre:  %N\n SteamID: %s \n IP: %s /n========== Test ============\n"client,  sAuthIDip); 

Last edited by Sdg; 04-25-2015 at 16:03.
Sdg is offline
Reply



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 11:41.


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