[HELP] Update3DTextLabelText
#1

Ok, i made it so all these 3Dlabels appear, but now when you type '/businessname' or '/sellbusiness' , it keeps the old 3Dlabel, plus adds the new, leaving 2 labels in place.

Here is where the labels first get created:

Код:
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 );
								}
							}
						}
					}
Here is the command:
Код:
	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;
	}
Please help, thank you.
Reply
#2

You don't need to use the "Text3D" tag after creating the variables, do you?

New possible code:
pawn Код:
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;
}
Reply
#3

Didnt work
Reply
#4

Four questions:

Why are you looking for an optional string?
pawn Код:
if( sscanf( params, "z", Name))
Where do you format "buss1", "buss2" and "buss3"?
pawn Код:
Update3DTextLabelText(BIZ1, ORANGE, buss1);
Update3DTextLabelText(BIZ2, ORANGE, buss2);
Update3DTextLabelText(BIZ3, ORANGE, buss3);
What are you trying to do by this:
pawn Код:
Businesses[Player[playerid][Business]][bName] = Name;
And are you using sscanf 2.0?
Reply
#5

Quote:
Originally Posted by Miguel
Посмотреть сообщение
Four questions:

Why are you looking for an optional string?
pawn Код:
if( sscanf( params, "z", Name))
Where do you format "buss1", "buss2" and "buss3"?
pawn Код:
Update3DTextLabelText(BIZ1, ORANGE, buss1);
Update3DTextLabelText(BIZ2, ORANGE, buss2);
Update3DTextLabelText(BIZ3, ORANGE, buss3);
What are you trying to do by this:
pawn Код:
Businesses[Player[playerid][Business]][bName] = Name;
And are you using sscanf 2.0?
The optional string is what the person uses to give the new business name.

Its formated here:
Код:
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 );
								}
							}
						}
					}
This sets the name in the business file:
Код:
Businesses[Player[playerid][Business]][bName] = Name;
I havnt checked yet on the 2.0
Reply
#6

Okay, first off, you can't do this:
pawn Код:
array[index][cell] = string;
You need to use format:
pawn Код:
format(array, array_size, input);
format(Businesses[Player[playerid][Business]][bName], 16, Name); // in your case
Second of all, you looked for an optional string but you didn't use it at all.

I suggest you to use sscanf ONLY if you have to look for more than two parameters in a command.

Example:
/mycommand [playerid] // 1 parameter
/mycommand [playerid] [something] // 2 parameters
/mycommand [playerid] [something] [something else] // more than 2 params

If you don't have a second parameter, use "params" as an everything.

pawn Код:
strval(params) // same as sscanf(params, "d", variable);
format(string, sizeof(string), "%s", params); // instead of using sscanf + new non-used string
I think you're using zcmd, this might be useful for you:
pawn Код:
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;
}
By the way: If you decide to use sscanf, this is the way:
pawn Код:
if(sscanf(params, "s", Name)) // I'm not sure about the "s", it is "s[size]" in sscanf 2.0...
{
    // syntax message
}
Reply
#7

[Deleted By Author]
Reply
#8

Ok, ive used what you said, but the old 3Dlabel still remains underneath
Reply
#9

Maybe you're creating them, over and over again. Are you using a timer or something to create them?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)