SA-MP Forums Archive
a 3d label is not created. - 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: a 3d label is not created. (/showthread.php?tid=663188)



a 3d label is not created. - Kincaid - 24.01.2019

The 3d label of the first index is not shown while it woks fine with other indices.

PHP код:
public loadtrees()
{
    print(
"Loading trees");
    for(new 
1MAX_TREESg++)
    {
        new 
LoadString[256];
        
format(LoadStringsizeof(LoadString), "/Trees/%d.dini.save"g);
        if(
dini_Exists(LoadString))
        {
            
treeData[g][tID] = g;
            
treeData[g][tX] = dini_Float(LoadString,"tX");
            
treeData[g][tY] = dini_Float(LoadString,"tY");
            
treeData[g][tZ] = dini_Float(LoadString,"tZ");
            
treeData[g][tObject] = CreateObject(617treeData[g][tX], treeData[g][tY], treeData[g][tZ], 0.00000.00000.0000); // tree
            
treeData[g][woodReady] = false;
            
treeData[g][tHealth] = 100;
                new 
string2[80];
            
format(string2sizeof(string2), "{ffff00}Tree\n/cuttree\nHealth: %i"treeData[g][tHealth]);
                
treeData[g][tLabel] = Create3DTextLabel(string2COLOR_YELLOWtreeData[g][tX], treeData[g][tY], treeData[g][tZ] + 0.2 3.11177.500);
                
treeData[g][tStatus] = true;
        }
    }
    return 
1;

the 3d label of tree id 1 is not shown while it's fine with {2,...,max_trees} ( the object of tree id 1 is created )

I gave it a try and changed the function to:
PHP код:
forward loadtrees();
public 
loadtrees()
{
    print(
"Loading trees");
    for(new 
1MAX_TREESg++)
    {
        new 
LoadString[256];
        
format(LoadStringsizeof(LoadString), "/Trees/%d.dini.save"g);
        if(
dini_Exists(LoadString))
        {
            
treeData[g][tID] = g;
            
treeData[g][tX] = dini_Float(LoadString,"tX");
            
treeData[g][tY] = dini_Float(LoadString,"tY");
            
treeData[g][tZ] = dini_Float(LoadString,"tZ");
            
treeData[g][tObject] = CreateObject(617treeData[g][tX], treeData[g][tY], treeData[g][tZ], 0.00000.00000.0000); // tree
            
treeData[g][woodReady] = false;
            
treeData[g][tHealth] = 100;
                new 
string2[40];
            
format(string2sizeof(string2), "{ffff00}Tree\n/cuttree\nHealth: %i"treeData[g][tHealth]);
                
treeData[g][tLabel] = Create3DTextLabel(string2COLOR_YELLOWtreeData[g][tX], treeData[g][tY], treeData[g][tZ] + 0.2 3.11177.500);
                
treeData[g][tStatus] = true;
        }
    }
    new 
str[40];
    
format(strsizeof(str), "{ffff00}Tree\n/cuttree\nHealth: %i"treeData[1][tHealth]);
    
treeData[1][tLabel] = Create3DTextLabel(strCOLOR_YELLOWtreeData[1][tX], treeData[1][tY], treeData[1][tZ] + 0.2 3.11177.500);
    return 
1;

( I created a custom 3d text label for the first index but i'm not satisfied by this solution :v)

-Thanks


Re: a 3d label is not created. - Florin48 - 24.01.2019

try to put in
Quote:

for(new g = 1; g < MAX_TREES; g++)

g = 0;


Re: a 3d label is not created. - Kincaid - 24.01.2019

Tree id 0 is not available. I started counting trees from 1.

( i used to start counting from 0 but the same bug occured )


Re: a 3d label is not created. - Florin48 - 24.01.2019

show function where you save trees


Re: a 3d label is not created. - Kincaid - 24.01.2019

Do you mean the cmd which creates a tree?

Trees go through 3 processes only:
1. creation ( using cmd /createtree )
2. loading trees on server start
3. destroying trees on server shutdown

PHP код:
COMMAND:createtree(playeridparams[])
{
    if(
pInfo[playerid][Level] >= 4)
    {
        new 
FloatxFloatyFloatz;
        
GetPlayerPos(playeridxyz);
        new 
treeid freeTreeID();
        
        new 
string[260];
        
format(stringsizeof(string), "/Trees/%d.dini.save"treeid);
        if(!
dini_Exists(string))
        {
            
treeData[treeid][tX] = x;
            
treeData[treeid][tY] = y;
            
treeData[treeid][tZ] = 3.1117// remove this value to fix object bug
            
treeData[treeid][tObject] = CreateObject(617treeData[treeid][tX], treeData[treeid][tY], treeData[treeid][tZ], 0.00000.00000.0000); // tree
            
treeData[treeid][woodReady] = false;
            
treeData[treeid][tHealth] = 100;
                new 
string2[80];
            
format(string2sizeof(string2), "{ffff00}Tree\n/cuttree\nHealth: %i"treeData[treeid][tHealth]);
                
treeData[treeid][tLabel] = Create3DTextLabel(string2COLOR_YELLOWtreeData[treeid][tX], treeData[treeid][tY], treeData[treeid][tZ] + (0.2 3.1117)  , 7.500);
                
treeData[treeid][tStatus] = true;
            
dini_Create(string);
            
dini_FloatSet(string"tX"x);
            
dini_FloatSet(string"tY"y);
            
dini_FloatSet(string"tZ"3.1117);
            
SSM(playerid"You have successfully created a tree.");
        }
    }
    else return 
0;
    return 
1;

-freetreeID function:
PHP код:
stock freeTreeID()
{
        new 
Trees[64];
     for(new 
1MAX_TREESg++)
    {
        
format(Treessizeof(Trees), "/Trees/%d.dini.save"g);
        if(!
dini_Exists(Trees)) return g;
    }
    return 
1;




Re: a 3d label is not created. - codExpert - 24.01.2019

PHP код:
#include <Dini2>
//will keep your ids in correct order, finds first empty id slot and so are file ids also correct
#include <YSI_Data\y_iterate>
#define max_trees 100
new Iterator:fTrees<max_trees>;
treeFile(i){
    new 
s[50];
    
format(s,50,"Trees/%d.ini",i);
    return 
s;
}
treeExsists(i){
    return 
dini_Exists(treeFile(i));
}
loadTrees(){
    for(new 
imax_treesi++){
        if(!
treeExsists(i))continue;
        
Iter_Add(fTrees,i);
        
//loading data
    
}
    return 
1;
}
//other systems
CMD:createtree(playeridparams[]) 

    if(
pInfo[playerid][Level] < 4)return 1
    new 
i=Iter_Free(fTrees);
    if(
i==INVALID_ITERATOR_SLOT)return 1;
    
Iter_Add(fTrees,i);
    new 
s[50];
    
strmid(s,treeFile(i),0,50,50);
    
dini_Create(s);
    
dini_FloatSet(s"tX"0.0); 
    
dini_FloatSet(s"tY"0.0); 
    
dini_FloatSet(s"tZ"0.0); 
    
dini_Timeout(s);
    return 
1




Re: a 3d label is not created. - Kincaid - 24.01.2019

I'm not experienced at using iterators. afterall, thanks for your help i will check the code and check iterators tutorial.


Re: a 3d label is not created. - Kincaid - 24.01.2019

I understood the code and added it but i get this error.

error 017: undefined symbol "INVALID_ITERATOR_SLOT"

I can not find the latest version of y_iterate


Re: a 3d label is not created. - codExpert - 24.01.2019

https://github.com/pawn-lang/YSI-Includes
if you are using sampctl just write : sampctl p install pawn-lang/YSI-Includes


Re: a 3d label is not created. - Jeffry - 25.01.2019

The reason for this is usually very simple.
You somewhere delete 3DLabels with a variable that has no value, means has the value 0.
This will delete the 3D-Label with the ID 0, the first 3D Label.

You have to review your code, to check where you are deleting Labels and initialize all your Label-Variables (same goes for Pickups btw.) that delete Labels with -1 at top of OnGameModeInit.


Re: a 3d label is not created. - Kincaid - 01.02.2019

I could't find such an error.
If you are free, I can send you the code to check it.
(I'm sorry for my late response )