HEADSHOT script won't work
#1

Hiye guys,

I have a script that works in another gamemode but not in the one I use now:

PHP код:
public OnPlayerTakeDamage playeridissueridFloat:amountweaponidbodypart ) {
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 3433 && bodypart == 9)
{
SetPlayerHealth(playerid0.0);
GameTextForPlayer(issuerid,"~g~HEADSHOT",2000,3);
GameTextForPlayer(playerid,"~r~HEAD~y~SHOT",2000,3);
}
    return 
1;

What's wrong?
Reply
#2

pawn Код:
weaponid == 34, 33
Shouldn't this be
pawn Код:
weaponid == 34 || weaponid == 33
Reply
#3

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
pawn Код:
weaponid == 34, 33
Shouldn't this be
pawn Код:
weaponid == 34 || weaponid == 33
Don't works.

Script:

PHP код:
new bodypart;
 
// I don't believe that's the sound ID for the sound you're looking for.
        
PlayerPlaySound(playerid178020.00.00.0);
        
PlayerPlaySound(issuerid178020.00.00.0);
    if(
gTeam[issuerid] == gTeam[playerid])
    {
           
GameTextForPlayer(issuerid,"~r~Don't attack your team mates!"30003);
    }
    if(
issuerid != INVALID_PLAYER_ID)
    {
          new 
str[26];
          
format(strsizeof(str),"-%.0f"amount);
          
SetPlayerChatBubble(playeridstr0xFF0000FF100.02000);
          
PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
    }
    if(
PlayerInfo[playerid][OnDuty] == || PlayerInfo[playerid][God] == 1)
    {
        
SetPlayerHealth(playerid1000.0);
        
GameTextForPlayer(issuerid,"~r~Don't attack admins on-duty!"30003);}
        if(
issuerid != INVALID_PLAYER_ID && weaponid == 34 || weaponid == 33 && bodypart == 9)
{
SetPlayerHealth(playerid0.0);
GameTextForPlayer(issuerid,"~g~HEADSHOT",2000,3);
GameTextForPlayer(playerid,"~r~HEAD~y~SHOT",2000,3);
}
    return 
1;

Reply
#4

why do you add a variable called "bodypart" ?.

the "headshot" worked in version 0.3z ? This parameter was added in version 0.3z if you use earlier versions do not will function"bodypart".
Reply
#5

The variable needs, or it gives undefined symbol. This is newest version
Reply
#6

If unsure about the order of operators, use brackets. That condition is most probably interpreted as:

pawn Код:
if((issuerid != INVALID_PLAYER_ID && weaponid == 34) || (weaponid == 33 && bodypart == 9))
Which means that this condition will be true if:
- the issuer is valid and uses weapon 34
OR
- the issuer uses weapon 33 to hit bodypart 9.

What you want is probably this:
pawn Код:
if(issuerid != INVALID_PLAYER_ID && (weaponid == 34 || weaponid == 33) && bodypart == 9)
Also got to love those "don't works" posts, without any explanation as to what exactly doesn't work.
Reply
#7

use it is only for sniper and rep me if i help you

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
 if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
 {
                if((weaponid == 34) && bodypart == 9)
                {
                    SetPlayerHealth(playerid, 0.0);
                    GameTextForPlayer(issuerid, "~r~Head shot!", 3000, 3);
                    GameTextForPlayer(playerid, "~r~Head shot!", 3000, 3);
                }
    else return PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
 }else {GameTextForPlayer(issuerid, "~w~don't shoot team mates", 3000, 3);}
 }
   return 0;
}
Reply
#8

Quote:
Originally Posted by Mijata
Посмотреть сообщение
use it is only for sniper and rep me if i help you

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid,bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
 if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
 {
                if((weaponid == 34) && bodypart == 9)
                {
                    SetPlayerHealth(playerid, 0.0);
                    GameTextForPlayer(issuerid, "~r~Head shot!", 3000, 3);
                    GameTextForPlayer(playerid, "~r~Head shot!", 3000, 3);
                }
    else return PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
 }else {GameTextForPlayer(issuerid, "~w~don't shoot team mates", 3000, 3);}
 }
   return 0;
}
+REPP!
Reply
#9

Just because you didn't define it, it doesn't mean using "new" will define it correctly.
What you did was just declaring a variable, that's set to 0 by default, and you don't change the value anywhere, that simply wont work.

As said on the wiki, you need to use #define to define the bodyparts manually, like this:
Quote:
#define BODY_PART_TORSO 3
#define BODY_PART_GROIN 4
#define BODY_PART_LEFT_ARM 5
#define BODY_PART_RIGHT_ARM 6
#define BODY_PART_LEFT_LEG 7
#define BODY_PART_RIGHT_LEG 8
#define BODY_PART_HEAD 9

Instead of declaring it with "new".
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)