error with this function
#1

I am creating a furniture system and I am dealing with this problem a few days ago that has me very angry. Apparently there is no error, I checked everything and it would seem to be all right.
When opening the dialog when there is no saved piece of furniture it appears well (all the slots appear in "vacнo") but when you set some id of a piece of furniture in one or all the variables of "HouseInfo [house] [hMueble]" no dialog appears . If they could help me, I would thank them for life.

Код:
forward MueblesGuardados(playerid); //Muestra los muebles guardados al jugador
public MueblesGuardados(playerid)
{
    new dialog[1024], string[128];
    new casa = GetPlayerDentroCasa(playerid);
	for(new i = 0; i < 5; i++)
	{
		new slot = HouseInfo[casa][hMueble][i];
		if(slot == 0){format(string, sizeof(string), "\n{b0b0b0}%s", MuebleInfo[slot][NombreMueble]);}
		else{format(string, sizeof(string), "\n{FFFFFF}%s", MuebleInfo[slot][NombreMueble]);}
		strcat(dialog, string);
		SaveCasa(casa);
	}
	ShowPlayerDialog(playerid, 78, DIALOG_STYLE_LIST, "Muebles guardados", dialog, "Seleccionar", "Cerrar");
	return 1;
}
Reply
#2

Quote:
Originally Posted by Wayzzar
Посмотреть сообщение
I am creating a furniture system and I am dealing with this problem a few days ago that has me very angry. Apparently there is no error, I checked everything and it would seem to be all right.
When opening the dialog when there is no saved piece of furniture it appears well (all the slots appear in "vacнo") but when you set some id of a piece of furniture in one or all the variables of "HouseInfo [house] [hMueble]" no dialog appears . If they could help me, I would thank them for life.

Код:
forward MueblesGuardados(playerid); //Muestra los muebles guardados al jugador
public MueblesGuardados(playerid)
{
    new dialog[1024], string[128];
    new casa = GetPlayerDentroCasa(playerid);
	for(new i = 0; i < 5; i++)
	{
		new slot = HouseInfo[casa][hMueble][i];
		if(slot == 0){format(string, sizeof(string), "\n{b0b0b0}%s", MuebleInfo[slot][NombreMueble]);}
		else{format(string, sizeof(string), "\n{FFFFFF}%s", MuebleInfo[slot][NombreMueble]);}
		strcat(dialog, string);
		SaveCasa(casa);
	}
	ShowPlayerDialog(playerid, 78, DIALOG_STYLE_LIST, "Muebles guardados", dialog, "Seleccionar", "Cerrar");
	return 1;
}
Hi, clearly I can see your problem, I'll pass the code and then I'll explain,

PHP код:
forward MueblesGuardados(playerid); //Muestra los muebles guardados al jugador
public MueblesGuardados(playerid)
{
    new 
dialog[1024], string[128];
    new 
casa GetPlayerDentroCasa(playerid);
    for(new 
05i++)
    {
        new 
slot HouseInfo[casa][hMueble][i];
        if(
slot == 0){format(stringsizeof(string), "\n{b0b0b0}%s"MuebleInfo[i][NombreMueble]);}
        else{
format(stringsizeof(string), "\n{FFFFFF}%s"MuebleInfo[i][NombreMueble]);}
        
strcat(dialogstring);
        
SaveCasa(casa);
    }
    
ShowPlayerDialog(playerid78DIALOG_STYLE_LIST"Muebles guardados"dialog"Seleccionar""Cerrar");
    return 
1;

What happens is that the slot variable "new slot = HouseInfo [house] [hMueble] [i];" you are storing the object/model of the furniture, then later when this code is executed.

PHP код:
        if(slot == 0){format(stringsizeof(string), "\n{b0b0b0}%s"/*MuebleInfo[slot][NombreMueble]*/);}
        else{
format(stringsizeof(string), "\n{FFFFFF}%s"/*MuebleInfo[slot][NombreMueble]*/);} 
The part that I put you / ** / is the one I'm talking about.
You are using slot as a number to define the variable, but that slot you used for the piece of furniture.
Example of what you do:

PHP код:
Suppose you have a piece of furniture in the house with model 19935. Then in "slot" it will store 19935.
And what you do is read "MuebleInfo [19935] [NombreMueble]" and from what I see you only get to "MuebleInfo [4] [NombreMueble]" in your furniture variablethat's why when it shows the dialog do not it does so because in theory that variable does not exist and the code will not be executed.
        if(slot == 0){format(string, sizeof(string), "\n{b0b0b0}%s", /*MuebleInfo[slot][NombreMueble]*/);}
        else{format(string, sizeof(string), "\n{FFFFFF}%s", /*MuebleInfo[slot][NombreMueble]*/);} 
I leave the code in the right way up, if you have any questions I'll gladly help.
Reply
#3

Swankeh thank you very much for the help but the error was not solved.
By placing the variable "MuebleInfo [i] [NombreMueble]" the names of the furniture that I store in that enum appear. What I wanted to do is that by placing the variable "MuebleInfo [slot] [NombreMueble]" I see in the dialog the name of each piece of furniture stored in the house, I do not know if I explain it.
MuebleInfo is an enum that contains the ids and the name of each piece of furniture, so when placing "[slot]" and "[NombreMueble]" I have it tell me the name of the piece of furniture that is stored "HouseInfo [casa] [hMueble]".

I'm still looking for a haha solution. Greetings.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)