PDA

View Full Version : 3D Label Creation problem. (+REP)


Lirbo
31/07/2015, 05:38 PM
It's saving only the first TP, how can i fix this? after restarting only the first tp that has created would be saved
what should i do?


#define MAX_TELEPORTS 500



#define function%0(%1) forward%0(%1); public%0(%1)
#define LoadTeleports INI_ParseFile(tpFile(), "LoadTP", .bExtra = true, .extra = i);



OnGameModeInit

for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}



function LoadTP(playerid, name[], value[])
{
for(new i = 0; i < MAX_TELEPORTS; i++){
INI_String("Description",tpDB[i][Description],64);
INI_Float("X",tpDB[i][X]);
INI_Float("Y",tpDB[i][Y]);
INI_Float("Z",tpDB[i][Z]);
INI_Float("ToX",tpDB[i][ToX]);
INI_Float("ToY",tpDB[i][ToY]);
INI_Float("ToZ",tpDB[i][ToZ]);
INI_Int("VW",tpDB[i][VW]);
INI_Int("ToVW",tpDB[i][ToVW]);}
return 1;
}

stock SaveTPFile()
{
new INI:tpfile = INI_Open(tpFile());
INI_SetTag(tpfile, "Database");
INI_WriteString(tpfile,"Description",tpDB[param[0]][Description]);
INI_WriteFloat(tpfile,"X",tpDB[param[0]][X]);
INI_WriteFloat(tpfile,"Y",tpDB[param[0]][Y]);
INI_WriteFloat(tpfile,"Z",tpDB[param[0]][Z]);
INI_WriteFloat(tpfile,"ToX",tpDB[param[0]][ToX]);
INI_WriteFloat(tpfile,"ToY",tpDB[param[0]][ToY]);
INI_WriteFloat(tpfile,"ToZ",tpDB[param[0]][ToZ]);
INI_WriteInt(tpfile,"VW",tpDB[param[0]][VW]);
INI_WriteInt(tpfile,"ToVW",tpDB[param[0]][ToVW]);
INI_Close(tpfile);
}

stock tpFile()
{
format(String,sizeof(String),"Teleports/Teleport (%i).ini",param[0]);
return String;
}

Jefff
31/07/2015, 06:28 PM
Should be
function LoadTP(index, name[], value[])
{
INI_String("Description",tpDB[index][Description],64);
INI_Float("X",tpDB[index][X]);
INI_Float("Y",tpDB[index][Y]);
INI_Float("Z",tpDB[index][Z]);
INI_Float("ToX",tpDB[index][ToX]);
INI_Float("ToY",tpDB[index][ToY]);
INI_Float("ToZ",tpDB[i][ToZ]);
INI_Int("VW",tpDB[index][VW]);
INI_Int("ToVW",tpDB[index][ToVW]);
return 1;
}

Lirbo
31/07/2015, 06:37 PM
Should be
function LoadTP(index, name[], value[])
{
INI_String("Description",tpDB[index][Description],64);
INI_Float("X",tpDB[index][X]);
INI_Float("Y",tpDB[index][Y]);
INI_Float("Z",tpDB[index][Z]);
INI_Float("ToX",tpDB[index][ToX]);
INI_Float("ToY",tpDB[index][ToY]);
INI_Float("ToZ",tpDB[i][ToZ]);
INI_Int("VW",tpDB[index][VW]);
INI_Int("ToVW",tpDB[index][ToVW]);
return 1;
}

omg dude -,- it doesn't matter it's just tabsize, fuck it it won't solve my problem....

Macronix
31/07/2015, 06:52 PM
I guess it shows only the second one, because you are overwriting the variable "TPText" with the second "Create3DTextLabel" everytime. Try to split the variable into two, meaning "TPText1" and "TPText2" :)

Lirbo
01/08/2015, 11:23 AM
I guess it shows only the second one, because you are overwriting the variable "TPText" with the second "Create3DTextLabel" everytime. Try to split the variable into two, meaning "TPText1" and "TPText2" :)

but if i'd do it i'd have to make tons of it, that's why I made it TPText[number] so i won't have to create tons of 3dtextlabel

Macronix
01/08/2015, 01:08 PM
No, you don't have to create "TPText1", "TPText2", "TPText3" and so on... because the loop does that for you. You just have to create the first two, meaning:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText1[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText2[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


If that doesn't work, try this:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText[i+1] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}

Lirbo
01/08/2015, 03:22 PM
I guess it shows only the second one, because you are overwriting the variable "TPText" with the second "Create3DTextLabel" everytime. Try to split the variable into two, meaning "TPText1" and "TPText2" :)

