public OnPlayerConnect(playerid)
{
new name[24]; // Makes a new string for the name
GetPlayerName(playerid,name,sizeof(name)); // Assigns it to the name
// Using strfind, this searches their name for the clan tag and what not.
if(strfind(name,"[TAG]",true) != -1) // The != is if it was found.
{
// If it was found then we follow that if with an other if to check if they are
// part of the clan that they have in front of their name.
if(PlayerInfo[playerid][pClan] != 1) // In this case the clan they need to be in is 1
{
// If they are not in the clan then it kicks them.
SendClientMessage(playerid,-1,"You are not in the [TAG] clan, you have been kicked as a result.");
Kick(playerid);
}
else
{
// If they are then send them a nice welcome message. :)
SendClientMessage(playerid,-1,"Welcome back to clan [TAG]");
return 1;
}
}
return 1;
}
You would use strfind to check their name for the desired clan tag. I wrote a mini-tutorial. It hasn't been tested, but should work.
pawn Код:
|
CMD :setclanmember ( playerid , params [ ] )
{
if ( IsPlayerConnected ( playerid ) )
{
if ( IsPlayerAdmin ( playerid ) )
{
new
nom [ MAX_PLAYER_NAME ] ,
str [ 79 ] ,
pid
;
if ( sscanf ( params, "u" , pid ) ) return SendClientMessage ( playerid , 0xBEBEBEAA , "[ERROR]: /Setclanmember [playerid]" ) ;
{
pClan [ pid ] = pid ;
GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
format ( str , sizeof ( str ) , "*You Have Successfuly Set %s As An Clan Member!" , pid ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
format ( str , sizeof ( str ) , "*%s Has Made You A [Du] Clan Member! Now You Are Allowed To Use [DU] Tag in Your Name!" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
}
}
else
SendClientMessage ( playerid, 0x8B1A1AAA , "[ERROR] Only RCON Administrators Can Use This Command!" ) ;
}
else
SendClientMessage ( playerid , 0x8B1A1AAA , "[ERROR] Player Not Connected!" ) ;
return 1;
}
CMD:setclanmember(playerid,params[])
{
new pid; // Your playerid variable.
// If they are not an admin then return a message saying their not. Take note that returning stops processing
// the command. The ! is if IsPlayerAdmin returns false, in other words he is not an admin.
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xBEBEBEAA,"[ERROR]: You are not an admin!"):
// If the player is an admin, then it continues and checks if they typed the command correctly.
// sscanf automatically says if they didn't type it correctly, so if they they didn't then tell em how to use
// the command and stop processing it
if(sscanf(params,"u",pid)) return SendClientMessage(playerid,0xBEBEBEAA,"[USAGE]: /setclanmember [playerid]");
// Now, if they are an admin, and they typed the command correctly, then we will see if the player that they
// want to add to the clan is connected. If the pid they typed is not online then it sends them a message telling them so
if(pid == INVALID_PLAYER_ID) return SendClientMessage(playerid,0xBEBEBEAA,"[ERROR]: Player not found.");
// Now if everything is correct the 'else' says if everything else has passed, then continue.
else
{
new nom[MAX_PLAYER_NAME],str[79];
// If everything else has passed then set their clan to 1.
pClan[pid] = 1;
GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
format ( str , sizeof ( str ) , "*You Have Successfuly Set %s As An Clan Member!" , pid ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
format ( str , sizeof ( str ) , "*%s Has Made You A [Du] Clan Member! Now You Are Allowed To Use [DU] Tag in Your Name!" , nom ) ;
SendClientMessage ( playerid , 0x00FF00AA , str ) ;
// Using strins (string insert) it gets the name string, and adds [DU]
// the 0 is the position where to insert [DU] which is 0 because you
// want it at the beginning of the name.
strins(nom,"[DU]",0,sizeof(nom));
// Now that we inserted the clan tag into their name using strins, we
// set their name with the clan tag.
SetPlayerName(pid,nom);
}
return 1;
}