18.06.2014, 19:35
(
Последний раз редактировалось XStormiest; 25.08.2014 в 22:54.
)
Hello everyone, I'm XStormiest and as you may know since the last update 0.3z, its been added a new simple callback but awesome, it allows you to verify what player shoots.
First lets take a brief explaination of the callback
Callback: OnPlayerWeaponShot
Paramaters:
Return Values:
Good, now lets see the type of things we can verify if shooted
What can you do with those TYPES?
BULLET_HIT_NONE:
Good to use with the X,Y,Z coordonates, you can create an awesome Explosive Bullets for example.
BULLEY_HIT_PLAYER:
Good for making different things based on your creativity for example, you can make more damage bullets , or one shot bullets or anything you want.
BULLET_HIT_VEHICLE:
Is what we gonna use in this tutorial, also you can make different things as well here, it depends on your imagination.
BULLET_HIT_TYPE_OBJECT:
As said below, in the part of NONE section where i told you about Explosive Bullets , you can make them to remove an object that is in the radius of where palyer shoot
BULLET_HIT_TYPE_PLAYEROBJECT:
Cool feature, you can use this for example: making a DM Test for players, and they have to shoot different objects. so in this case, only they will see the objects and actual shoot them.
Why is this Callback awesome?
Because before if you wanted to ever do that, you had to use Camera Vectors to verify if player look at that object, but that would be inacurracy, but now is more precise i guess..
Now that I explained almost every single thing about this feature , lets actually get into the tutorial.
So we have this simple callback
Ok this was my tutorial.
I want to say sorry if i have some mistakes (Im from Romania so my english is not that perfect yet...)
Also, if you know a easy way to do that , go ahead tell me , correct me if Im wrong cause I dont want to learn others wrong scripts.
First lets take a brief explaination of the callback
Callback: OnPlayerWeaponShot
Paramaters:
Код:
playerid - the id of the player that shoot weaponid - the id of the weapon that player use to shoot hittid - the id of the object/player/car that have been hit fx - the coordonate of X axis where player shoots fy - the coordonate of Y axis where player shoots fz - the coordonate of Z axis where player shoots
Код:
0 - prevent any bullet from being shoot 1 - allows bullets to be shoot
Код:
BULLET_HIT_TYPE_NONE 0 BULLET_HIT_TYPE_PLAYER 1 BULLET_HIT_TYPE_VEHICLE 2 BULLET_HIT_TYPE_OBJECT 3 BULLET_HIT_TYPE_PLAYER_OBJECT 4
BULLET_HIT_NONE:
Good to use with the X,Y,Z coordonates, you can create an awesome Explosive Bullets for example.
BULLEY_HIT_PLAYER:
Good for making different things based on your creativity for example, you can make more damage bullets , or one shot bullets or anything you want.
BULLET_HIT_VEHICLE:
Is what we gonna use in this tutorial, also you can make different things as well here, it depends on your imagination.
BULLET_HIT_TYPE_OBJECT:
As said below, in the part of NONE section where i told you about Explosive Bullets , you can make them to remove an object that is in the radius of where palyer shoot
BULLET_HIT_TYPE_PLAYEROBJECT:
Cool feature, you can use this for example: making a DM Test for players, and they have to shoot different objects. so in this case, only they will see the objects and actual shoot them.
Why is this Callback awesome?
Because before if you wanted to ever do that, you had to use Camera Vectors to verify if player look at that object, but that would be inacurracy, but now is more precise i guess..
Now that I explained almost every single thing about this feature , lets actually get into the tutorial.
So we have this simple callback
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == 2) // verify if the player shoot an vehicle
{
new bool: isany_incar = false; // we use a boolean (true/false variable) to check if is anyone in car, and set this to false by default
for(new i = 0; i < MAX_PLAYERS; i++) // we go through a loop for all players
{
if(IsPlayerInVehicle(i, hitid)) // we verify if any player is in the shooted vehicle
{
isany_incar = true; // if a player is in vehicle , then we set our variable to false
break; // we break the loop , cause thats mean that a player have been found
}
}
if(isany_incar != true) // we check if the verify from below was false, is noone in the car
{
new Float: vHealth; // creating a float variable for getting vehicle health
GetVehicleHealth(hitid, vHealth); // getting the hitid vehicle
SetVehicleHealth(hitid, vhealth-40); // removing 100 from the vehicle health, its not necesary to be 100, you can make a system based on weapon cause unfortunately there is no damage paramater in this callback
}
}
return 1;
}
I want to say sorry if i have some mistakes (Im from Romania so my english is not that perfect yet...)
Also, if you know a easy way to do that , go ahead tell me , correct me if Im wrong cause I dont want to learn others wrong scripts.