Headshot
#1

I need a headshot codes, in onplayertakedamage, Not a fs, pls gimme a working and kindly tell is this correct section to ask for a script?
Reply
#2

http://forum.sa-mp.com/showthread.ph...7813&page=1334
Reply
#3

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    
// check if there was a shooter, weaponID was 34(Sniper) and bodypart was 9(Head)
    
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
            
// checks if both players have same team, except NO_TEAM. if not procced, otherwise send error message
//*A edit by our genius friend sickattack
            
if(GetPlayerTeam(issuerid) | GetPlayerTeam(playerid) == NO_TEAM || GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
            {
//check if player is dead... if not proceed(by Gammix)
                
if (GetPlayerState(playerid) != PLAYER_STATE_WASTED)
                {
                    
//variables, first one to format the message, second and third contain player names.
                    
new headmsg[128], dead[24], killer[24];
                    
//on player's screen we show him a message for 3 seconds "HeadShot"
                    
GameTextForPlayer(playerid"~r~Headshoted! ~n~~Y~TASTE ~B~YOUR ~G~ASS",3000,4);
                    
// same to issuer's screen
                    
GameTextForPlayer(issuerid"~r~Headshot!",3000,4);
                    
// we get the victims name with this function and store it into our previously made variable "dead";
                    
GetPlayerName(playeriddeadsizeof(dead));
                    
// we get the victims name with this function and store it into our previously made variable "killer";
                    
GetPlayerName(issueridkillersizeof(killer));
                    
//format the message, means we put that text into "headmsg".
                    
format(headmsgsizeof(headmsg), "[News] {FFDC2E}%s(%i) has been killed in a headshot by %s(%i) and got +200$!",deadplayeridkiller,issuerid);
                    
// once we've formatted the message we're ready to send the message to all players!
                    
SendClientMessageToAll(0xAA3333AAheadmsg);
                    
// Give him so money as a reward
                    
GivePlayerMoney(issuerid,200);
                    
//kill the player
                    
SetPlayerHealth(playerid0.0);
                    
//and tell the server that he's dead!
                
}
            }
            else
            
SendClientMessage(issuerid0xf8f8f8fff"ERROR: {FFFFFF}That player is in your team!");
    }
    
PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
    return 
1;

Credits goes to iLearner firstly.
Reply
#4

Quote:
Originally Posted by RxErT
Посмотреть сообщение
PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    
// check if there was a shooter, weaponID was 34(Sniper) and bodypart was 9(Head)
    
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
            
// checks if both players have same team, except NO_TEAM. if not procced, otherwise send error message
//*A edit by our genius friend sickattack
            
if(GetPlayerTeam(issuerid) | GetPlayerTeam(playerid) == NO_TEAM || GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
            {
//check if player is dead... if not proceed(by Gammix)
                
if (GetPlayerState(playerid) != PLAYER_STATE_WASTED)
                {
                    
//variables, first one to format the message, second and third contain player names.
                    
new headmsg[128], dead[24], killer[24];
                    
//on player's screen we show him a message for 3 seconds "HeadShot"
                    
GameTextForPlayer(playerid"~r~Headshoted! ~n~~Y~TASTE ~B~YOUR ~G~ASS",3000,4);
                    
// same to issuer's screen
                    
GameTextForPlayer(issuerid"~r~Headshot!",3000,4);
                    
// we get the victims name with this function and store it into our previously made variable "dead";
                    
GetPlayerName(playeriddeadsizeof(dead));
                    
// we get the victims name with this function and store it into our previously made variable "killer";
                    
GetPlayerName(issueridkillersizeof(killer));
                    
//format the message, means we put that text into "headmsg".
                    
format(headmsgsizeof(headmsg), "[News] {FFDC2E}%s(%i) has been killed in a headshot by %s(%i) and got +200$!",deadplayeridkiller,issuerid);
                    
// once we've formatted the message we're ready to send the message to all players!
                    
SendClientMessageToAll(0xAA3333AAheadmsg);
                    
// Give him so money as a reward
                    
GivePlayerMoney(issuerid,200);
                    
//kill the player
                    
SetPlayerHealth(playerid0.0);
                    
//and tell the server that he's dead!
                
}
            }
            else
            
SendClientMessage(issuerid0xf8f8f8fff"ERROR: {FFFFFF}That player is in your team!");
    }
    
PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
    return 
1;

Credits goes to iLearner firstly.
Brother It's not working for me, Nothing is happening!, Just health going down as normal :/
Reply
#5

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID) // Check if the player taking the damage didn't just take damage from other sources
    {
        if(bodypart == 9 && weaponid == 34) // Check if it was the head that was shot and he was also shot with a sniper.. change 34 to weapon of ur choice
        {
            if(GetPlayerState(playerid) == PLAYER_STATE_SPAWNED) // Check if the player is actually spawned..
            {
                SetPlayerHealth(playerid, 0.00); // Kill the player
                GameTextForPlayer(playerid, "HEAD SHOT!", 1000, 2); // Just aesthetics
                GameTextForPlayer(issuerid, "HEAD SHOT!", 1000, 2); // Just aesthetics
            }
        }
    }
}
Reply
#6

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID && (weaponid == 24 || weaponid == 34) && bodypart == 9)
    {
             new 
string[100], headshota[24], pname[24];
             
GetPlayerName(playeridheadshotasizeof(headshota));
             
GetPlayerName(issueridpnamesizeof(pname));
             
format(stringsizeof(string), "%s(%i) was shoot to the head by %s(%i)"headshota,playeridpname);
             
SendClientMessageToAll(COLOR_SILVER,string);
             
GameTextForPlayer(issuerid,"~r~Headshot",2000,3);
             
PlayerPlaySound(issuerid178020.00.00.0);
             
GameTextForPlayer(playerid,"~r~Headshot",2000,3);
             
PlayerPlaySound(playerid178020.00.00.0);
             
SetPlayerHealth(playerid0.0);
    }
    return 
1;

try this maybe gonna work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)