SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/11/2010, 12:00 AM   #1
The_Moddler
High-roller
 
The_Moddler's Avatar
 
Join Date: Jan 2010
Location: In my house.
Posts: 1,168
Reputation: 3
Default Car damage system - Damage a car without a driver!

Damage Car System V2.5

Hi,

Here I bring this simple system, basicly, you can damage cars without a driver with a gun.

Usage:

Extract the files to your 'pawno/include' folder, then in your script you put: #include <Damage>, and you are ready to use it.

You can also change some configuration opening damage.inc and tweak it to your taste.

You must include those callbacks, if you don't, you will get an error message.

pawn Code:
public OnPlayerShotVehicle(playerid, vehicleid)
{
    //your code here...
    printf("playerid %d is shooting vehicleid %d", playerid, vehicleid);
    return 1;
}

public OnPlayerUnShotVehicle(playerid, vehicleid)
{
    //your code here...
    printf("playerid %d stopped shooting vehicleid %d", playerid, vehicleid);
    return 1;
}

You will have to add this under their respective callbacks:

pawn Code:
D_OnPlayerConnect(playerid); //Under OnPlayerConnect
D_OnPlayerDisconnect(playerid); //Under OnPlayerDisconnect
D_OnPlayerKeyStateChange(playerid, newkeys, oldkeys); //Under OnPlayerKeyStateChange
That's all, if you don't put it, it won't work and it will give you some warnings.

Functions:

Well, there is just one for now, if you need any other fuction that I can make just post in here.

pawn Code:
IsPlayerShootingVehicle(playerid);

It will return the vehicle id if he is shooting, 0 if not.

pawn Code:
if(IsPlayerShooting(playerid))
{
    printf("playerid %d is shooting vehicleid %d", playerid, IsPlayerShooting(playerid));
}

Bugs:

» It doesn't work with the rifle, shotgun, and with some other constant reloading weapons.
» You can damage cars trough walls.
» If there are too many cars together, it may not work properly.

Special thanks:
niCe for the IsPlayerAimingAt.
For the guys who made IsVehicleOccupied and GetClosestVehicle.
And to g_aSlice for some helping

Links:
Solidfiles > Errors FIXED. <

Version history:
  • V2.5: Fixed a bug when the vehicle exploded, now it will respawn if health is less than 250, fixed errors, added damage to car.
  • V2.0: Added callbacks and functions.
  • V1.0: Just the script.

Peace.
__________________

Last edited by The_Moddler; 07/03/2011 at 07:15 PM.
The_Moddler is offline   Reply With Quote
Old 02/11/2010, 12:07 AM   #2
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: Car damage system - Damage a car without a driver!

Can you show some things?
__________________
Fuck the system.
willsuckformoney is offline   Reply With Quote
Old 02/11/2010, 12:08 AM   #3
The_Moddler
High-roller
 
The_Moddler's Avatar
 
Join Date: Jan 2010
Location: In my house.
Posts: 1,168
Reputation: 3
Default Re: Car damage system - Damage a car without a driver!

Quote:
Originally Posted by willsuckformoney View Post
Can you show some things?
I'll make a vid tomorrow, im going to bed right now, if you want and can make a vid for me, it will be apreciated :P
__________________
The_Moddler is offline   Reply With Quote
Old 02/11/2010, 12:09 AM   #4
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: Car damage system - Damage a car without a driver!

Busy myself, looked at the script, you need to post some credits :S. Also You could had at least showed us an example on how to use it or something.
__________________
Fuck the system.
willsuckformoney is offline   Reply With Quote
Old 02/11/2010, 12:11 AM   #5
GaGlets(R)
Gangsta
 
GaGlets(R)'s Avatar
 
Join Date: Oct 2009
Posts: 931
Reputation: 2
Default Re: Car damage system - Damage a car without a driver!

Omg, 1 milisecond timer when presing/holding fire key..

Errrm.. You should add credit for
Code:
IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
This sucks.. soz but its true. First reson - 1 millisecond timer.
No credits added for all functions include IsPlayerAimngAt.
GaGlets(R) is offline   Reply With Quote
Old 02/11/2010, 12:13 AM   #6
The_Moddler
High-roller
 
