SA-MP Forums Archive
Problem Whit 3DTextLabel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem Whit 3DTextLabel (/showthread.php?tid=613896)



Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

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


Re: Problem Whit 3DTextLabel - AndySedeyn - 02.08.2016

https://sampwiki.blast.hk/wiki/Update3DTextLabelText


Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

How could I use it in this case?


Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

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?


Re: Problem Whit 3DTextLabel - AndySedeyn - 02.08.2016

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;




Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

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);
}




Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

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;
}



Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

Not update...


Re: Problem Whit 3DTextLabel - AndySedeyn - 02.08.2016

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.


Re: Problem Whit 3DTextLabel - AlexPalermitano97 - 02.08.2016

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

Mylabel=create3dtextlabel(......)