new String[128];//Declaring the string.
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,namevar,24);//Make sure you already defined the variable that stores the player's name.
if(strfind(namevar,"The clan tag will go here: example '[mG]' ",true) != -1)//Change to the your clan tag.
{
format(String,76,"SELECT Name FROM clanmembers WHERE Name='%s' LIMIT 1",escapename);//Selecting the Name field from the "clanmembers" table.
mysql_query(String);
mysql_store_result();//Storing the result.
if(mysql_num_rows() != 0)//If the name was found in the table, then we can give the player a warm welcome.
{
mysql_free_result();//Remember to free the result, or you'll get lag issues.
SendClientMessage(playerid,-1,"Nice, you're in the clan.");//Warm welcome :)
}
if(mysql_num_rows() == 0)//Now, if the player's name was not found in the clan table, then take the following actions:
{
mysql_free_result();//Free the result.
format(String,sizeof(String),"%s has been kicked from the server. Reason: Not in clan.",GetName(playerid));
SendClientMessageToAll(-1,String);
Kick(playerid);//Kicking the player.
return 1;
}
}
return 1;
}
COMMAND:setclanmember(playerid, params[])
{
if(!IsPlayerAdmin(playerid))return 0;//Checking if the player is a RCON admin.
new id;
if(sscanf(params,"u",id))return SendClientMessage(playerid,-1,"Usage: /setclanmember [id]");//Using sscanf to check if the params where filled.
GetPlayerName(id,namevar,24);//Again, getting the player's name, and storing it into the name variable.
format(String,sizeof(String),"SELECT Name FROM clanmembers WHERE Name='%s' LIMIT 1",namevar);//Selecting the name from the table.
mysql_query(String);
mysql_store_result();//Storing the result.
if(mysql_num_rows() != 0)return (mysql_free_result() && SendClientMessage(playerid,-1,"That player is already in the clan."));//Freeing the result, and making sure you don't add that name again.
mysql_free_result();//Freeing the result.
format(String,sizeof(String),"INSERT INTO clanmembers (Name) VALUES ('%s')",namevar);//If the name was not found, then insert it into the table.
mysql_query(String);
format(String,sizeof(String),"You've accepted %s into the clan.",namevar);//
SendClientMessage(playerid,-1,String);
GetPlayerName(playerid,namevar,24);//Getting your name (user of the command)
format(String,sizeof(String),"You've been accepted into the clan by admin %s.",namevar);
SendClientMessage(id,-1,String);
return 1;
}
COMMAND:removeclanmember(playerid, params[])
{
if(!IsPlayerAdmin(playerid))return 0;//Checking if the player is a RCON admin.
if(sscanf(params,"s",params))return SendClientMessage(playerid,-1,"Usage: /removeclanmember [name]");
format(String,76,"SELECT Name FROM clanmembers WHERE Name='%s' LIMIT 1",params);//Selecting the name from the table.
mysql_query(String);
mysql_store_result();//Storing the result.
if(mysql_num_rows() == 0)return (mysql_free_result() && SendClientMessage(playerid,-1,"That name was not found in the table."));//Freeing the result, and giving an error that the name entered is not in the table.
mysql_free_result();//Freeing the result.
format(String,60,"DELETE FROM clanmembers WHERE Name='%s'",params);//If the name was found, then delete it.
mysql_query(String);
format(String,100,"You've removed %s from the clan.",params);
SendClientMessage(playerid,-1,String);
return 1;
}
Great tutorial, but you should make a command that does.
/setclanowner - Makes it so that you can set a player a clan owner. (Multiple people) |
C:\Users\Faqahat\LSSW\Server\gamemodes\LS-SW.pwn(2417) : error 017: undefined symbol "namevar" C:\Users\Faqahat\LSSW\Server\gamemodes\LS-SW.pwn(241 ![]() C:\Users\Faqahat\LSSW\Server\gamemodes\LS-SW.pwn(2420) : error 017: undefined symbol "escapename" C:\Users\Faqahat\LSSW\Server\gamemodes\LS-SW.pwn(2421) : error 017: undefined symbol "mysql_query" C:\Users\Faqahat\LSSW\Server\gamemodes\LS-SW.pwn(2431) : error 017: undefined symbol "GetName" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 5 Errors. |
new namevar[MAX_PLAYER_NAME];
new escapename[MAX_PLAYER_NAME];
// Replace GetName To GetPlayerName