08.01.2012, 16:29
Your script was rather buggy and I don't actually think it's going to achieve what you've set it out to achieve.
This is your script - as you wrote it, but without the bugs:
^untested
But I wouldn't write a switch for the "cancel" button... That's insinuating you want to teleport the player regardless of his selection?
I would use this:
This is your script - as you wrote it, but without the bugs:
pawn Code:
CMD:teleports(playerid, params[])
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "tarta", "Lvas\nBuilding\nStunts\nTest\n", "Ok", "No");
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(response) //User pressed OK
{
switch(listitem)
{
case 0:
{
//Selected Item: "Lvas"
}
case 1:
{
//Selected Item: "Building"
}
case 2:
{
//Selected Item: "Stunts"
}
case 3:
{
//Selected Item: "Test"
}
case 4:
{
//Selected Item: ""
}
}
}
else if(!response) //User pressed No
{
switch(listitem)
{
case 0:
{
//Selected Item: "Lvas"
}
case 1:
{
//Selected Item: "Building"
}
case 2:
{
//Selected Item: "Stunts"
}
case 3:
{
//Selected Item: "Test"
}
case 4:
{
//Selected Item: ""
}
}
}
}
return 0;
}
But I wouldn't write a switch for the "cancel" button... That's insinuating you want to teleport the player regardless of his selection?
I would use this:
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(response) //User pressed OK
{
switch(listitem)
{
case 0:
{
//Selected Item: "Lvas"
}
case 1:
{
//Selected Item: "Building"
}
case 2:
{
//Selected Item: "Stunts"
}
case 3:
{
//Selected Item: "Test"
}
case 4:
{
//Selected Item: ""
}
}
}
}
return 1;
}