Dialog isn't working, help would be very usefull. :)
#1

Hello scripters!

I have a problem with my car control script.
I think you will understand what this script does by looking at it.
If not, it basically just turns engine on/off, or lights on/off and so on.

Here is the script that calls the Dialog:
Код:
dcmd_car(playerid,params[])
{
	ShowPlayerDialog(playerid,DIALOG_CAR,DIALOG_STYLE_LIST, "Car control", "Engine\r\nLights\r\nAlarm\r\nBonnet\r\nBoot", "Ok", "Close");
	return 1;
}
And here is the script at 'OnDialogResponse':
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOG_CAR)
	{
	if(!response)
	{
	return 1;
	}
	new Vehicle[MAX_PLAYERS], Engine[MAX_PLAYERS], Lights[MAX_PLAYERS], Alarm[MAX_PLAYERS], Doors[MAX_PLAYERS], Bonnet[MAX_PLAYERS], Boot[MAX_PLAYERS], Objective[MAX_PLAYERS];
	Vehicle[playerid] = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(listitem == 0)
	{
	if(Engine[playerid] == 1) return SetVehicleParamsEx(Vehicle[playerid], 0, Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Engine[playerid] == 0) return SetVehicleParamsEx(Vehicle[playerid], 1, Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 1)
	{
	if(Lights[playerid] == 1) return Lights[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Lights[playerid] == 0) return Lights[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 2)
	{
	if(Alarm[playerid] == 1) return Alarm[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Alarm[playerid] == 0) return Alarm[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 3)
	{
	if(Bonnet[playerid] == 1) return Bonnet[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Bonnet[playerid] == 0) return Bonnet[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 4)
	{
	if(Boot[playerid] == 1) return Boot[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Boot[playerid] == 0) return Boot[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	}
	return 0;
}
Problem is that when i type '/car', the dialog pops up, and when i try turning my engine for example off, it just closes the dialog....
Reply
#2

return 1 in each dialogid but return 0 at the end of OnDialogResponse
Reply
#3

hmm...
I changed it like this:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOG_CAR)
	{
	if(!response)
	{
	return 1;
	}
	new Vehicle[MAX_PLAYERS], Engine[MAX_PLAYERS], Lights[MAX_PLAYERS], Alarm[MAX_PLAYERS], Doors[MAX_PLAYERS], Bonnet[MAX_PLAYERS], Boot[MAX_PLAYERS], Objective[MAX_PLAYERS];
	Vehicle[playerid] = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(listitem == 0)
	{
	if(Engine[playerid] == 1) return SetVehicleParamsEx(Vehicle[playerid], 0, Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Engine[playerid] == 0) return SetVehicleParamsEx(Vehicle[playerid], 1, Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 1)
	{
	if(Lights[playerid] == 1) return Lights[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Lights[playerid] == 0) return Lights[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
 	}
	if(listitem == 2)
	{
	if(Alarm[playerid] == 1) return Alarm[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Alarm[playerid] == 0) return Alarm[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 3)
	{
	if(Bonnet[playerid] == 1) return Bonnet[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Bonnet[playerid] == 0) return Bonnet[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	if(listitem == 4)
	{
	if(Boot[playerid] == 1) return Boot[playerid] = 0, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	if(Boot[playerid] == 0) return Boot[playerid] = 1, SetVehicleParamsEx(Vehicle[playerid], Engine[playerid], Lights[playerid], Alarm[playerid], Doors[playerid], Bonnet[playerid], Boot[playerid], Objective[playerid]);
	}
	return 1;
	}
	return 0;
}
Still doesn't work, anone any other ideas?
Reply
#4

Any FS? Do the same thing.
Reply
#5

nope, all my FilterScripts have return 0; at 'OnDialogResponse'.
Any other ideas.
Reply
#6

Make sure the dialog ID didn't messed with another dialog.
Debug your code and see if your OnDialogReponse called and your dialogid works.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    print("1");
    if(dialogid == DIALOG_CAR)
    {
        print("2");
        if(!response) return 1;
        new Vehicle,Engine,Lights,Alarm,Doors,Bonnet,Boot,Objective;
        Vehicle= GetPlayerVehicleID(playerid);
        if(listitem == 0)
        {
            if(Engine== 1) return SetVehicleParamsEx(Vehicle, 0, Lights, Alarm, Doors, Bonnet, Boot, Objective);
            if(Engine== 0) return SetVehicleParamsEx(Vehicle, 1, Lights, Alarm, Doors, Bonnet, Boot, Objective);
        }
        if(listitem == 1)
        {
            if(Lights== 1) return Lights = 0, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
            if(Lights== 0) return Lights = 1, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
        }
        if(listitem == 2)
        {
            if(Alarm== 1) return Alarm= 0, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
            if(Alarm== 0) return Alarm= 1, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
        }
        if(listitem == 3)
        {
            if(Bonnet== 1) return Bonnet= 0, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
            if(Bonnet== 0) return Bonnet= 1, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
        }
        if(listitem == 4)
        {
            if(Boot== 1) return Boot= 0, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
            if(Boot== 0) return Boot= 1, SetVehicleParamsEx(Vehicle, Engine, Lights, Alarm, Doors, Bonnet, Boot, Objective);
        }
        return 1;
    }
    return 0;
}
I suggest you yo use switch statement.
Reply
#7

Whats the difference between switch and listitem?
This is what i got in my console:
Код:
[00:39:25] 1
[00:39:25] 1
[00:39:26] 1
[00:39:26] 1
[00:39:26] 1
[00:39:29] 1
[00:39:29] 2
Reply
#8

Do you use any FS,which use Dialogs,if yes,i had the same problem :P and i think i know how to fix..
il give a try.
Reply
#9

Yep, i have other FS witch use dialogs.
Can you try fixing it please?
Reply
#10

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Yep, i have other FS witch use dialogs.
Can you try fixing it please?
MSN? so we can talk easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)