OnVehicleDamageStatusUpdate
#1

Hello, I'm in doubt, I have a code here, is used in a public SA-MP, is as follows, if the person hit with a vehicle and be with the seat belt:

PHP код:
VerificarVelocidade(playerid); //This function is called only when the driver or passenger is without the belt 
I wanted to make this function is valid for the driver and passengers at this time is only for drivers, as I do for the passenger receive the same function (For example, the person hits a vehicle, to and all the vehicle receiving function) ? very complex, going beyond the SA-MP! ..

PHP код:
public OnVehicleDamageStatusUpdate(vehicleidplayerid)
{
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerInVehicle(ivehicleid))
        {
            if (
CintoPlayerid[i] == 0)
            {
                
VerificarVelocidade(playerid);
            }
            else if (
Capacetes[i] == && IsAMotos(GetPlayerVehicleID(i)))
            {
                
VerificarVelocidade(playerid);
            }
        }
    }

Reply
#2

up please.. help-me!? ..
Reply
#3

What execly you want to add/fix/change to this code?
Reply
#4

Quote:
Originally Posted by maximthepain
Посмотреть сообщение
What execly you want to add/fix/change to this code?
verifies that the player hit the vehicle with OnVehicleDamageStatusUpdate more this checking only for the driver and the passenger nothing happens, the passageito must receive the damage
Reply
#5

someone can give me some information?
Reply
#6

If you want what is happening to the driver, to also happen to the passengers, all you have to do is this:

Код:
if(GetPlayerVehicleid(I) == GetPlayerVehicleID(playerid))
{
          // do something here
}
Reply
#7

Ok so just to verify, when a vehicle gets hit, you want to damage players in that vehicle? (where there might be things like more or less damage for passengers/drivers?)

If i understood correctly, then you should really go at this in a different manner, to save resources, and trouble down the road.
1] Make a array in which you will store vehicle driver/passengers, use vehicle id as key, and another array (containing player id's) as value
2] When a player gets in a vehicle, save it too the array, again, i would make the first 'layer' vehicle-id, and the second layer is seats.
2b] When a player gets out of a vehicle (dont forget disconnects or deaths) remove them from the array.
3] When a vehicle gets hit, look at the array, using the vehicle id, should result in an array of driver/passengers of said vehicle
4] Loop trough the few driver/passengers, and apply damage
5] Rinse and repeat.

The above will be way faster then what you try to do now, because it wont loop trough MAX_PLAYERS for every single vehicle damage 'event', and it will make applying damage too the vehicle participants easier too.

If you really want too, then somebody here can write you the code needed to do the above, but in general, forums like these tend to push people into learning to code things themselves, so i guess i speak for the entire forum when i say we'd much rather see you try the above, and report back here with questions, then have you copy our example code 1on1 and then complain that it doesnt work because you cant spot a (deliberate) typo.

Looking at what you supplied, im fairly sure you are more then capable to write this.
Reply
#8

Sorry forgot to add that you will also have to use a loop, such as:

for(new I = 0; I < MAX_PLAYERS; I++) etc..
Reply
#9

Quote:
Originally Posted by IzadorO
Посмотреть сообщение
Sorry forgot to add that you will also have to use a loop, such as:

for(new I = 0; I < MAX_PLAYERS; I++) etc..
I did the system but is not functional, what's wrong?

PHP код:
public OnVehicleDamageStatusUpdate(vehicleidplayerid)
{
    new 
Floathealth;
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsAMotos(vehicleid))
        {
            if (
GetPlayerSpeed(playeridtrue) >= 50)
            {
                if (
IsPlayerInVehicle(ivehicleid))
                {
                    if(
Capacetes[i] == 1) continue;
                    
GetPlayerHealth(ihealth);
                    
SetPlayerHealth(ihealth 7);
                }
                return 
1;
            }
            else if (
GetPlayerSpeed(playeridtrue) >= 100)
            {
                if (
IsPlayerInVehicle(ivehicleid))
                {
                    if(
Capacetes[i] == 1) continue;
                    
                    
GetPlayerHealth(ihealth);
                    
SetPlayerHealth(ihealth 10);
                }
            }
            return 
1;
        }
        else
        {
            if (
GetPlayerSpeed(playeridtrue) >= 50)
            {
                if (
IsPlayerInVehicle(ivehicleid))
                {
                    if(
CintoPlayerid[i] == 1) continue;
                    
GetPlayerHealth(ihealth);
                    
SetPlayerHealth(ihealth 7);
                }
                return 
1;
            }
            else if (
GetPlayerSpeed(playeridtrue) >= 100)
            {
                if (
IsPlayerInVehicle(ivehicleid))
                {
                    if(
CintoPlayerid[i] == 1) continue;
                    
GetPlayerHealth(ihealth);
                    
SetPlayerHealth(ihealth 10);
                }
            }
        }
        return 
1;
     }

Reply
#10

pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    new Float:damage, Float:speed = GetPlayerSpeed(playerid, true);
    if(IsAMotos(vehicleid))
    {
        if(speed >= 100.0) damage = 10.0;
        else if(speed >= 50.0) damage = 7.0;
        new Float:health;
        for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(!IsPlayerInVehicle(i, vehicleid)) continue;
            if(Capacetes[i] == 1) continue;
            GetPlayerHealth(i, health);
            SetPlayerHealth(i, health - damage);
        }
    }
    else
    {
        if(speed >= 100.0) damage = 10.0;
        else if(speed >= 50.0) damage = 7.0;
        new Float:health;
        for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
        {
            if(!IsPlayerConnected(i)) continue;
            if(!IsPlayerInVehicle(i, vehicleid)) continue;
            if(CintoPlayerid[i] == 1) continue;
            GetPlayerHealth(i, health);
            SetPlayerHealth(i, health - damage);
        }
    }
    return 1;
}
Due to how OnVehicleDamageStatusUpdate is called, you probably won't get the functionality that you're expecting. By the time this callback is called, the chances are that your vehicle speed will have dramatically decreased anyway. Also, remember that this callback is called when a vehicle is 'visually' damaged.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)