Calculating Damage for new doors/ tires/ lights/panals?
#1

Does anyone know an efficient way (or any way) to calculate the status for the parts within doors, tires, lights, and panals in a vehicle?

I'm hoping to encode them and then have it detect the parts that are damaged.


So as in somthing that will do this (Obviously this wont work... but it shows what I mean):

pawn Код:
new lightcost = 0;//Cost for light repair
encode_lights(light1, light2, light3, light4)//Some way to detect light damaged/undamaged
if(light1 != 0)//if light1 is broken
{
      lightcost += 35;//Add $35 to light repair
}
if(light2 != 0)
{
      lightcost += 35;

}
if(light3 != 0)
{
      lightcost += 35;

}
if(light4 != 0)
{
      lightcost += 35;

}
Does anyone know how to do somthing like this. I will be using it for an advanced /repair system.
Reply
#2

Would have to make a Native that isn't written in Pawn.
Reply
#3

I dont think its possible, atleast I've never heard of anything near it.

Intresting though..
Reply
#4

I think you can use this GetVehicleDamageStatus
Reply
#5

Quote:
Originally Posted by Scrillex
Посмотреть сообщение
I think you can use this GetVehicleDamageStatus
Yeah, its a usefull function I gonna use it my self lol thanks
Reply
#6

Allright, you're sort of correct. That is what I will use (I knew that however), but maybe I should ask a better and easier question,

If I have: [Panels] : 1048576

I know that:
flp=1(bad), frp=0(good), rlp=4(good), rrp=8(good), windshield=5(bad), front_bumper=7 (bad), rear_bumper=6 (good)


But how do I seperate each number out so I can assign in to a variable?
Reply
#7

Maybe something like this:
pawn Код:
new panelstring[8];
format(panelstring,sizeof(panelstring),"%d",panels);
new flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper;
for(new i=0; i < sizeof(panelstring); i++)
{
    switch(i)
    {
        case 0:
        {
            flp = strval(panelstring[i]);
        }
        case 1:
        {
            frp = strval(panelstring[i])
        }
        case 2:
        {
            rlp = strval(panelstring[i])
        }
        case 3:
        {
            rrp = strval(panelstring[i])
        }
        case 4:
        {
            windshield = strval(panelstring[i])
        }
        case 5;
        {
            front_bumper = strval(panelstring[i])
        }
        case 6:
        {
            rear_bumper = strval(panelstring[i])
        }
       
    }
}
For this you need to make a string of the panel value. Not sure if this works, and not sure if it's a good way to do it, but I think it's something like this.
If anyone else replies with a better method, then use that one.
Reply
#8

Well, it didn't work correctly... for two reasons.

In the example where 1048576 represented my GetVehicleDamageStatus output, I got this:

flp = 1048576
frp = 48576
rlp = 48576
rrp = 8576
windshield = 576
front_bumper = 76
rear_bumper = 6


Problem #1: (Which could be resolved by simple division) It showed the numbers after the first digit.
Problem #2: It ignored the what should have been 0 in frp (first number), resulting in it showing the value of rpl first.


Anyone know what to do? I could, like I mentioned forgive the first issue by dividing the intiger by a certain 10's ammount (So rrp/1000 would show 8 and not 8576). Just not sure...


UPDATE:

After searching pastebin, I ran across a solo piece of script I could find nowhere. This does excatly what I need, after some minor editing: http://pastebin.com/0pdKyzm1 (Gets all parts damage... 0 = bad & 1 = good)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)