19.03.2017, 21:38
Hello there friends.
I need some help with labels from houses when a player change his(her) name.
So, i use house system by rootcause, and that system allows the player to buy more than 1 house and
this means there are 2, 3 or more houses with player name in their label. (Ex: FaLLenGirL's House) etc.
I want that when i use '/newname' command and i change my name that labels (from all houses that i own) to update
with the new name that i changed. I will paste my '/newname' command bellow:
When i buy or sell a house, the labels will be updated with this stock:
And in the "LoadHouses" public, where the houses loaded on server, the labels etc are here:
So, in the end i just want that the player that is online, when he(she) use the command '/newname' and change
his(her) name, their house labels to update with his(her) newname. If you can help me i would be very grateful.
I need some help with labels from houses when a player change his(her) name.
So, i use house system by rootcause, and that system allows the player to buy more than 1 house and
this means there are 2, 3 or more houses with player name in their label. (Ex: FaLLenGirL's House) etc.
I want that when i use '/newname' command and i change my name that labels (from all houses that i own) to update
with the new name that i changed. I will paste my '/newname' command bellow:
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 )
{
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;
}
PHP код:
stock UpdateHouseLabel( id )
{
if( !Iter_Contains( Houses, id ) )
return 0;
eString[ 0 ] = EOS;
if( !strcmp( HouseData[ id ][ Owner ], "-" ) )
{
format( eString, sizeof( eString ), "{41C63F}House For Sale {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n{FFFFFF}%s\n{FFFFFF}Price: {41C63F}${D6D6D6}%s", id, HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], convertNumber( HouseData[ id ][ Price ] ) );
}
else
{
if( HouseData[ id ][ SalePrice ] > 0 )
{
format( eString, sizeof( eString ), "{D6D6D6}%s's House\n{FFFFFF}is now {41C63F}For Sale {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n%s\n{FFFFFF}%s\n{FFFFFF}Price: {41C63F}${D6D6D6}%s", HouseData[ id ][ Owner ], id, HouseData[ id ][ Name ], HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], convertNumber( HouseData[ id ][ SalePrice ] ) );
}
else
{
format( eString, sizeof( eString ), "{D6D6D6}%s's House {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n%s\n{FFFFFF}%s\n%s\n{D6D6D6}%s", HouseData[ id ][ Owner ], id, HouseData[ id ][ Name ], HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], LockNames[ HouseData[ id ][ LockMode ] ], HouseData[ id ][ Address ] );
}
}
UpdateDynamic3DTextLabelText( HouseData[ id ][ HouseLabel ], ~1, eString );
return 1;
}
PHP код:
forward LoadHouses( );
public LoadHouses( )
{
new rows = cache_num_rows( );
if( rows )
{
new id, loaded, for_sale, label[ 5000 ];
while( loaded < rows )
{
id = cache_get_field_content_int( loaded, "ID" );
cache_get_field_content( loaded, "HouseName", HouseData[ id ][ Name ], .max_len = MAX_HOUSE_NAME );
cache_get_field_content( loaded, "HouseOwner", HouseData[ id ][ Owner ], .max_len = MAX_PLAYER_NAME );
cache_get_field_content( loaded, "HousePassword", HouseData[ id ][ Password ], .max_len = MAX_HOUSE_PASSWORD );
HouseData[ id ][ houseX ] = cache_get_field_content_float( loaded, "HouseX" );
HouseData[ id ][ houseY ] = cache_get_field_content_float( loaded, "HouseY" );
HouseData[ id ][ houseZ ] = cache_get_field_content_float( loaded, "HouseZ" );
HouseData[ id ][ Price ] = cache_get_field_content_int( loaded, "HousePrice" );
HouseData[ id ][ SalePrice ] = cache_get_field_content_int( loaded, "HouseSalePrice" );
HouseData[ id ][ Interior ] = cache_get_field_content_int( loaded, "HouseInterior" );
HouseData[ id ][ LockMode ] = cache_get_field_content_int( loaded, "HouseLock" );
//printf( "On Lock Mode %i", HouseData[ id ][ LockMode ] );
HouseData[ id ][ SafeMoney ] = cache_get_field_content_int( loaded, "HouseMoney" );
HouseData[ id ][ LastEntered ] = cache_get_field_content_int( loaded, "LastEntered" );
format( HouseData[ id ][ Address ], MAX_HOUSE_ADDRESS, "%d, %s, %s", id, GetZoneName( HouseData[ id ][ houseX ], HouseData[ id ][ houseY ], HouseData[ id ][ houseZ ] ), GetCityName( HouseData[ id ][ houseX ], HouseData[ id ][ houseY ], HouseData[ id ][ houseZ ] ) );
if( strcmp( HouseData[ id ][ Owner ], "-"))
{
if( HouseData[ id ][ SalePrice ] > 0 )
{
for_sale = 1;
format( label, sizeof( label ), "{D6D6D6}%s's House\n{FFFFFF}is now {41C63F}For Sale {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n%s\n{FFFFFF}%s\n{FFFFFF}Price: {41C63F}${D6D6D6}%s", HouseData[ id ][ Owner ], id, HouseData[ id ][ Name ], HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], convertNumber( HouseData[ id ][ SalePrice ] ) );
}
else
{
for_sale = 0;
format( label, sizeof( label ), "{D6D6D6}%s's House {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n{FFFFFF}%s\n{FFFFFF}%s\n%s\n{D6D6D6}%s", HouseData[ id ][ Owner ], id, HouseData[ id ][ Name ], HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], LockNames[ HouseData[ id ][ LockMode ] ], HouseData[ id ][ Address ] );
}
}
else
{
for_sale = 1;
format( label, sizeof( label ), "{41C63F}House For Sale {FFFFFF}(ID: {D6D6D6}%d{FFFFFF})\n{FFFFFF}%s\n{FFFFFF}Price: {41C63F}${D6D6D6}%s", id, HouseInteriors[ HouseData[ id ][ Interior ] ][ IntName ], convertNumber(HouseData[ id ][ Price ] ) );
}
HouseData[ id ][ HousePickup ] = CreateDynamicPickup((!for_sale) ? 19522 : 1273, 1, HouseData[ id ][ houseX ], HouseData[ id ][ houseY ], HouseData[ id ][ houseZ ], 0 );
HouseData[ id ][ HouseIcon ] = CreateDynamicMapIcon( HouseData[ id ][ houseX ], HouseData[ id ][ houseY ], HouseData[ id ][ houseZ ], (!for_sale) ? 32 : 31, 0, .worldid = 0, .streamdistance = 300.0 );
HouseData[ id ][ HouseLabel ] = CreateDynamic3DTextLabel( label, ~1, HouseData[ id ][ houseX ], HouseData[ id ][ houseY ], HouseData[ id ][ houseZ ] + 0.35, 30.0, .worldid = 0, .testlos = 1 );
Iter_Add(Houses, id);
loaded ++;
}
printf( "Loaded %d Houses.", loaded );
}
return 1;
}
his(her) name, their house labels to update with his(her) newname. If you can help me i would be very grateful.