SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 12/08/2011, 10:48 AM   #1
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default OnPlayerVehicleDamage

OnPlayerVehicleDamage v1


So, I think there is no normal system like this on the forums.

ChangeLog:
Quote:
Version 1:
-Initial release.
Usage:
Firstly, copy both include files into /pawno/includes
Insert this code on top of your game mode after #include <a_samp>
pawn Code:
#include <OPVD>
And place this function anywhere you like:
pawn Code:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    return 1;
}
Attention: If you use SetVehicleHealth or RepairVehicle in Filterscripts, add this code in all of them.
pawn Code:
#include <OPVD_SEC> // after include <a_samp>
An example:
pawn Code:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    new msg[128];
    format(msg,sizeof(msg)," * You damaged vehicleid %i with %.2f",vehicleid,Damage);
    SendClientMessage(playerid,COLOR,msg);
    return 1;
}
OR a system, to turn off the engine, after a strong hit.
pawn Code:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    if(Damage > 149.0)
    {
        new VehVars[7];
        GetVehicleParamsEx(vehicleid,VehVars[0],VehVars[1],VehVars[2],VehVars[3],VehVars[4],VehVars[5],VehVars[6]);
        if(VehVars[0])
        {
            SetVehicleParamsEx(vehicleid,false,VehVars[1],VehVars[2],VehVars[3],VehVars[4],VehVars[5],VehVars[6]);
            SendClientMessage(playerid,0xFF0000AA," * Your Engine Went down!");
        }
    }
}
Another nice use would be detecting heal hacks: If the Damage is negative, Check if the player is not in a mod shop, and not in a pay& spray.
Installing:
Download and save to pawn/includes folder!

Credits:
Lorenc_ inspired me

Download:
Here you go:
Version 1.0

Feel free to do anything you want with it.

v1 Has been tested.

Last edited by wups; 20/08/2011 at 10:20 PM.
wups is offline   Reply With Quote
Old 12/08/2011, 11:14 AM   #2
rbN.
Banned
 
Join Date: Jan 2010
Location: fissa
Posts: 2,178
Reputation: 289
Default Re: OnPlayerVehicleDamage

Good job..

Would be also awesome if works for vehicles without driver :P
rbN. is offline   Reply With Quote
Old 12/08/2011, 11:32 AM   #3
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default Re: OnPlayerVehicleDamage

Quote:
Originally Posted by RobinOwnz View Post
Good job..

Would be also awesome if works for vehicles without driver :P
Unoccupied vehicle damage is disabled by default, so it's not really needed.
wups is offline   Reply With Quote
Old 12/08/2011, 11:42 AM   #4
CJoao
Huge Clucker
 
CJoao's Avatar
 
Join Date: Nov 2007
Location: Portugal, Madeira
Posts: 296
Reputation: 12
Default Re: OnPlayerVehicleDamage

Another exemple:

if damage is -100 of health the vehicle, you lose 20% of your health!

Code:
public OnPlayerVehicleDamage(playerid,vehicleid,Float:Damage)
{
    new Float:health;
        if(IsPlayerConnected(playerid) && IsPlayerInVehicle(playerid,vehicleid)) {
            if(Damage > 100){ GetPlayerHealth(playerid,health); SetPlayerHealth(playerid,health-20);}
        }
    return 1;
}
Sorry For My English
CJoao is offline   Reply With Quote
Old 12/08/2011, 11:57 AM   #5
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,250
Reputation: 1141
Default Re: OnPlayerVehicleDamage

pawn Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    return 1;
}



Pretty mad release :P
Should have some detection modes, (BUMPED CAR, SHOT_CAR)

Good job mate
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 12/08/2011, 12:07 PM   #6
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default Re: OnPlayerVehicleDamage

Quote:
Originally Posted by Lorenc_ View Post
pawn Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    return 1;
}



Pretty mad release :P
Should have some detection modes, (BUMPED CAR, SHOT_CAR)

Good job mate
Heh, fixed the topic.
For the suggestion, i think it's quite much scripting to do that.
wups is offline   Reply With Quote
Old 12/08/2011, 12:33 PM   #7
Gh0sT_
Gangsta
 
Join Date: Sep 2010
Location: Lithuania, Alytus
Posts: 725
Reputation: 0
Default Re: OnPlayerVehicleDamage

You should add params like "oldhealth, newhealth"
__________________
Includes
Player/Vehicle Control
Entrances system
Gh0sT_ is offline   Reply With Quote
Old 12/08/2011, 06:24 PM   #8
Macluawn
Gangsta
 
Macluawn's Avatar
 
Join Date: Aug 2010
Location: Latvia
Posts: 637
Reputation: 78
Default Re: OnPlayerVehicleDamage

Quote:
Originally Posted by wups View Post
Unoccupied vehicle damage is disabled by default, so it's not really needed.
Take a parachute and hit the car.
Macluawn is offline   Reply With Quote
Old 12/08/2011, 06:28 PM   #9
wups
High-roller
 
wups's Avatar
 
Join Date: Apr 2010
Location: Lithuania
Posts: 1,251
Reputation: 137
Default Re: OnPlayerVehicleDamage

Quote:
Originally Posted by Macluawn View Post
Take a parachute and hit the car.
LOL, I didn't know this!
wups is offline   Reply With Quote
Old 12/08/2011, 07:15 PM   #10
rbN.
Banned
 
Join Date: Jan 2010
Location: fissa
Posts: 2,178
Reputation: 289
Default Re: OnPlayerVehicleDamage

Quote:
Originally Posted by wups View Post
LOL, I didn't know this!


weird bug anyways lol
rbN. is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.