SA-MP Forums Archive
UpdateVehicleDamageStatus Help - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: UpdateVehicleDamageStatus Help (/showthread.php?tid=182270)



UpdateVehicleDamageStatus Help - Angelus~ - 09.10.2010

I want to damage the driver's door
Binary code would be
00000000 00000010 00000000 00000000

Decimal would be: 131072
However when i put that in, the trunk gets damaged

I tried it this way too
00000000 00000000 00000010 00000000
but the same thing happens

what am i doing wrong?


Re: UpdateVehicleDamageStatus Help - Angelus~ - 10.10.2010

-bump-
Can anyone help me? T.T


Re: UpdateVehicleDamageStatus Help - Rachael - 10.10.2010

If I remember correctly, the script reads the bytes starting from the right, so the rightmost byte affects the hood, the next one affects the trunk etc.

https://sampwiki.blast.hk/wiki/DoorStates


Re: UpdateVehicleDamageStatus Help - Angelus~ - 10.10.2010

Quote:
Originally Posted by Rachael
Посмотреть сообщение
If I remember correctly, the script reads the bytes starting from the right, so the rightmost byte affects the hood, the next one affects the trunk etc.

https://sampwiki.blast.hk/wiki/DoorStates
Yea i figured, but i tried both ways
00000000 00000010 00000000 00000000
00000000 00000000 00000010 00000000

both damaged the trunk >.>
can anyone else confirm?


Re: UpdateVehicleDamageStatus Help - Rachael - 10.10.2010

ok I wrote you a little filterscript
pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#define COLOR_GREY              0xAFAFAFAA

CMD:setdoors(playerid,params[])
{
    new string[128],copyparams[48],count,decimal,vehid;
    vehid = GetPlayerVehicleID(playerid);
    for(new i = 0; i < strlen(params);i++)
    {
        if(params[i] == ' ')
        {
            continue;
        }
        copyparams[count] = params[i];
        count++;
    }
    unformat(copyparams,"b",decimal);
    new panels,doors,lights,tires;
    GetVehicleDamageStatus(vehid,panels,doors,lights,tires);
    UpdateVehicleDamageStatus(vehid,panels,decimal,lights,tires);
    format(string,sizeof(string),"doors: %s decimal: %d",params,decimal);
    SendClientMessage(playerid,COLOR_GREY,string);
    return 1;
}
CMD:getdoors(playerid,params[])
{
    new string[128],binary[48],vehid,exponent = 1;
    new panels,doors,tires,lights;
    vehid = GetPlayerVehicleID(playerid);
    GetVehicleDamageStatus(vehid,panels,doors,lights,tires);
    for(new i = 0; i <= 31;i++)
    {
        if(doors & exponent)
        {
            strins(binary,"1",0,sizeof(binary));
        } else {
            strins(binary,"0",0,sizeof(binary));
        }
        exponent = (2 * exponent);
        switch(i)
        {
            case 7,15,23: strins(binary," ",0,sizeof(binary));
        }
    }
    format(string,sizeof(string),"doors: %s decimal: %d",binary,doors);
    SendClientMessage(playerid,COLOR_GREY,string);
    return 1;
}
note: with /setdoors you can separate the digits to make it easier for you to get them right
eg: /setdoors 00000100 00000110 00000000 00000000

both commands will return a decimal value for you to incude in your script


Re: UpdateVehicleDamageStatus Help - Rachael - 10.10.2010

I just tested your original number, my filterscript confirms that drivers door damaged is indeed 131072.
so you must be doing something else wrong.

remember that you can only UpdateVehicleDamageStatus when there is a driver in the vehicle.

hopefully if you compare your code with the filterscript you can find the error.