20.02.2012, 20:02
(
Последний раз редактировалось Tanush123; 20.02.2012 в 21:20.
Причина: Now a new problem
)
pawn Код:
CMD:setname(playerid, params[])
{
new name[20];
mysql_real_escape_string(name,escapename);
GetPlayerName(playerid,Nam,sizeof(Nam));
if(Logged[playerid] == 0)return SCM(playerid,orange,"Please login before using this command.");
if(sscanf(params,"s",escapename))return SCM(playerid,grey,"USAGE: /setname [new name]");
if(strlen(escapename) < 3) return SCM(playerid,orange,"Your name cannot be less than 3 characters.");
if(strlen(escapename) > 20) return SCM(playerid,orange,"Your name cannot be more than 20 characters.");
format(str,sizeof(str),"SELECT * FROM accounts WHERE Name = '%s'",escapename);
mysql_query(str);
mysql_store_result();
if(mysql_num_rows() != 0)
{
mysql_free_result();
return SCM(playerid,red,"ERROR: That Name is already Used by someone!");
}
if(mysql_num_rows() == 0)
{
if(strfind(escapename, "!", true) != -1 || strfind(escapename, "@", true) != -1 || strfind(escapename, "#", true) != -1 || strfind(escapename, "$", true) != -1 || strfind(escapename, "^", true) != -1 || strfind(escapename, "&", true) != -1 || strfind(escapename, "'", true) != -1)return SCM(playerid,red,"Please do not use symbols in your name.");
if(strfind(escapename, " ", true) != -1)return SCM(playerid,red,"Don't use spaces in your name.");
GetPlayerName(playerid,Nam,sizeof(Nam));
format( str, sizeof( str ), "UPDATE accounts SET Name = '%s' WHERE Name = '%s'",escapename,Nam);
mysql_query(str);
//Achievement Change
format(query,sizeof(query),"SELECT * FROM `Achievement` WHERE `Name` = '%s'",Nam);
mysql_query(query);
format(query,sizeof(query),"UPDATE `Achievement` SET `Name` = '%s' WHERE `Name` = '%s'",escapename,Nam);
mysql_query(query);
//Business Change
format(str,sizeof(str),"SELECT * FROM `Business` WHERE `Owner` = '%s'",Nam);
mysql_query(str);
if(PlayerData[playerid][OwnBus] == 1)
{
format(str,sizeof(str),"UPDATE `Business` SET `Owner` = '%s'",pname);
mysql_query(str);
}
//TcR Name
if(strfind(escapename,"[TcR]",true) != -1)
{
format(str,sizeof(str),"SELECT `Name` FROM `clanmembers` WHERE `Name` = '%s'",Nam);
mysql_query(str);
mysql_store_result();
if(mysql_num_rows() == 0)return SCM(playerid,red,"ERROR: Your not in the [TcR] Clan");
if(mysql_num_rows() != 0) return format(str,sizeof(str),"UDPATE `clanmembers` SET `Name` = '%s' WHERE `Name` = '%s'",escapename,Nam) && mysql_query(str);
}
//Org Change
format(str,sizeof(str),"SELECT * FROM orgs WHERE Orgid = %d",PlayerData[playerid][Member]);
mysql_query(str);
if(PlayerData[playerid][Leader] == 1)
{
GetPlayerName(playerid,Nam,sizeof(Nam));
mysql_store_result();
format(str,sizeof(str),"UPDATE orgs SET Leader = '%s' WHERE Orgid = '%d'",Nam,PlayerData[playerid][Member]);
mysql_query(str);
mysql_free_result();
format(OrgInfo[PlayerData[playerid][Member]][LName],24,"%s",Nam);
mysql_query(str);
}
format(str,sizeof(str),"You have changed your name to {FF0000}%s.",escapename);
SCM(playerid,lightyellow,str);
format(str,sizeof(str),"{FF0000}%s{FFFFFF} has changed his name to {8080FF}%s",Nam,escapename);
SendClientMessageToAll(-1,str);
SetPlayerName(playerid,escapename);
}
return 1;
}