Problem Whit 3DTextLabel
#1

Hi,I have a litte problem whit a 3DTextLabel.

The problem is that:


• This a code to buy a fuel station

Quote:

CMD:buyfuelstation(playerid, params[])
{
new str4[128], stringa[128];
new id = IsPlayerNearBenzEnt(playerid);

if(id == -1 || id == 0) return SCM(playerid, COMANDO_USARE, "Non sei in un pompa benzina");

if(BenzinaioInfo[id][bOwned] != 0 || BenzinaioInfo[id][bPrice] == 0) return SCM(playerid, COMANDO_USARE, "Pompa benzina non in vendita");

if(PlayerInfo[playerid][pBenzinaio] != 0) return SCM(playerid, ROSSO, "Hai giа una pompa benzina");

if(PlayerInfo[playerid][pCash] < BenzinaioInfo[id][bPrice]) return SCM(playerid, ROSSO, "Spiacenti, non hai abbastanza soldi.");

PlayerInfo[playerid][pBenzinaio] = id;
PlayerInfo[playerid][pCash] -= BenzinaioInfo[id][bPrice];
GivePlayerMoney(playerid, -BenzinaioInfo[id][bPrice]);
BenzinaioInfo[id][bLocked] = 0;
BenzinaioInfo[id][bOwned] = 1;
BenzinaioInfo[id][bOwner] = RemoveUnderScore(playerid);
SalvaBenzinaio(id);
Salvataggio(playerid);
Delete3DTextLabel(mylabel);
format(str4, sizeof(str4), BENZPATH, id);//formats the file path, with the biz ID
INI_ParseFile(str4, "loadbenz_%s", .bExtra = true, .extra = id );//This is very hard to explain, but it basically loads the info from the file(More in ****** y_ini tutorial.)
//CreateDynamicPickup(1274, 1, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 0); //Creates a pickup at the business entrance.
if(BenzinaioInfo[id][bOwned] == 1)
{
format(stringa,sizeof(stringa), "Pompa benzina di: %s\nPrezzo al litro: 1.7$",BenzinaioInfo[id][bOwner]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 40.0, 0, 0);
}
else
{
format(stringa,sizeof(stringa), "Pompa benzina dello stato\n%d$ per acquistarla\nPrezzo al litro: 1.70$",BenzinaioInfo[id][bPrice]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 40.0, 0, 0);
}
return 1;
}
• In OnGameModeInIt I have a
Quote:

mylabel = Create3DTextLabel(.......);

And if the fuel station has a Owner the 3dTextLabel is a one, else if another text..

But, when I buy a fuelstation, how do to change a text of 3dtextlabel?

Quote:

if(BenzinaioInfo[idx6][bOwned] == 1)
{
format(stringa,sizeof(stringa), "Pompa benzina di: %s\nPrezzo al litro: 1.7$",BenzinaioInfo[idx6][bOwner]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[idx6][bEntranceX], BenzinaioInfo[idx6][bEntranceY], BenzinaioInfo[idx6][bEntranceZ], 40.0, 0, 0);
}
else
{
format(stringa,sizeof(stringa), "Pompa benzina dello stato\n%d$ per acquistarla\nPrezzo al litro: 1.70$",BenzinaioInfo[idx6][bPrice]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[idx6][bEntranceX], BenzinaioInfo[idx6][bEntranceY], BenzinaioInfo[idx6][bEntranceZ], 40.0, 0, 0);
}
Sorry for my english but I'm Italian boy
Reply
#2

https://sampwiki.blast.hk/wiki/Update3DTextLabelText
Reply
#3

How could I use it in this case?
Reply
#4

Quote:

