SA-MP Forums Archive
Textdraws string, information showing - 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: Textdraws string, information showing (/showthread.php?tid=491676)



Textdraws string, information showing - bogushas - 31.01.2014

I really don't understand textdraws very well, but I have a big problem and I can't find the solution for it.

News
Код HTML:
new Text:RodomValgi;
new PlayerText:HungerT[MAX_PLAYERS];
new HungerS[256];
new Text:RodomTroskuly;
new PlayerText:DrinkT[MAX_PLAYERS];
new DrinkS[256];
OnGameModeInit
Код HTML:
// hunger / thirsty
    RodomValgi = TextDrawCreate(495.000030, 103.288887, "hud:radar_burgershot");
    TextDrawLetterSize(RodomValgi, 0.000000, 0.000000);
    TextDrawTextSize(RodomValgi, 9.333342, 9.540744);
    TextDrawAlignment(RodomValgi, 1);
    TextDrawColor(RodomValgi, -1);
    TextDrawSetShadow(RodomValgi, 0);
    TextDrawSetOutline(RodomValgi, 0);
    TextDrawFont(RodomValgi, 4);
 
    RodomTroskuly = TextDrawCreate(582.999938, 102.044433, "hud:radar_diner");
    TextDrawLetterSize(RodomTroskuly, 0.000000, 0.000000);
    TextDrawTextSize(RodomTroskuly, 8.999999, 11.200007);
    TextDrawAlignment(RodomTroskuly, 1);
    TextDrawColor(RodomTroskuly, -1);
    TextDrawSetShadow(RodomTroskuly, 0);
    TextDrawSetOutline(RodomTroskuly, 0);
    TextDrawFont(RodomTroskuly, 4);
