Dialog enable/disable function
#1

Hi, I'm making a new filterscript for my server (vehicle system for the engine,lights and etc.) and I want to control the vehicle engine and other vehicle features from menu dialog.Now it's :
pawn Код:
#define Dialog_VehSystem 12
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/vehsys", true)
    {
    new State=GetPlayerState(playerid);
    if (IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
    {
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine \nEngine off \nLights \nLights off ","Ok","Cancel");
    }else SendClientMessage(playerid,0xFFFFFFAA, "Sorry, You must be in vehicle!");
    return 1;
    }
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==Dialog_VehSystem)
{
        new carid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        if(response)
        {
            //Engine on
            if(listitem == 0)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(carid,1,lights,alarm,doors,bonnet,boot,objective);
            }
            //Engine off
            if(listitem == 1)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(carid,0,lights,alarm,doors,bonnet,boot,objective);
            }
            //Lights on
            if(listitem == 2)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(carid,engine,1,alarm,doors,bonnet,boot,objective);
            }
            //Lights off
            if(listitem == 3)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(carid,engine,0,alarm,doors,bonnet,boot,objective);
            }
        }
        return 1;
    }
return 0;
}
But I want enabling and disabling to be on the same "listitem" for example when I open the dialog and click on engine to see on the button "Engine Enabled" and it really to be enabled and when I click again to disable it to see "Engine Disabled". Can somebody help me ?
Reply
#2

pawn Код:
#define Dialog_VehSystem 12
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/vehsys", true)
    {
    new State=GetPlayerState(playerid);
    if (IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
    {
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine && lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine off \nLights off","Ok","Cancel");
    else if(engine && !lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine off \nLights on","Ok","Cancel");
    else if(!engine && lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine on \nLights off","Ok","Cancel");
    else ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine on \nLights on","Ok","Cancel");
    }else SendClientMessage(playerid,0xFFFFFFAA, "Sorry, You must be in vehicle!");
    return 1;
    }
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==Dialog_VehSystem)
{
        new carid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        if(response)
        {
            if(listitem == 0)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                if(engine == 0)
                SetVehicleParamsEx(carid,1,lights,alarm,doors,bonnet,boot,objective);
                else SetVehicleParamsEx(carid,0,lights,alarm,doors,bonnet,boot,objective);
            }
            //Engine off
            if(listitem == 1)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                if(lights==0)
                SetVehicleParamsEx(carid,engine,1,alarm,doors,bonnet,boot,objective);
                else SetVehicleParamsEx(carid,engine,1,alarm,doors,bonnet,boot,objective);
            }

        }
        return 1;
    }
here you go
Reply
#3

nice work does it work yet hope that you release it the the samp community as a full script with many options
Reply
#4

Quote:
Originally Posted by Ultra-Gaming
Посмотреть сообщение
nice work does it work yet hope that you release it the the samp community as a full script with many options
Not bad idea I can do that!
Reply
#5

Quote:
Originally Posted by Roko_foko
Посмотреть сообщение
pawn Код:
#define Dialog_VehSystem 12
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp(cmdtext, "/vehsys", true)
    {
    new State=GetPlayerState(playerid);
    if (IsPlayerInAnyVehicle(playerid) && State == PLAYER_STATE_DRIVER)
    {
    new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine && lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine off \nLights off","Ok","Cancel");
    else if(engine && !lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine off \nLights on","Ok","Cancel");
    else if(!engine && lights )
    ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine on \nLights off","Ok","Cancel");
    else ShowPlayerDialog(playerid,Dialog_VehSystem,2,"{FFFFFF}Vehicle System:","Engine on \nLights on","Ok","Cancel");
    }else SendClientMessage(playerid,0xFFFFFFAA, "Sorry, You must be in vehicle!");
    return 1;
    }
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==Dialog_VehSystem)
{
        new carid = GetPlayerVehicleID(playerid);
        new engine,lights,alarm,doors,bonnet,boot,objective;
        if(response)
        {
            if(listitem == 0)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                if(engine == 0)
                SetVehicleParamsEx(carid,1,lights,alarm,doors,bonnet,boot,objective);
                else SetVehicleParamsEx(carid,0,lights,alarm,doors,bonnet,boot,objective);
            }
            //Engine off
            if(listitem == 1)
            {
                GetVehicleParamsEx(carid,engine,lights,alarm,doors,bonnet,boot,objective);
                if(lights==0)
                SetVehicleParamsEx(carid,engine,1,alarm,doors,bonnet,boot,objective);
                else SetVehicleParamsEx(carid,engine,1,alarm,doors,bonnet,boot,objective);
            }

        }
        return 1;
    }
here you go
Hmm, I tried it but when the engine is turned on it shows that it's off ?!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)