The_Moddler's Avatar
 
Join Date: Jan 2010
Location: In my house.
Posts: 1,168
Reputation: 3
Default Re: Car damage system - Damage a car without a driver!

Quote:
Originally Posted by GaGlets(R) View Post
Omg, 1 milisecond timer when presing/holding fire key..

Errrm.. You should add credit for
Code:
IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
This sucks.. soz but its true. First reson - 1 millisecond timer.
No credits added for all functions include IsPlayerAimngAt.
Where is the one milisecond timer?

I only see a 794 milisecond timer..

Gonna add the credits, I forgot :S

EDIT:

OMG I am so tired that putted the wrong link, now it's okay, credits added also.

BTW Gaglets, you suck.
__________________

Last edited by The_Moddler; 02/11/2010 at 12:28 AM.
The_Moddler is offline   Reply With Quote
Old 02/11/2010, 12:21 AM   #7
Camacorn
Gangsta
 
Camacorn's Avatar
 
Join Date: Sep 2009
Location: Florida, USA
Posts: 752
Reputation: 85
Default Re: Car damage system - Damage a car without a driver!

Looks nice, i will use this, thanks!
Camacorn is offline   Reply With Quote
Old 02/11/2010, 12:32 AM   #8
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,505
Reputation: 65
Default Re: Car damage system - Damage a car without a driver!

Quote:

EDIT:

OMG I am so tired that putted the wrong link, now it's okay, credits added also.

BTW Gaglets, you suck.
Lmao^^ Also that '1' that he seen and said was millisecond is the repeat (true/false) he put 1 for true.
__________________
Fuck the system.
willsuckformoney is offline   Reply With Quote
Old 02/11/2010, 12:55 AM   #9
ViruZZzZ_ChiLLL
High-roller
 
ViruZZzZ_ChiLLL's Avatar
 
Join Date: Aug 2009
Location: I don't know
Posts: 1,701
Reputation: 8
Default Re: Car damage system - Damage a car without a driver!

Look's cool yet simple.
Goodjob!
__________________


ViruZZzZ_ChiLLL is offline   Reply With Quote
Old 02/11/2010, 07:08 AM   #10
Slice
High-roller
 
Slice's Avatar
 
Join Date: Mar 2008
Location: Sweden
Posts: 1,858
Reputation: 1234
Default Re: Car damage system - Damage a car without a driver!

Couple problems (some can be fixed, some can't):
  • Hold fire and tap the action key to do loads of damage to cars (I think, I have only looked at the code).
  • The damage is random.
  • Large vehicles are hard to hit, and small vehicles are easy.
  • Cars take damage when shooting through walls.
  • You can jump/fall/lay down and damage vehicles.

pawn Code:
new veh = GetClosestVehicle(playerid);
        if(veh)
Will always be true (INVALID_VEHICLE_ID is 0xFFFF)

pawn Code:
if(weap == 0 || weap == 1 || weap == 4 || weap == 15 || weap == 40 || weap == 46 || weap == 43 || weap == 45 || weap == 44
    || weap == 42 || weap == 17 || weap == 3 || weap == 7 || weap == 8 || weap == 10 || weap == 11 || weap == 12 || weap == 13)
    {
        return 1;
    }
Will return 1 when unarmed, aswell.

pawn Code:
Hook:D_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(HOLDING(KEY_ACTION) || HOLDING(KEY_FIRE))
    {
        Timer[playerid] = SetTimerEx("C_Update", UPDATE_TIME, 1, "i", playerid);
    }
    else
    {
        KillTimer(Timer[playerid]);
    }
    return 1;
}
The timer can be re-created several time. One crafty person could probably cause havoc in the server by holding fire and tapping tab.
__________________
Do you like SA-MP and DayZ? Come play both: ulclan.com:1421

Do you use any scripts I've made?
Star them on GitHub or reply in their topics so I know what I should keep working on!
Slice 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS]Tires Damage System. lolmaster Filterscripts 16 10/09/2011 05:39 AM
Damage? Despare Help Archive 1 17/08/2010 05:12 AM
[FilterScript] [FS] Damage System crone Релизы/Releases 5 10/05/2010 09:37 AM


All times are GMT. The time now is 06:21 PM.


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