01.12.2013, 01:17
pawn Код:
COMMAND:changemyname(playerid, params[])
{
new newname[24], pname[24];
if(sscanf(params, "u",newname)) return SCP(playerid, "[New_Name]");
GetPlayerName(playerid,pname,24);
new query1[256],escapename[24];
mysql_real_escape_string(newname, escapename);
format(query1, sizeof(query1), "SELECT `user` FROM `playerdata` WHERE `user` = '%s'", escapename);
mysql_query(query1);
mysql_store_result();
new rows = mysql_num_rows();
if(!rows)
{
new query[256];
format(query, sizeof(query), "UPDATE `playerdata` SET `user`= '%s' WHERE `user` ='%s'",escapename,pname);
mysql_query(query);
SetPlayerName(playerid, newname);
//==============================================================================
for(new i; i < sizeof(House); i++)
{
format(iStr, sizeof(iStr), "Houses/Casa%d.txt", i);
if(!strcmp(House[i][tmpowner], pname, false))
{
dini_Set(iStr, "owner", newname);
myStrcpy(House[i][tmpowner],newname);
UpdateHouse(i);
}
}
for(new i; i < sizeof(biz); i++)
{
format(iStr, sizeof(iStr), "Businesses/%s.txt", biz[i][bizname]);
if(!strcmp(biz[i][tmpowner], pname, false))
{
dini_Set(iStr, "owner", newname);
myStrcpy(biz[i][tmpowner],newname);
UpdateBiz(i);
}
}
for(new i = 1; i < sizeof(Vehicles); i++)
{
if(!strcmp(Vehicles[i][carowner], pname))
{
dini_Set(CarFile(i), "owner", newname);
myStrcpy(Vehicles[i][carowner], newname);
}
}
//==============================================================================
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
SendClientMessage(playerid, COLOR_RED, "=========================== ATTENTION ===========================");
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
format(iStr, sizeof(iStr), " Your name has been changed to \"%s\". Make sure you always login with that name now!", newname);
SendClientMessage(playerid, COLOR_LIGHTGREY, iStr);
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
SendClientMessage(playerid, COLOR_RED, "=========================== ATTENTION ===========================");
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
SendClientMessage(playerid, COLOR_LIGHTGREY, "");
//==============================================================================
}
else if(rows == 1)
{
SendClientError(playerid, "Account already exists!");
}
mysql_free_result();
return 1;
}