OnPlayerSpawn
Код HTML:
    TextDrawShowForPlayer(playerid,RodomValgi);
    TextDrawShowForPlayer(playerid,RodomTroskuly);
   
    HungerT[playerid] = CreatePlayerTextDraw(playerid,516.000244, 100.799980,HungerS);
    format(HungerS, sizeof(HungerS), "%d %%", playerDB[playerid][Hunger]);
    PlayerTextDrawLetterSize(playerid,HungerT[playerid], 0.225666, 1.496296);
    PlayerTextDrawAlignment(playerid,HungerT[playerid], 2);
    PlayerTextDrawColor(playerid,HungerT[playerid], -1);
    PlayerTextDrawSetShadow(playerid,HungerT[playerid], 0);
    PlayerTextDrawSetOutline(playerid,HungerT[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid,HungerT[playerid], 51);
    PlayerTextDrawFont(playerid,HungerT[playerid], 2);
    PlayerTextDrawSetProportional(playerid,HungerT[playerid], 1);
 
    format(DrinkS, sizeof(DrinkS), "%d %%", playerDB[playerid][Drink]);
    DrinkT[playerid] = CreatePlayerTextDraw(playerid,592.333801, 100.799995,DrinkS);
    PlayerTextDrawLetterSize(playerid, DrinkT[playerid], 0.211333, 1.608296);
    PlayerTextDrawAlignment(playerid, DrinkT[playerid], 1);
    PlayerTextDrawColor(playerid, DrinkT[playerid], -1);
    PlayerTextDrawSetShadow(playerid, DrinkT[playerid], 0);
    PlayerTextDrawSetOutline(playerid, DrinkT[playerid], 1);
    PlayerTextDrawBackgroundColor(playerid, DrinkT[playerid], 51);
    PlayerTextDrawFont(playerid, DrinkT[playerid], 2);
 
    PlayerTextDrawShow(playerid,HungerT[playerid]);
    PlayerTextDrawShow(playerid,DrinkT[playerid]);
Here's the problem: what's wrong, in player file there's hunger and drink is up to 100, but I see 0%, and on hungry nothing at all.


Re: Textdraws string, information showing - Immortal_LTU - 31.01.2014

Interesting....


Re: Textdraws string, information showing - MrTinder - 31.01.2014

You should use timer to update your textdraw and new public..


Re: Textdraws string, information showing - bogushas - 31.01.2014

But why do I have to update him? I just want to show the information, not to update.


Re: Textdraws string, information showing - Hoborific - 31.01.2014

Humor me and change the format to %i %%

Sometimes its best to create it before you show it, and use a stock/public to update it.

here's one of mine from somewhere.

pawn Код:
stock HUDUpdatePresents(playerid)
{
    new str1[20];
    format(str1,sizeof(str1),"Presents: %i",PlayerStats[playerid][PresentsFound]);
    TextDrawSetString(TXDPresents[playerid],str1);
}



Re: Textdraws string, information showing - bogushas - 31.01.2014

Okay, that worked. But now why can I still can't see the hunger?


Re: Textdraws string, information showing - KingSenpai - 27.06.2017

PHP код:
=====================
forward Update(); //on the top
=====================
    
SetTimer("Update"50true); //Onfilterscriptinit
    
return 1;
}
=====================
public 
Update()
{
    new 
playerid;
    new 
Float:Health;
    new 
Float:Armour;
    
GetPlayerHealth(playeridHealth);
    
GetPlayerArmour(playeridArmour);
    new New[
41];
    
format(New, sizeof(New), "%.0f"Health);
    
TextDrawSetString(Textdraw1, New);
    
format(New, sizeof(New), "%.0f"Armour);
    
TextDrawSetString(Textdraw3, New); 
=====================
Don`t forget to rep if i helped you! Thanks anyways



Re: Textdraws string, information showing - Whatname - 27.06.2017

-removed


Re: Textdraws string, information showing - Whatname - 27.06.2017

Quote:
Originally Posted by KingSenpai
Посмотреть сообщение
PHP код:
=====================
forward Update(); //on the top
=====================
    
SetTimer("Update"50true); //Onfilterscriptinit
    
return 1;
}
=====================
public 
Update()
{
    new 
playerid;
    new 
Float:Health;
    new 
Float:Armour;
    
GetPlayerHealth(playeridHealth);
    
GetPlayerArmour(playeridArmour);
    new New[
41];
    
format(New, sizeof(New), "%.0f"Health);
    
TextDrawSetString(Textdraw1, New);
    
format(New, sizeof(New), "%.0f"Armour);
    
TextDrawSetString(Textdraw3, New); 
=====================
Don`t forget to rep if i helped you! Thanks anyways
new playerid; wtf?!?!?!?

also it should be player text because global textdraws will show the string of player id 0

PHP код:
forward Update(); 
public 
Update()
{
    new 
Float:Health;
    new 
Float:Armour;
    new New[
8], New2[8];
    for(new 
0GetMaxPlayers(); ++)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        
GetPlayerHealth(iHealth);
        
GetPlayerArmour(iArmour);
        
format(New, sizeof(New), "%0.2f"Health);
        
PlayerTextDrawSetString(playeridTextdraw1, New);
        
format(New2sizeof(New2), "%0.2f"Armour);
        
PlayerTextDrawSetString(playeridTextdraw3New2);
    }
    return 
1;




Re: Textdraws string, information showing - KingSenpai - 27.06.2017

Quote:
Originally Posted by Whatname
Посмотреть сообщение
new playerid; wtf?!?!?!?

also it should be player text because global textdraws will show the string of player id 0

PHP код:
forward Update(); 
public 
Update()
{
    new 
Float:Health;
    new 
Float:Armour;
    new New[
8], New2[8];
    for(new 
0GetMaxPlayers(); ++)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        
GetPlayerHealth(iHealth);
        
GetPlayerArmour(iArmour);
        
format(New, sizeof(New), "%0.2f"Health);
        
PlayerTextDrawSetString(playeridTextdraw1, New);
        
format(New2sizeof(New2), "%0.2f"Armour);
        
PlayerTextDrawSetString(playeridTextdraw3New2);
    }
    return 
1;

Its still works fine, i don`t see any problem in my server.