public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYER_NAME],string[125]; // These are our variables pname stores the players name for later use, and string is used later too.
GetPlayerName(playerid,pname,sizeof(pname)); // This reads what player is connecting and saves it to the variable pname that we made.
if(strfind(pname, "admin", true) != -1) // We use strfind, to check if a certain variable contains something. In this case, we are checking if the players name contains "admin"
{
format(string, sizeof(string), "{FF0000}Hello %s, your name contains the word 'Admin' please change it.",pname);// We use format here, so we can send the player a message with his/her name inside of it.
SendClientMessage(playerid, -1, string);// This uses the format what we did above, it basically sends whatever is inside of the format above.
SetTimerEx("KickPlayer", 100, false, "i", playerid);// We use a timer here, as if we didn't the player would not see the message before he was kicked.
}
return 1;
}
forward KickPlayer(playerid);
public KickPlayer(playerid)// This function will be called when the timer goes down, whatever is inside here will be run.
{
Kick(playerid);// Finally, this kicks the player from the server.
return 1;
}
forward KickPlayer(playerid);
public KickPlayer(playerid)
{
Kick(playerid);
return 1;
}
public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYER_NAME],string[125]; GetPlayerName(playerid,pname,sizeof(pname));
if(strfind(pname, "admin", true) != -1)
{
format(string, sizeof(string), "{FF0000}Hello %s, your name contains the word 'Admin' please change it.",pname);
SendClientMessage(playerid, -1, string);
SetTimerEx("KickPlayer", 100, false, "i", playerid);
}
return 1;
}
|
Well. I connected with Admin and it worked then i connected with my name "[Cali]Stuun"
It said hello cali stuun your name contains admin bla bla.. like i still have admin |
|
Seems you didn't test this but you copied from other gamemode/filterscript.
OT: It would be great if you put screenshot e.t.c so you can show players that this work perfect. |