Headshot System Help
#1

I want to make this headshot system, so example:
when i shoot a player it should show:

Areeb has been shoot by XBoss30 to the head and XBoss30 has earned $100

here is my code:

On top of the script
new headshot[MAX_PLAYERS];

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID)
    {
        if(
IsPlayerConnected(issuerid))
        {
            if(
bodypart == 9)
            {
                
SetPlayerHealth(playerid0.0);
                new 
string[100];
                
GetPlayerName(playeridheadshotsizeof(headshot));
                
format(stringsizeof(string), "%s was shoot to the head by %d and %d has earned $100"headshotissuerid);
                
GivePlayerMoney(issuerid100);
                
SendClientMessageToAll(COLOR_RED,string);
                
GameTextForPlayer(issuerid,"~r~Headshot",2000,3);
                
PlayerPlaySound(issuerid178020.00.00.0);
                
GameTextForPlayer(playerid,"~r~Headshot",2000,3);
                
PlayerPlaySound(playerid178020.00.00.0);
                
            }
        }
    }
    return 
1;

Reply
#2

PHP код:
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponidbodypart

    if(
issuerid != INVALID_PLAYER_ID && bodypart == 9
    {     
        new 
string[100], headshot[24], pname[24]; 
        
GetPlayerName(playeridheadshotsizeof(headshot));
        
GetPlayerName(issueridpname sizeof(pname));    
        
format(stringsizeof(string), "%s(%i) was shoot to the head by %s(%i) and %d has earned $100"headshot,playeridpnameissuerid); 
        
GivePlayerMoney(issuerid100); 
        
SendClientMessageToAll(COLOR_RED,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

Some touch ups, though its recommended to check that playerid is not dead.
Reply
#3

Thanks
Reply
#4

you can do some checks in one line as well, also you can make the money amount random.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)