SA-MP Forums Archive
Dialog isn't working, help would be very usefull. :) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dialog isn't working, help would be very usefull. :) (/showthread.php?tid=284548)



Dialog isn't working, help would be very usefull. :) - Shetch - 19.09.2011

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....


Re: Dialog isn't working, help would be very usefull. :) - =WoR=Varth - 19.09.2011

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


Re: Dialog isn't working, help would be very usefull. :) - Shetch - 19.09.2011

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?


Re: Dialog isn't working, help would be very usefull. :) - =WoR=Varth - 19.09.2011

Any FS? Do the same thing.


Re: Dialog isn't working, help would be very usefull. :) - Shetch - 19.09.2011

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


Re: Dialog isn't working, help would be very usefull. :) - =WoR=Varth - 19.09.2011

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.


Re: Dialog isn't working, help would be very usefull. :) - Shetch - 19.09.2011

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



Re: Dialog isn't working, help would be very usefull. :) - Issam - 19.09.2011

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.


Re: Dialog isn't working, help would be very usefull. :) - Shetch - 19.09.2011

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


Re: Dialog isn't working, help would be very usefull. :) - Issam - 19.09.2011

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.