[Include] OnEmptyVehicleDamage - Damage an empty vehicle (v0.1) [0.3c R3 Server]
#1

What is it?
Yesterday i saw, that Kalcor released a new Server Version for SA-MP and the new Callbacks allows me to make this little include. It's my first Include which I release ... and I hope you will enjoy it.

With this Include you can recognize if a vehicle got hit by a person with a weapon...
There is a FS from somebody which was released last year and do almost the same like my include but i think this solution is a little bit better because it doesn't use the Camera Vectors. It uses the new Callback "OnUnoccupiedVehicleUpdate" to check if the vehicle was really hit and moved...

Update v0.3
This Update is a really important update, because [BEP]AcerPilot gave me a tip and now the include doesn't use the Camera Vectors. It means that the include runs more correctly and faster, but if you want to check if the Person Looks at the vehicle you could use the function "IsPlayerLookingAtVehicle".

Now I use only the Animationindex, too. This should speed up the Include.

Furthermore the Callback change:
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
    // Vehicleid = The ID of The Vehicle
        // Playerid = The ID of the Player who shot or hit the vehicle
        // exems = The Time to execute this Callback in milliseconds
    return 1;
}
Moreover there are also 2 new Function which can be use
Код:
IsPlayerLookingAtVehicle(playerid,vehicleid);
GiveVehicleHealth(vehicleid,health);
Update v0.21
1) Bugfixxes...
2) Now you can also use your fist to damage the vehicle...

Update v0.2
1) I improved the Camera Vector System... It works so great now, almost perfect :P. If you shot at the vehicle or hit it with a baseball bat, shovel etc. and the vehicle moves, the system recognize it...
2) Furthermore now you can also use the weapons from 1 to 15 to damage an empty vehicle... I made a blockade so the Callback "OnEmptyVehicleDamage" will only call as often as you hit the vehicle and not as often as "OnUnoccupiedVehicleUpdate" is called.
And the Script runs without any for loop, so it should be very fast...


Videos
Version 0.2
Version 0.1


How to install
Copy the VD.inc into the Pawno\include folder

Insert the Include
pawn Код:
#include <VB>
and insert the new Callback
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
    // Your Code
    return 1;
}
Example
1)
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
        if(IsPlayerLookingAtVehicle(playerid,vehicleid))
        {
               new Float:Health;
                   GetVehicleHealth(vehicleid,Health);
                   SetVehicleHealth(vehicleid,Health-random(100));
        }
        //You do not have to use the function "IsPlayerLookingAtVehicle" but with this function you can be 99%    
        //sure that you shot at the vehicle ;)
    return 1;
}
2)
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
    // Toggle Vehicle Alarm
    return 1;
}
3) My Favourite :P
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
    ChangeVehicleColor(vehicleid,random(126),random(126));
    return 1;
}

The Future
There are still some little problems, because not every vehicle moves if it got hit. I will try to solve this little problem...


Credits
To RyDeR (GetVehicleSize)
To unkown Person who made "Holding define"
To wups (Alternativ hook method for callbacks)


Download (All this includes doen't work with 0.3d or above)
Click me (v0.3)
Click me (v0.3 - Pastebin)


Click me (v0.21)
Click me (v0.21 - Pastebin)

Click me (v0.2)
Click me (v0.2 - Pastebin)

Click me (v0.1)
Click me (v0.1 - Pastebin)

Warning:
You need the the newest SA-MP 0.3c Server Version (R3)
Newest 0.3c Server Version
Reply
#2

Nice Upload to pastebin please.
Reply
#3

pawn Код:
D:\SAMP\samp03csvr_R2-2_win32\pawno\include\VD.inc(141) : error 017: undefined symbol "GetPlayerDistanceFromPoint"
D:\SAMP\samp03csvr_R2-2_win32\pawno\include\VD.inc(166) : warning 235: public function lacks forward declaration (symbol "OnUnoccupiedVehicleUpdate")
D:\SAMP\samp03csvr_R2-2_win32\pawno\include\VD.inc(194) : error 017: undefined symbol "GetPlayerCameraMode"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Reply
#4

Look at the Title :P
You use R2 Server and you need R3...
Click me (R3 Server)
Reply
#5

Omg , didnt see :/
Reply
#6

Looks nice, maybe in future updates that if you shoot with like a Desert Eagle on an empty car it gets the damage of the desert eagle, and if you shoot on the Tank-Cap it explodes, and on the tires it got flattened tires and when you shoot with a M4 it gets the damage of the M4?
Reply
#7

I also trough about it but I decide to release an Include which is completly customizable, so the user can decide what happend when the vehicle got hit...

There are people who doesn't want to set the health when it got hit but they want to start the alarm of the vehicle
Reply
#8

But there should also be something that can turn Damage on vehicle On/Off at any spot like in Singleplayer.
Reply
#9

This is very nice, and I have a video as an example if you wish.

The code used for this video:

pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid)
{
    if(GetPlayerWeapon(playerid) == 24)
    {
        new Float:Health;
        GetVehicleHealth(vehicleid,Health);
        SetVehicleHealth(vehicleid, 100);
    }
    return 1;
}
[ame]http://www.youtube.com/watch?v=H-4QU_kqtIA[/ame] (Processing, video quality goes upwards)
Reply
#10

looks nice. Soon testing
Reply
#11

@Skylar Paul:

Thanks for the video... it shows the function in the best way :P and furthermore it's really funny that you used the same car for testing. Invernus is the best test car
Reply
#12

Yea looks cool, but is not the same thing as someone is in the vehicle.
Reply
#13

New Update...
Reply
#14

Quote:
Originally Posted by Nanory
Посмотреть сообщение
New Update...
Nice! Keep the updates coming!
Reply
#15

Update ...
The Include runs without Camera Vectors, because i realized that the Looking Position isn't need. This means that the Include runs faster now.
Reply
#16

Hi

I am not sure but is there a possibility for this situation:

I drive with a car in an empty car and the alarm system of this other car will start ?


Simon
Reply
#17

how to make with this damage for vehicle serverside? like windshild damage and so on...?
Reply
#18

Intresting, will check it out soon on the server.
Reply
#19

This isn't a forum about PHP, it's a forum about PAWN. Use the PAWN tags please:

Quote:

[ pawn] <insert code here> [/pawn ] - without the spaces in the tags

Reply
#20

@dUDALUS: With the current release it isn't possible but i could script it.

@whitedragon: I don't understand your question (Maybe it is because of my missing english knowledge )

@RealCop228: Okay I wanted to make with pawn but I could not find the the right BB-Code and it wasn't listed in BB-Code List of this forum, but thanks for the tip, I changed it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)