24.08.2017, 11:49
Hi guys, I wanna create a dialog and let the player input the color id (color1 and color2 of the vehicle) and I have two ways (one is define just 1 dialog and use PVar, two is define two dialog and not use PVar) to do this but I just don't know which way should I follow:
1:
2.
Thanks in advanced!
1:
PHP код:
#define DIALOG_MENUCOLOR 1
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
else if(playertextid == dealership_ColorMenu[3]) // color1
{
SetPVarInt(playerid, "ChoseColorID", 1);
ShowPlayerDialog(playerid, DIALOG_COLORMENU, DIALOG_STYLE_INPUT, " ", "Input the color1 id", "Confirm", "Cancel");
}
else if(playertextid == dealership_ColorMenu[4]) // color2
{
SetPVarInt(playerid, "ChoseColorID", 2);
ShowPlayerDialog(playerid, DIALOG_COLORMENU, DIALOG_STYLE_INPUT, " ", "Input the color1 id", "Confirm", "Cancel");
}
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_COLORMENU:
{
if(GetPVarInt(playerid, "ChoseColorID") == 1) // update the color 1 box textdraw if chose colorid is 1
{
PlayerTextDrawColor(playerid, dealership_ColorMenu[3], vehicleColoursTableRGBA[strval(inputtext)]);
PlayerTextDrawShow(playerid, dealership_ColorMenu[3]);
}
else if(GetPVarInt(playerid, "ChoseColorID") == 2) // update the color 2 box textdraw if chose colorid is 2
{
PlayerTextDrawColor(playerid, dealership_ColorMenu[4], vehicleColoursTableRGBA[strval(inputtext)]);
PlayerTextDrawShow(playerid, dealership_ColorMenu[4]);
}
}
}
}
PHP код:
#define DIALOG_COLORMENU1 1
#define DIALOG_COLORMENU2 2
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if(_:playertextid != INVALID_TEXT_DRAW)
{
else if(playertextid == dealership_ColorMenu[3]) // color1
{
ShowPlayerDialog(playerid, DIALOG_COLORMENU1, DIALOG_STYLE_INPUT, " ", "Input the color1 id", "Confirm", "Cancel");
}
else if(playertextid == dealership_ColorMenu[4]) // color2
{
ShowPlayerDialog(playerid, DIALOG_COLORMENU2, DIALOG_STYLE_INPUT, " ", "Input the color2 id", "Confirm", "Cancel");
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_COLORMENU1:
{
PlayerTextDrawColor(playerid, dealership_ColorMenu[3], vehicleColoursTableRGBA[strval(inputtext)]);
PlayerTextDrawShow(playerid, dealership_ColorMenu[3]);
}
case DIALOG_COLORMENU2:
{
PlayerTextDrawColor(playerid, dealership_ColorMenu[4], vehicleColoursTableRGBA[strval(inputtext)]);
PlayerTextDrawShow(playerid, dealership_ColorMenu[4]);
}
}
}