Multiple Dialog Problem -
tommzy09 - 12.06.2014
i'm trying to get multiple dialogs to work but only the first dialog works perfect,
as for the second dialog, it shows the dialog options but once you select an option, it does nothing.
My first dialog is a weapon shop which works perfect, but the second dialog is a vehicle repair shop which doesn't work at all.
All my dialogs are done as checkpoints.
here's snippets of my code
Under Includes
Код:
#define SHOP_DIALOG 0
#define PETROL_DIALOG 1
Under OnPplayerEnterDynamicCP
Код:
if(checkpointid == Checkpoint[3]) // Petrol Dialog Idlewood
{
ShowPlayerDialog(playerid, PETROL_DIALOG, DIALOG_STYLE_LIST, "Repair Menu", "Repair Vehicle\nAdd Nitrous", "Select", "Exit");//Show them the dialog.
}
now the main script itself
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == SHOP_DIALOG)//If the dialog responded to is our Weapon Shop dialog.
{
if(!response) return SendClientMessage(playerid, -1, "You have left the Weapon Shop.");//If they click "Exit" they have left the dialog(Shop).
switch(listitem)
{
case 0://Baseball Bat
{
if(GetPlayerMoney(playerid) >= 100)//If they have more or equal to the price.
{
GivePlayerMoney(playerid, -100);//Take the cost.
GivePlayerWeapon(playerid, 5, 1);//Give them the weapon/ammo.
SendClientMessage(playerid, -1, "Baseball Bat purchased.");//And let them know they just purchased a weapon.
return 1;//Tell pawno to stop processing now.
}
else//Else the dont have enough money to cover the purchase.
{
SendClientMessage(playerid, -1, "You dont have enough money to purchase this weapon.");//Tell them.
return 1;//Tell pawno to stop processing now.
}
}
case 1://Sawn-Off
{
if(GetPlayerMoney(playerid) >= 2000)//If they have more or equal to the price.
{
GivePlayerMoney(playerid, -2000);//Take the cost.
GivePlayerWeapon(playerid, 26, 20);//Give them the weapon/ammo.
SendClientMessage(playerid, -1, "Sawn-Off Shotgun purchased.");//And let them know they just purchased a weapon.
return 1;//Tell pawno to stop processing now.
}
else//Else the dont have enough money to cover the purchase.
{
SendClientMessage(playerid, -1, "You dont have enough money to purchase this weapon.");//Tell them.
return 1;//Tell pawno to stop processing now.
}
}
case 2://Combat Shotgun
{
if(GetPlayerMoney(playerid) >= 1000)//If they have more or equal to the price.
{
GivePlayerMoney(playerid, -1000);//Take the cost.
GivePlayerWeapon(playerid, 27, 20);//Give them the weapon/ammo.
SendClientMessage(playerid, -1, "Combat Shotgun purchased.");//And let them know they just purchased a weapon.
return 1;//Tell pawno to stop processing now.
}
else//Else the dont have enough money to cover the purchase.
{
SendClientMessage(playerid, -1, "You dont have enough money to purchase this weapon.");//Tell them.
return 1;//Tell pawno to stop processing now.
}
}
case 3://M4
{
if(GetPlayerMoney(playerid) >= 2000)//If they have more or equal to the price.
{
GivePlayerMoney(playerid, -2000);//Take the cost.
GivePlayerWeapon(playerid, 31, 100);//Give them the weapon/ammo.
SendClientMessage(playerid, -1, "M4 purchased.");//And let them know they just purchased a weapon.
return 1;//Tell pawno to stop processing now.
}
else//Else the dont have enough money to cover the purchase.
{
SendClientMessage(playerid, -1, "You dont have enough money to purchase this weapon.");//Tell them.
return 1;//Tell pawno to stop processing now.
}
}
}
if(dialogid == PETROL_DIALOG)//If the dialog responded to is our Weapon Shop dialog.
{
if(!response) return SendClientMessage(playerid, -1, "You have exited the Repair Menu.");//If they click "Exit" they have left the dialog(Shop).
switch(listitem)
{
case 0://Vehicle Repair
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been repaired!");//And let them know they just purchased a weapon.
return 1;//Tell pawno to stop processing now.
}
else
{
SendClientMessage(playerid,0xff0000ff,"You must be in a Vehicle!");
return 1;
}
}
case 1://Nitro
{
{
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
AddVehicleComponent(GetPlayerVehicleID(playerid),1010);
SendClientMessage(playerid, 0xFFFFFFFF, "Nitrous Added!");
return 1;//Tell pawno to stop processing now.
}
else
{
SendClientMessage(playerid,0xff0000ff,"You must be in a Vehicle!");
return 1;
}
}
}
}
}
}
return 0;
}
whats gone wrong? i get no compile errors but it just doesnt repair or add nos to the vehicle.
Re: Multiple Dialog Problem -
Beckett - 12.06.2014
Why are you checking his state if he's ON_FOOT shouldn't you check if he was in a vehicle? or VEHICLE_STATE_DRIVER?
Re: Multiple Dialog Problem -
tommzy09 - 12.06.2014
my bad, ive changed it to PLAYER_STATE_DRIVER but it doesnt work, as of IsPlayerInAnyVehicle(), where should i put that?
Re: Multiple Dialog Problem -
Joe Staff - 12.06.2014
Count your brackets, you'll probably see that you're off by one in your first dialog.
Re: Multiple Dialog Problem -
tommzy09 - 12.06.2014
i've tried everything you guys have mentioned, besides IsPlayerInAnyVehicle() cause I wouldnt have a clue where to add that.
I have updated my post with all the changes you guys suggested.