Accidents system - help!
#1

As in the topic. Is anybody can help me with making of accidents system? I mean if the any vehicle is suddenly lost many HP - the driver and passengers are injured. This can include a vehicle speed too. If player is driving with too many speed, the health of player is decreased when the vehicle hits an object. How to make this?
Reply
#2

Try this ... "Seat Belt System "Ekano" [V.1]"
Reply
#3

This doesn't work for me :C
Reply
#4

what your asking for
well youll need to check to see if the player is in the vehicle and if the vehicle loses health set the player health amount for damage recieve, vehicle healths are max 1000 and health 100
Reply
#5

you can do it easily using OnVehicleDamageStatusUpdate , and GetVehicleSpeed
Reply
#6

Okay, thanks all!

HuSs3n you are my god
Reply
#7

pawn Код:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    if(Damage > 149.0)
    {
        foreach(Player, i)
        {
            if(GetPlayerVehicleID(i) == vehicleid)
            {
                if(belt[i] == 1)
                {
                    GivePlayerHealth(i, -2);
                }
                else
                {
                    GivePlayerHealth(i, -30);
                }
            }
        }
    }
    return 1;
}
Or this one, which I prefer.

pawn Код:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    foreach(Player, i)
    {
        if(GetPlayerVehicleID(i) == vehicleid)
        {
            if(belt[i] != 1)
            {
                new Float:dam;
                dam = (Damage / 20) * 3;
                GivePlayerHealth(i, -dam);
            }
        }
    }
    return 1;
}

You'll need the include.

And:

OPVD.inc

pawn Код:
/********************************************
 * OnPlayerVehicleDamage! V1.0              *
 * Credits: wups                            *
 ********************************************/

// include

#include <a_samp>


// defines
#if defined OPVD_INC
    #endinput
#endif
#define OPVD_INC

forward OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage);

static
        Float:OPVD_VehHealth[MAX_VEHICLES] = {1000.0, 1000.0,...},
        bool:OPVD_VehUpd[MAX_VEHICLES]={false,false,...},
        bool:OPVD_OPUP,
        bool:OPVD_OPSC;
       
       
public OnPlayerUpdate(playerid)
{
    static      PL_VehID;
    PL_VehID = GetPlayerVehicleID(playerid);
    if(PL_VehID)
    {
        static      Float:PL_VehHP;
        GetVehicleHealth(PL_VehID,PL_VehHP);
        if(OPVD_VehUpd[PL_VehID])
                OPVD_VehUpd[PL_VehID]=false;
        else
        {
            if(PL_VehHP != OPVD_VehHealth[PL_VehID] && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
                    CallLocalFunction("OnPlayerVehicleDamage","iif",playerid,PL_VehID,(OPVD_VehHealth[PL_VehID]-PL_VehHP));
        }
        OPVD_VehHealth[PL_VehID]=PL_VehHP;
    }
   
    return (OPVD_OPUP)?CallLocalFunction("OPVD_OnPlayerUpdate","i",playerid):1;
}

#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif

#define OnPlayerUpdate OPVD_OnPlayerUpdate
forward OPVD_OnPlayerUpdate(playerid);
// OnPlayerStateChange
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
        OPVD_VehUpd[GetPlayerVehicleID(playerid)]=true;
    return (OPVD_OPSC)?CallLocalFunction("OPVD_OnPlayerStateChange","iii",playerid,newstate,oldstate):1;
}
#if defined _ALS_OnPlayerStateChange
    #undef OnPlayerStateChange
#else
    #define _ALS_OnPlayerStateChange
#endif
#define OnPlayerStateChange OPVD_OnPlayerStateChange

forward OPVD_OnPlayerStateChange(playerid,newstate, oldstate);

forward OPVD_SetVehicleHealth(vehicleid,Float:health);
public OPVD_SetVehicleHealth(vehicleid,Float:health)
{
    OPVD_VehUpd[vehicleid]=true;
    return SetVehicleHealth(vehicleid, health);
}

forward OPVD_RepairVehicle(vehicleid);
public OPVD_RepairVehicle(vehicleid)
{
    OPVD_VehUpd[vehicleid]=true;
    return RepairVehicle(vehicleid);
}
#define RepairVehicle OPVD_RepairVehicle
#define SetVehicleHealth OPVD_SetVehicleHealth


#if defined FILTERSCRIPT
    // OnFilterScriptInit
    public OnFilterScriptInit()
    {
        OPVD_OPUP = (funcidx("OPVD_OnPlayerUpdate") != -1);
        OPVD_OPSC = (funcidx("OPVD_OnPlayerStateChange") != -1);
        return (funcidx("OPVD_OnFilterScriptInit") != -1)?CallLocalFunction("OPVD_OnFilterScriptInit",""):1;
    }
    #if defined _ALS_OnFilterScriptInit
        #undef OnFilterScriptInit
    #else
        #define _ALS_OnFilterScriptInit
    #endif
    #define OnFilterScriptInit OPVD_OnFilterScriptInit
    forward OPVD_OnFilterScriptInit();
#else
    // OnGameModeInit
    public OnGameModeInit()
    {
        OPVD_OPUP = (funcidx("OPVD_OnPlayerUpdate") != -1);
        OPVD_OPSC = (funcidx("OPVD_OnPlayerStateChange") != -1);
        return (funcidx("OPVD_OnGameModeInit") != -1)?CallLocalFunction("OPVD_OnGameModeInit",""):1;
    }
    #if defined _ALS_OnGameModeInit
        #undef OnGameModeInit
    #else
        #define _ALS_OnGameModeInit
    #endif
    #define OnGameModeInit OPVD_OnGameModeInit
    forward OPVD_OnGameModeInit();
#endif
// end
Reply
#8

Oh, milanosie your idea is better than my FS!!! Repu up and big thanks
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)