SA-MP Forums Archive
Detect invincible vehicle ? - 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)
+--- Thread: Detect invincible vehicle ? (/showthread.php?tid=446035)



Detect invincible vehicle ? - vardanega - 24.06.2013

Hi guys,

I want to know if there is a reliable way to detect whether a vehicle (with one player driving) is invincible?

Thank you all for your replies


Re: Detect invincible vehicle ? - Cjgogo - 24.06.2013

Well, most likely you have to check it's HP first. If it's greater than 1000.0, then the player should be banned. However, a smarter hack might use the vehicle's HP to it's advantage(so the hack can't be detected), and if the vehicle's HP it's less than 1000.0, it immediatly repairs/restores the vehicle's health back to 1000.0(so, yeah, same as the previous hack, just smarter).

In that case you should script a timer FOR EACH individual vehicle in the server(don't loop through them in a single timer). First of all, you're first checking if the vehicle has a driver. When you find the desired vehicle, check it's HP. If it's less than 1000, then store that variable(or somehow remember the vehicle). When the timer executes again for that vehicle, if it's HP is 1000, then you should ban the player. HOWEVER, you also need to check if they are not in range of modding garages, or Pay n Sprays. You might ban him for sparying his vehicle. So, yeah, seems hard, but it's not that hard.


Re: Detect invincible vehicle ? - park4bmx - 24.06.2013

something like this?
pawn Код:
new Timer;
CheckVehicle(vehid)
{
     new Float:health;
    GetVehicleHealth(vehid, health);
     SetVehicleHealth(vehicleid, 998);
     if(Timer !-1) KillTimer(Timer);
     Timer = SetTimerEx("Check", 1200, false,"ii",vehicleid,health);//give it 1 sec to change
}
forward Check(vehid,oldhealth);
public Check(vehid,oldhealth){
    new Float:health;
    GetVehicleHealth(vehid, health);
    if(health<=998 && health >= 980)
    {
        SetVehicleHealth(vehid, oldhealth);
        return 1;//vehicle's Health not changed!
    }else{
        return 0;//vehicle's Health changed!
    }
}



Re: Detect invincible vehicle ? - Vrag - 24.06.2013

You can see vehicles health and if its bigger then 999.9


Re : Detect invincible vehicle ? - vardanega - 24.06.2013

I figured out how to detect when the player returns to the life his vehicle but what I want is a way to detect when the player takes the example colission with another vehicle but the vehicle does not lose life.

I hope you understand!


Re: Detect invincible vehicle ? - Kyle - 24.06.2013

You lot don't understand his question.

He wants to make it so if people shoot his car / he crashes it and he doesn't get damaged = hacks.

Although I think it is pretty impossible. ^


Re: Detect invincible vehicle ? - introzen - 24.06.2013

pawn Код:
new Float:vehiclehealth[MAX_VEHICLES];
new Float:playerhealth[MAX_PLAYERS];
new Float:playerarmor[MAX_PLAYERS];

forward CheckPlayerGodMode(playerid);
public CheckPlayerGodMode(playerid)
{
    new Float:health, Float:armor, Float:vehhealth;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, vehhealth);
    if(vehiclehealth[veh] != vehhealth)
    {
        GetPlayerHealth(playerid,health);
        GetPlayerArmour(playerid,armor);
        if((playerhealth[playerid] == health) || (playerarmor[playerid] == armor))
        {
            //Player has godmode. What to do?
        }
        else
        {
            //player doesn't cheat
        }
        playerhealth[playerid] = health;
        playerarmor[playerid] = armor;
        return 1;
    }
    vehiclehealth[veh] = vehhealth;
    return 1;
}
NOT TESTED!
Also, this script is simple so if anyone repairs the car in a pay'n'spray, it would show up as cheat. Fix:

switch
pawn Код:
if(vehiclehealth[veh] != vehhealth)
to
pawn Код:
if(vehiclehealth[veh] > vehhealth)



Re : Detect invincible vehicle ? - vardanega - 28.06.2013

The problem is that the life of my vehicle and the same as the player's life (I script a derby)


Re: Detect invincible vehicle ? - park4bmx - 28.06.2013

so, the player has MAX 1000 health ?
because the vehicle cant have MAX 100 as it will explode straight away.

if that's the case the code should work


Re : Detect invincible vehicle ? - vardanega - 28.06.2013

Код:
forward UpdateVieVehicule();
public UpdateVieVehicule()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
		{
            new Float:health;
            GetVehicleHealth(GetPlayerVehicleID(i),health);
            health = (health - 250.0) * (100.0/ 750.0);
            SetPlayerHealth(i,health);
        }
    }
}