Vehicle Params
#2

Hi,

add this at OnPlayerCommandText: (Change the command if you wish)
pawn Code:
if(!strcmd(cmdtext, "/veh", true))
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You need to be in a vehicle to use this command.");
    new veh = GetPlayerVehicleID(playerid);
    new stats[7], str[1024];
    GetVehicleParamsEx(veh, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6]);
    for(new i=0; i<7; i++)
    {
        switch(i)
        {
            case 0:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sEngine: Turn Off", str); //It is currently on
                else format(str, sizeof(str), "%sEngine: Turn On", str); //It is currently off
            }
            case 1:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sLights: Turn Off", str);
                else format(str, sizeof(str), "%sLights: Turn On", str);
            }
            case 2:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sAlarm: Turn Off", str);
                else format(str, sizeof(str), "%sAlarm: Turn On", str);
            }
            case 3:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sDoors: Close", str);
                else format(str, sizeof(str), "%sDoors: Open", str)
            }
            case 4:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sBonnet: Close", str);
                else format(str, sizeof(str), "%sBonnet: Open", str);
            }
            case 5:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sBoot: Close", str);
                else format(str, sizeof(str), "%sBoot: Open", str);
            }
            case 6:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sObjective: Turn Off", str);
                else format(str, sizeof(str), "%sObjective: Turn On", str);
            }
        }
    }
    ShowPlayerDialog(playerid, 15151, DIALOG_STYLE_LIST, "Vehicle Properties", str, "Ok!", "Close");
    return 1;
}
and this goes under OnDialogResponse:
pawn Code:
if(dialogid == 15151)
{
    if(!response) return 1;
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You need to be in a vehicle.");
    new stats[7], str[1024];
    GetVehicleParamsEx(veh, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6]);
    if(stats[listitem] == 1) stats[listitem] = 0;
    else stats[listitem] = 1;
    SetVehicleParamsEx(veh, stats[0], stats[1], stats[2], stats[3], stats[4], stats[5], stats[6]);
    for(new i=0; i<7; i++)
    {
        switch(i)
        {
            case 0:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sEngine: Turn Off", str); //It is currently on
                else format(str, sizeof(str), "%sEngine: Turn On", str); //It is currently off
            }
            case 1:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sLights: Turn Off", str);
                else format(str, sizeof(str), "%sLights: Turn On", str);
            }
            case 2:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sAlarm: Turn Off", str);
                else format(str, sizeof(str), "%sAlarm: Turn On", str);
            }
            case 3:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sDoors: Close", str);
                else format(str, sizeof(str), "%sDoors: Open", str)
            }
            case 4:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sBonnet: Close", str);
                else format(str, sizeof(str), "%sBonnet: Open", str);
            }
            case 5:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sBoot: Close", str);
                else format(str, sizeof(str), "%sBoot: Open", str);
            }
            case 6:
            {
                if(stats[i] == 1) format(str, sizeof(str), "%sObjective: Turn Off", str);
                else format(str, sizeof(str), "%sObjective: Turn On", str);
            }
        }
    }
    ShowPlayerDialog(playerid, 15151, DIALOG_STYLE_LIST, "Vehicle Properties", str, "Ok!", "Close");
    return 1;
}
I think all params just switch between 1 and 0, not sure... if it is different, change it or let me know. Never worked with this function yet.

I hope it works so far, if not, tell me where it is wrong and I can fix it.

PS: You need to add the embedded colors yourself. ^^


Cheers.
Reply


Messages In This Thread
Vehicle Params - by Konstantinos - 09.01.2012, 17:35
Re: Vehicle Params - by Jeffry - 01.02.2012, 17:41
Re: Vehicle Params - by Konstantinos - 02.02.2012, 13:10
Re: Vehicle Params - by milanosie - 02.02.2012, 13:11
Re: Vehicle Params - by Konstantinos - 02.02.2012, 13:13
Re: Vehicle Params - by milanosie - 02.02.2012, 13:30
Re: Vehicle Params - by Konstantinos - 02.02.2012, 13:41

Forum Jump:


Users browsing this thread: 5 Guest(s)