15.03.2012, 08:54
Firstly, sscanf checks if a command was not typed correctly. You need to add an else statement to check if it was typed correctly.
Secondly, you are making the player's clan equal to their playerid which is not what you want. Don't put so many spaces in your command lol.
Another min-tutorial.
Secondly, you are making the player's clan equal to their playerid which is not what you want. Don't put so many spaces in your command lol.
Another min-tutorial.
pawn Код:
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;
}