CMD:comprapompabenzina(playerid, params[])
{
new str4[128], stringa[128];
new id = IsPlayerNearBenzEnt(playerid);

if(id == -1 || id == 0) return SCM(playerid, COMANDO_USARE, "Non sei in un pompa benzina");

if(BenzinaioInfo[id][bOwned] != 0 || BenzinaioInfo[id][bPrice] == 0) return SCM(playerid, COMANDO_USARE, "Pompa benzina non in vendita");

if(PlayerInfo[playerid][pBenzinaio] != 0) return SCM(playerid, ROSSO, "Hai giа una pompa benzina");

if(PlayerInfo[playerid][pCash] < BenzinaioInfo[id][bPrice]) return SCM(playerid, ROSSO, "Spiacenti, non hai abbastanza soldi.");

PlayerInfo[playerid][pBenzinaio] = id;
PlayerInfo[playerid][pCash] -= BenzinaioInfo[id][bPrice];
GivePlayerMoney(playerid, -BenzinaioInfo[id][bPrice]);
BenzinaioInfo[id][bLocked] = 0;
BenzinaioInfo[id][bOwned] = 1;
BenzinaioInfo[id][bOwner] = RemoveUnderScore(playerid);
SalvaBenzinaio(id);
Salvataggio(playerid);
format(str4, sizeof(str4), BENZPATH, id);//formats the file path, with the biz ID
INI_ParseFile(str4, "loadbenz_%s", .bExtra = true, .extra = id );//This is very hard to explain, but it basically loads the info from the file(More in ****** y_ini tutorial.)
//CreateDynamicPickup(1274, 1, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 0); //Creates a pickup at the business entrance.
if(BenzinaioInfo[id][bOwned] == 1)
{
format(stringa,sizeof(stringa), "Pompa benzina di: %s\nPrezzo al litro: 1.7$",BenzinaioInfo[id][bOwner]);
Update3DTextLabelText(mylabel, 0xFFFFFFFF, str);
}
else
{
format(stringa,sizeof(stringa), "Pompa benzina dello stato\n%d$ per acquistarla\nPrezzo al litro: 1.70$",BenzinaioInfo[id][bPrice]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 40.0, 0, 0);
}
return 1;
}
Where I error?
Reply
#5

I'm assuming you've got a command to buy tankstations. In that case, update the 3D label's text when the command is performed. Example:
PHP код:
CMD:buyfuelstation(playeridparams[]) {
    
// ...
    // Checks
    // ...
    // Update fuelstation in the database/file
    
BenzinaioInfo[idx6][bOwner] = playerid;
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));  
    
format(new_label_textsizeof(new_label_text), "Pompa benzina di: %s\nPrezzo al litro: $1.7"name);
    
Update3DTextLabel(mylabel0x008080FFnew_label_text);
    return 
true;

Reply
#6

It update so?:

Quote:

if(BenzinaioInfo[id][bOwned] == 1)
{
format(stringa,sizeof(stringa), "Pompa benzina di: %s\nPrezzo al litro: 1.7$",BenzinaioInfo[id][bOwner]);
Update3DTextLabelText(mylabel, 0xFFFFFFFF, str);
}
else
{
format(stringa,sizeof(stringa), "Pompa benzina dello stato\n%d$ per acquistarla\nPrezzo al litro: 1.70$",BenzinaioInfo[id][bPrice]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 40.0, 0, 0);
}

Reply
#7

The command is correct?

Quote:

CMD:comprapompabenzina(playerid, params[])
{
new str[128], stringa[128];
new id = IsPlayerNearBenzEnt(playerid);

if(id == -1 || id == 0) return SCM(playerid, COMANDO_USARE, "Non sei in un pompa benzina");

if(BenzinaioInfo[id][bOwned] != 0 || BenzinaioInfo[id][bPrice] == 0) return SCM(playerid, COMANDO_USARE, "Pompa benzina non in vendita");

if(PlayerInfo[playerid][pBenzinaio] != 0) return SCM(playerid, ROSSO, "Hai giа una pompa benzina");

if(PlayerInfo[playerid][pCash] < BenzinaioInfo[id][bPrice]) return SCM(playerid, ROSSO, "Spiacenti, non hai abbastanza soldi.");

PlayerInfo[playerid][pBenzinaio] = id;
PlayerInfo[playerid][pCash] -= BenzinaioInfo[id][bPrice];
GivePlayerMoney(playerid, -BenzinaioInfo[id][bPrice]);
BenzinaioInfo[id][bLocked] = 0;
BenzinaioInfo[id][bOwned] = 1;
BenzinaioInfo[id][bOwner] = RemoveUnderScore(playerid);
SalvaBenzinaio(id);
Salvataggio(playerid);
if(BenzinaioInfo[id][bOwned] == 1)
{
format(stringa,sizeof(stringa), "Pompa benzina di: %s\nPrezzo al litro: 1.7$",BenzinaioInfo[id][bOwner]);
Update3DTextLabelText(mylabel, 0xFFFFFFFF, str);
}
else
{
format(stringa,sizeof(stringa), "Pompa benzina dello stato\n%d$ per acquistarla\nPrezzo al litro: 1.70$",BenzinaioInfo[id][bPrice]);
mylabel = Create3DTextLabel(stringa, 0x008080FF, BenzinaioInfo[id][bEntranceX], BenzinaioInfo[id][bEntranceY], BenzinaioInfo[id][bEntranceZ], 40.0, 0, 0);
}
return 1;
}
Reply
#8

Not update...
Reply
#9

Are you creating mylabel somewhere else other than in that else-statement? If not, updating the text of a non-existing 3D label is illogical, if not impossible.
Reply
#10

I have create a mylabel in Ongamemodeinit.
When the loop create every fuel station.

Mylabel=create3dtextlabel(......)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)