SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/07/2019, 07:23 AM   #1
rocketbunny
Little Clucker
 
rocketbunny's Avatar
 
Join Date: Jun 2019
Location: Jakarta
Posts: 12
Reputation: 0
Default PartNameKick

I want to kick a player when using a nickname like "[PRO] boi" onplayerconnect
PHP Code:
new ForbiddenPartName[] =
{
        
"[","]","(",")","-","=","$","@","."
};

public 
OnPlayerConnect(playerid)
{
    new 
string[128];
    new 
PlayerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridPlayerNameMAX_PLAYER_NAME);
    
    if(
strfind(PlayerNameForbiddenParttrue) == -1) {
        
SendClientMessage(playerid,red"ATTENTION: Your name is not Allowed on this server, you have been Kicked!.");
        
format(string,sizeof(string),"|- Player %s (Id:%d) has been Automatically Kicked. | Reason: Forbidden Name -|",PlayerName,playerid);
        
SendClientMessageToAll(redstring);  print(string);
       return 
Kick(playerid);
    }
    return 
1;

rocketbunny is offline   Reply With Quote
Old 12/07/2019, 08:04 AM   #2
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,064
Reputation: 50
Default Re: PartNameKick

strfind returns the starting integer from string, so there must be != -1 instead of == -1
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
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



All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.