Originally Posted by Mencent
Hello!
Does it work like this?
PHP код:
CMD:newname( playerid, params[ ] )
{
LoginCheck( playerid );
new newname[ 24 ], Rows, Fields, query1[ 256 ], escapename[ 24 ],
pname[ MAX_PLAYER_NAME ], Cache:newnames;
if( PlayerInfo[ playerid ][ PremiumLevel ] != 10 )
return SendError( playerid, "You must be Premium Level {FF0000}10 {FFFFFF}to change your name !" );
if( PlayerInfo[ playerid ][ NewNameAgain ] == 1 )
return SendError( playerid, "You can change your name at every 10 minutes !" );
if( sscanf( params, "s[24]", newname ) )
return SendUsage( playerid, "/newname [New Name]" );
if( strlen( newname ) < 4 || strlen( newname ) > 24 )
return SendError( playerid, "Unacceptable nick lenght. Between 4 and 24 characters !" );
GetPlayerName( playerid, pname, 24 );
cache_get_data( Rows, Fields, database );
mysql_real_escape_string( newname, escapename );
format( query1, sizeof( query1 ), "SELECT `Name` FROM `Accounts` WHERE `Name` = '%s'", escapename );
newnames = mysql_query( database, query1 );
if( !Rows )
{
for(new i,j=sizeof(HouseData);i<j;i++)
{
if(!strcmp(HouseData[i][Owner],pname,true))
{
strcat(HouseData[i][Owner],params,sizeof(Housedata[]));
UpdateHouseLabel(i);
continue;
}
}
new query[ 3000 ];
format( query, sizeof( query ), "UPDATE `Accounts` SET `Name`= '%s' WHERE `Name` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `Achievements` SET `AchName` = '%s' WHERE `AchName` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `housekeys` SET `Player` = '%s' WHERE `Player` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `houses` SET `HouseOwner` = '%s' WHERE `HouseOwner` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `housesales` SET `OldOwner` = '%s' WHERE `OldOwner` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `housesales` SET `NewOwner` = '%s' WHERE `NewOwner` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `housevisitors` SET `Visitor` = '%s' WHERE `Visitor` ='%s'", escapename, pname );
mysql_tquery( database, query );
format( query, sizeof( query ), "UPDATE `Properties` SET `PropOwner` = '%s' WHERE `PropOwner` ='%s'", escapename, pname );
mysql_tquery( database, query );
SetPlayerName( playerid, params );
eBigString[ 0 ] = EOS;
format( eBigString, sizeof( eBigString ), "[Server Info]: {%06x}%s(%d) {FFFFFF}has changed his name into '{D6D6D6}%s{FFFFFF}'.", GetPlayerColor( playerid ) >>> 8, pname, playerid, params );
SendClientMessageToAll( 0xD6D6D6FF, eBigString );
eString[ 0 ] = EOS;
format( eString, sizeof( eString ), "{FFFFFF}You have changed your name sucesfully.\nPlease reconnect to save your dates in {FF0000}database{FFFFFF}." );
ShowPlayerDialog( playerid, EMPTY_DIALOG, DIALOG_STYLE_MSGBOX, "{FFFFFF}New Name:", eString, "Ok","" );
PlayerInfo[ playerid ][ NewNameAgain ] = 1;
SetTimerEx( "NewNameAgain2", 10 * 60 * 1000, 0, "i", playerid );
}
else if( Rows == 1 )
{
SendError( playerid, "This name already exists in the database !" );
}
cache_delete( newnames );
return 1;
}
I added this:
PHP код:
for(new i,j=sizeof(HouseData);i<j;i++)
{
if(!strcmp(HouseData[i][Owner],pname,true))
{
strcat(HouseData[i][Owner],params,sizeof(Housedata[]));
UpdateHouseLabel(i);
continue;
}
}
|