Vehicle Params
#1

I was wondering, how this is possible
pawn Code:
new engine, lights, alarm, doors, bonnet, boot, objective, veh = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
If you press on Engine it turn off, and on the dialog appears "Turn On", if you press Turn On , it turns th engine on and on the dialog appears "Turn Off". Is this possible with bool?
Reply
#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
#3

Thank you, Jeffry <3
I will test it soon because my SA-MP - San Andreas has problem and I can't connect on any server/localhost.
But in pawno it compiles without any errors. I hope it works, if not I will inform you!

Regards,
Reply
#4

1 for engine should be true
its always true and false with vehicleparams
Reply
#5

Quote:
Originally Posted by milanosie
View Post
1 for engine should be true
its always true and false with vehicleparams
Nope, it can be 1 and 0.
Reply
#6

Not that I know, atleast not with the door(locks)
Reply
#7

Anyway that isn't a problem, when I will be able to test it, if it doesn't I will change it to true and false.
Thanks for the info.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)