Raised This Month: $77 Target: $400
 19% 

HELP OnBanClient()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SpirT
Member
Join Date: Sep 2018
Location: PT FixingMyGF(int time)
Old 03-04-2019 , 14:26   HELP OnBanClient()
Reply With Quote #1

Hello guys,

Today I decided to do a plugin for my server.

It consists that when a player is banned it prints to all players:
-> Name of player that was banned.
-> Reason of the Ban.
-> Time of the ban.
-> Who Banned the player.

I already done this on my code:
PHP Code:
public void OnPluginStart()
{
    
HookEvent("round_start"EventRoundStartEventHookMode_PostNoCopy);
}

public 
Action EventRoundStart(Event eventchar[] namebool bDontBroadcast)
{
    for (
int client 1client <= MaxClientsclient++)
    {
        
char time[32];
        
char reason[512];
        
char message[512];
        
int e_time;
        
StringToInt(time) == e_time;
        
OnBanClient(cliente_timereasonmessage)
        {
            
PrintToChatAll("Player %s was banned for %s. The ban is %s (0 == permanent)"clientreasone_time);
        }
    }

Can someone help me with the other part of the code?

Actual errors
Code:
Line 36: error 004 -> function "OnBanClient" is not implemented.
Regards,

SpirT.
__________________
SpirT is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 03-04-2019 , 16:26   Re: HELP OnBanClient()
Reply With Quote #2

OnBanClient is a forward function that belongs in your plugin's global scope. It's parameters and when it's called are not controlled by your plugin.

Spoiler

Last edited by Kolapsicle; 03-04-2019 at 16:27.
Kolapsicle is offline
SpirT
Member
Join Date: Sep 2018
Location: PT FixingMyGF(int time)
Old 03-05-2019 , 05:57   Re: HELP OnBanClient()
Reply With Quote #3

Quote:
Originally Posted by Kolapsicle View Post
OnBanClient is a forward function that belongs in your plugin's global scope. It's parameters and when it's called are not controlled by your plugin.

Spoiler
First thanks for your reply! So the code just needs to be like this?
PHP Code:

public Action OnBanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany source)
{
    
PrintToChatAll("%s was banned for %s. The ban is %s (0 = permanent)"clientreasontime);

__________________
SpirT is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 03-05-2019 , 07:58   Re: HELP OnBanClient()
Reply With Quote #4

Quote:
Originally Posted by SpirT View Post
First thanks for your reply! So the code just needs to be like this?
PHP Code:

public Action OnBanClient(int clientint timeint flags, const char[] reason, const char[] kick_message, const char[] commandany source)
{
    
PrintToChatAll("%s was banned for %s. The ban is %s (0 = permanent)"clientreasontime);

Correct. However, change the first %s to %N, and change the third %s to %i.

Last edited by ThatKidWhoGames; 03-05-2019 at 07:59.
ThatKidWhoGames is offline
SpirT
Member
Join Date: Sep 2018
Location: PT FixingMyGF(int time)
Old 03-05-2019 , 14:51   Re: HELP OnBanClient()
Reply With Quote #5

Quote:
Originally Posted by ThatKidWhoGames View Post
Correct. However, change the first %s to %N, and change the third %s to %i.
Hey. Thanks for your reply too. Why do i need to change the third %s to %i? What's the diference? And one thing. Where can i get the name of the player who banned the client?
__________________
SpirT is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 03-05-2019 , 15:26   Re: HELP OnBanClient()
Reply With Quote #6

%s prints a string and %i prints an int.

The forward in this thread doesnt appear to parse the client who issued the ban.
__________________
Neuro Toxin is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-05-2019 , 19:38   Re: HELP OnBanClient()
Reply With Quote #7

Quote:
Originally Posted by SpirT View Post
Where can i get the name of the player who banned the client?
Quote:
Originally Posted by Neuro Toxin View Post
The forward in this thread doesnt appear to parse the client who issued the ban.
SourceMod's base plugin usage of BanClient (i.e. sm_ban) passes the banning admin as the source param.
__________________
asherkin is online now
SpirT
Member
Join Date: Sep 2018
Location: PT FixingMyGF(int time)
Old 03-06-2019 , 04:39   Re: HELP OnBanClient()
Reply With Quote #8

Quote:
Originally Posted by asherkin View Post
SourceMod's base plugin usage of BanClient (i.e. sm_ban) passes the banning admin as the source param.
Hey asherkin. Thank's for your reply. So for source I should use %s or %i? I'm going to test with the %s and the %i and see if it works!
__________________

Last edited by SpirT; 03-06-2019 at 04:45.
SpirT is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-06-2019 , 04:53   Re: HELP OnBanClient()
Reply With Quote #9

Quote:
Originally Posted by SpirT View Post
Hey asherkin. Thank's for your reply. So for source I should use %s or %i? I'm going to test with the %s and the %i and see if it works!
It is a client index (an integer), so %i if you want to print the number, or %N to print the client name, never %s (it could cause a crash).
__________________
asherkin is online now
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 07:27.


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