OnPlayerTakeDamage question
#1

My question might sound noobish, but I've been trying to work this problem out, testing it but the result is negative, It doesn't work, I'm trying to make like a system when-ever you get hit by a sniper you will get killed automatically

Code
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
   
        if(weaponid == 34 && pInfo[issuerid][pVIP] >= 2)
        {
            SetPlayerHealth(playerid, 0);
            GameTextForPlayer(issuerid, "Sniper Kill!", 2600, 4);
        }
    }
    return 1;
}
When I press KEY_FIRE, the bullet hits me but it doesn't kill me or the player even though my sniper scope is aiming towards the target
Reply
#2

I made something for you, test this out and tell me if it works(It should):
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
        new Float:HP;
        GetPlayerHealth(playerid, HP);
        if(weaponid == 34 && pInfo[issuerid][pVIP] >= 2) SetPlayerHealth(playerid, HP-200);
        GameTextForPlayer(issuerid, "Sniper Kill!", 2600, 4);
        PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
        return 1;
}
Reply
#3

@JimmyCh It Doesn't work.

PS: Uploading a video to show you what really happen, Also when I get punch I automatically die, the system works if you're punching not scoping someone.
Reply
#4

Did you make sure the issuer's VIP level is higher or equal than 2? Also, here's my OnPlayerTakeDamage from a DM server I did a couple of weeks ago:

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(weaponid == 34)
        {
            SetPlayerHealth(playerid, 0.0); // comparing mine and your code, I have this as a float, you don't.. try that.. crazy answer but might work.
        }
        new string[200];
        GetPlayerName(issuerid, sendername, sizeof(sendername));
        GetPlayerName(playerid, receivername, sizeof(receivername));
        format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~r~SHOT BY ~w~%s~n~~y~HP -%.0f", sendername, amount);
        GameTextForPlayer(playerid, string, 1750, 3);
        format(string, sizeof(string), "~n~~n~~n~~n~~n~~n~~n~~g~HIT ~w~%s~n~~y~HP -%.0f", receivername, amount);
        GameTextForPlayer(issuerid, string, 1750, 3);
    }
    return 1;
}
You might wanna use some cool stuff in there , it includes the fact that it will kill someone if the weapon was a sniper.
Reply
#5

@DanishHaq - Ofcourse I did make sure that the issuer's VIP level is higher than 2 or equals to 2.

Here's the video to show what's happening when you shoot a sniper, and it hits you not the target, but it doesn't kill you tho.

Link: http://www.youtube.com/watch?v=EOeFY...ature=*********

PS: @DanishHaq - I tried your code and it is still the same for some reason
Reply
#6

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
       
        if((GetPlayerWeapon(playerid)==34)&& pInfo[issuerid][pVIP] >= 2)
        {
            SetPlayerHealth(playerid, 0);
            GameTextForPlayer(issuerid, "Sniper Kill!", 2600, 4);
        }
    }
    return 1;
}
Reply
#7

A possible error could be that you have both OnPlayerTakeDamage and OnPlayerGiveDamage in your code. Remove the OnPlayerGiveDamage if you have it, it'll probably be before the OnPlayerTakeDamage.
Reply
#8

GoldZoroGrab Thanks it worked bro :P
DanishHaq Thanks for trying bro, but alteast you tried :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)