No, you don't have to create "TPText1", "TPText2", "TPText3" and so on... because the loop does that for you. You just have to create the first two, meaning:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText1[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText2[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


If that doesn't work, try this:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText[i+1] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


it isn't working, i noticed that the first 3dtext isnt working EVEN if i remove the second 3dtext, what should i do?
EDIT: oh sec it's saving all the positions on X, lemme try to fix

Lirbo
01/08/2015, 07:44 PM
No, you don't have to create "TPText1", "TPText2", "TPText3" and so on... because the loop does that for you. You just have to create the first two, meaning:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText1[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText2[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


If that doesn't work, try this:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText[i+1] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


Ty man. but I just noticed that after i i'm GMXing it's saving only the first Teleport, do u know how can i fix this shit?

xVIP3Rx
01/08/2015, 07:50 PM
INI_WriteFloat(tpfile,"X",tpDB[param[0]][X]);
INI_WriteFloat(tpfile,"X",tpDB[param[0]][Y]);
INI_WriteFloat(tpfile,"X",tpDB[param[0]][Z]);
You're saving them all as "X", why..

Also, what is "param[0]" and why are you using it as the teleport id/sort.

Lirbo
01/08/2015, 08:23 PM
No, you don't have to create "TPText1", "TPText2", "TPText3" and so on... because the loop does that for you. You just have to create the first two, meaning:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText1[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText2[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


If that doesn't work, try this:


for(new i = 0; i < MAX_TELEPORTS; i++){
LoadTeleports
format(String,sizeof(String),"- Teleport -\n%s",tpDB[i][Description]);
TPText[i] = Create3DTextLabel(String, C_WHITE, tpDB[i][X],tpDB[i][Y],tpDB[i][Z], 25.0, tpDB[i][VW], 0);
TPText[i+1] = Create3DTextLabel(String, C_WHITE, tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ], 25.0, tpDB[i][ToVW], 0);
}


You're saving them all as "X", why..

Also, what is "param[0]" and why are you using it as the teleport id/sort.

ye i already fixed it, I forgot to change it here too. what should i do?

xVIP3Rx
01/08/2015, 08:58 PM
I don't think you're making it right, if you want to save an array in a single file you should add an id to it, or use a different database for it.

Lirbo
02/08/2015, 01:40 PM
I don't think you're making it right, if you want to save an array in a single file you should add an id to it, or use a different database for it.

can u gimme an example please?

xVIP3Rx
02/08/2015, 03:17 PM
#define MAX_TELEPORTS 10

new teleport1[MAX_TELEPORTS];
new teleport2[MAX_TELEPORTS];
new teleport3[MAX_TELEPORTS];

//This is the same size as
new teleport[3][MAX_TELEPORTS];//This is called an array


You're saving the same teleport over and over again, you need to set an id or a value to differ them from each other, and load them.

Lirbo
02/08/2015, 06:27 PM
#define MAX_TELEPORTS 10

new teleport1[MAX_TELEPORTS];
new teleport2[MAX_TELEPORTS];
new teleport3[MAX_TELEPORTS];

//This is the same size as
new teleport[3][MAX_TELEPORTS];//This is called an array


You're saving the same teleport over and over again, you need to set an id or a value to differ them from each other, and load them.

yeah but my problem isn't that the 3d label isn't appearing, the portal isn't working, only the last one that has created is working. the others aren't appearing and aren't working (teleporting)

xVIP3Rx
02/08/2015, 06:28 PM
yeah but my problem isn't that the 3d label isn't appearing, the portal isn't working, only the last one that has created is working. the others aren't appearing and aren't working (teleporting)

Yes because, the last one is always over-writing the one before it, look for some tutorial about saving arrays.

Lirbo
02/08/2015, 08:09 PM
#define MAX_TELEPORTS 10

new teleport1[MAX_TELEPORTS];
new teleport2[MAX_TELEPORTS];
new teleport3[MAX_TELEPORTS];

//This is the same size as
new teleport[3][MAX_TELEPORTS];//This is called an array


You're saving the same teleport over and over again, you need to set an id or a value to differ them from each other, and load them.

Yes because, the last one is always over-writing the one before it, look for some tutorial about saving arrays.

umm actually it's not over-writing, for example in my teleports folder i have "Teleport (0).ini" and "Teleport (1).ini" with different coords
but the problem is that 3dlabel creation + teleport doesn't working

Lirbo
03/08/2015, 02:06 PM
bump

Lirbo
06/08/2015, 03:26 PM
bump