new buss1[128]; new buss2[128]; new buss3[128]; new Text3D:BIZ1; new Text3D:BIZ2; new Text3D:BIZ3;
for(new h = 0; h < sizeof(Businesses); h++) { if(IsPlayerInRangeOfPoint(i, 30, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ]) ) { if(GetPlayerVirtualWorld( i ) == 0 ) { if( strcmp(Businesses[h][bOwner], "Nobody", true) == 0 ) { if(Businesses[h][bPrice] == -1) { format(buss1,128, "Business ID: %d \n (%s) Unavailable", h, Businesses[h][bName]); BIZ1 = Create3DTextLabel( buss1 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } else { format(buss2,128, "Business ID: %d \n (%s) \n Available to buy for %d (/buybusiness).", h, Businesses[h][bName], Businesses[h][bPrice]); BIZ2 = Create3DTextLabel( buss2 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } } else { format(buss3,128, "Business ID: %d \n (%s) \n Owner: %s", h, Businesses[h][bName], Businesses[h][bOwner]); BIZ3 = Create3DTextLabel( buss3 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } } } }
command(businessname, playerid, params[]) { new Name[255], string[ 128 ]; if( sscanf( params, "z", Name) ) { SendClientMessage( playerid, WHITE, "SYNTAX: /businessname [New Name]" ); } else { if(strlen(Name) >= 1 && strlen(Name) < 15) { if(strfind(Name, "~", true) ) { format( string, sizeof( string ), "You have changed your business name to %s.", Name); SendClientMessage( playerid, WHITE, string); SaveBusiness(Player[playerid][Business]); Update3DTextLabelText(Text3D:BIZ1, ORANGE, buss1); Update3DTextLabelText(Text3D:BIZ2, ORANGE, buss2); Update3DTextLabelText(Text3D:BIZ3, ORANGE, buss3); Businesses[Player[playerid][Business]][bName] = Name; } else { SendClientMessage( playerid, WHITE, "You may not use the '~' character." ); } } else { SendClientMessage( playerid, WHITE, "Names must be shorter than 15 characters, and higher than 1 character." ); } } return 1; }
command(businessname, playerid, params[])
{
new Name[255], string[ 128 ];
if( sscanf( params, "z", Name) )
{
SendClientMessage( playerid, WHITE, "SYNTAX: /businessname [New Name]" );
}
else
{
if(strlen(Name) >= 1 && strlen(Name) < 15)
{
if(strfind(Name, "~", true) )
{
format( string, sizeof( string ), "You have changed your business name to %s.", Name);
SendClientMessage( playerid, WHITE, string);
SaveBusiness(Player[playerid][Business]);
Update3DTextLabelText(BIZ1, ORANGE, buss1); // changed
Update3DTextLabelText(BIZ2, ORANGE, buss2); // changed
Update3DTextLabelText(BIZ3, ORANGE, buss3); // changed
Businesses[Player[playerid][Business]][bName] = Name;
}
else
{
SendClientMessage( playerid, WHITE, "You may not use the '~' character." );
}
}
else
{
SendClientMessage( playerid, WHITE, "Names must be shorter than 15 characters, and higher than 1 character." );
}
}
return 1;
}
if( sscanf( params, "z", Name))
Update3DTextLabelText(BIZ1, ORANGE, buss1);
Update3DTextLabelText(BIZ2, ORANGE, buss2);
Update3DTextLabelText(BIZ3, ORANGE, buss3);
Businesses[Player[playerid][Business]][bName] = Name;
Four questions:
Why are you looking for an optional string? pawn Код:
pawn Код:
pawn Код:
|
for(new h = 0; h < sizeof(Businesses); h++) { if(IsPlayerInRangeOfPoint(i, 30, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ]) ) { if(GetPlayerVirtualWorld( i ) == 0 ) { if( strcmp(Businesses[h][bOwner], "Nobody", true) == 0 ) { if(Businesses[h][bPrice] == -1) { format(buss1,128, "Business ID: %d \n (%s) Unavailable", h, Businesses[h][bName]); BIZ1 = Create3DTextLabel( buss1 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } else { format(buss2,128, "Business ID: %d \n (%s) \n Available to buy for %d (/buybusiness).", h, Businesses[h][bName], Businesses[h][bPrice]); BIZ2 = Create3DTextLabel( buss2 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } } else { format(buss3,128, "Business ID: %d \n (%s) \n Owner: %s", h, Businesses[h][bName], Businesses[h][bOwner]); BIZ3 = Create3DTextLabel( buss3 , ORANGE, Businesses[h][bExteriorX], Businesses[h][bExteriorY], Businesses[h][bExteriorZ], 20, 0 ); } } } }
Businesses[Player[playerid][Business]][bName] = Name;
array[index][cell] = string;
format(array, array_size, input);
format(Businesses[Player[playerid][Business]][bName], 16, Name); // in your case
strval(params) // same as sscanf(params, "d", variable);
format(string, sizeof(string), "%s", params); // instead of using sscanf + new non-used string
command(businessname, playerid, params[])
{
new
string[57];
if(isnull(params)) return SendClientMessage(playerid, WHITE, "SYNTAX: /businessname [new name]");
else if(strlen(params) < 2 || strelen(params) > 15) return SendClientMessage(playerid, WHITE, "The name has to be between 2 and 15 characters long.");
else if(strfind(params, "~", true) != -1) return SendClientMessage(playerid, WHITE, "You may not use the '~' character.");
format(string, sizeof(string), "You have changed your business name to %s.", params);
SendClientMessage(playerid, WHITE, string);
SaveBusiness(Player[playerid][Business]);
Update3DTextLabelText(BIZ1, ORANGE, params);
Update3DTextLabelText(BIZ2, ORANGE, params);
Update3DTextLabelText(BIZ3, ORANGE, params);
format(Businesses[Player[playerid][Business]][bName], 16, params);
return 1;
}
if(sscanf(params, "s", Name)) // I'm not sure about the "s", it is "s[size]" in sscanf 2.0...
{
// syntax message
}