[Tutorial] Blood in screen and damage amount when shot by a player
#1

Hi, this is a pretty simple tutorial, but I've seen some people that doesn't know how to display blood in the screen of a player when that player gets shot by someone and how to display the damage amount on screen.

You don't need to create a red textdraw to show blood in the screen when a player receives a shot, you just have to do:

pawn Code:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)//This callback is called when a player gives damage to another player.
{
    new st[16];//We create a string
    format(st, sizeof(st), "~r~-%.0f", amount);//we give a format to the string created above basedo on the damage amount given with a red color ~r~
    GameTextForPlayer(damagedid, st, 2000, 5);//we show a game text showing the damage to the damagedid for 2 seconds.
    new Float:Pos[3];//We create 3 variables to store the player position X, Y, Z
    GetPlayerPos(damagedid, Pos[0], Pos[1], Pos[2]);//We store the player position in the variables created above
    CreatePlayerObject(damagedid, 18668, Pos[0], Pos[1], Pos[2]-0.4, 0.0, 0.0, 96.0);//We show the object 18668(blood_heli) to the player who received the shot
    return 1;
}
Reply
#2

Great ! Thanks (repped)
Reply
#3

Can the others see this?
Reply
#4

Quote:
Originally Posted by Awide
View Post
Can the others see this?
They are not supposed to, it means that if someone fires at you, that blood object will come up in your screen, making you know that you were shot for example?, the same thing with the damage amount.
Reply
#5

There is an issue with this just because OnPlayerWeaponShot() is called does not mean the player was actually shot on their screen (with stock damage system). You would need to actually implement a skinhit system for this to be effective just use OnPlayerTakeDamage() instead.
Reply
#6

Quote:
Originally Posted by ThePhenix
View Post
They are not supposed to, it means that if someone fires at you, that blood object will come up in your screen, making you know that you were shot for example?, the same thing with the damage amount.
Ah I didn't realize it's a player object. Good idea! ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)