Need help!
#1

I wanna prevent headshoting my teammates

i got headshot script but i can headshot my teammates too

CODE:
PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
    {
        new 
string[128], dead[24], killer[24];
        
GameTextForPlayer(issuerid"~r~Headshot!",3000,4); 
        
GetPlayerName(playeriddeadsizeof(dead)); 
        
GetPlayerName(issueridkillersizeof(killer));
        
format(stringsizeof(string), "{FFFF00}%s (%i) {FF0000}Popped {FFFF00}%s (%i) {FF0000}head with a Sniper Rifle"killerissueriddeadplayerid);
        
SendClientMessageToAll(COLOR_WHITEstring); 
        
SetPlayerHealth(playerid0.0);
    }
    return 
1;

Reply
#2

Check if the players are in the same team...
From what I remember you had gTeam[MAX_PLAYERS] array... So the code is:
PHP код:
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == && gTeam[playerid] != gTeam[issuerid])
    {
        new 
string[128], dead[24], killer[24];
        
GameTextForPlayer(issuerid"~r~Headshot!",3000,4); 
        
GetPlayerName(playeriddeadsizeof(dead)); 
        
GetPlayerName(issueridkillersizeof(killer));
        
format(stringsizeof(string), "{FFFF00}%s (%i) {FF0000}Popped {FFFF00}%s (%i) {FF0000}head with a Sniper Rifle"killerissueriddeadplayerid);
        
SendClientMessageToAll(COLOR_WHITEstring); 
        
SetPlayerHealth(playerid0.0);
    } 
Reply
#3

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Check if the players are in the same team...
From what I remember you had gTeam[MAX_PLAYERS] array... So the code is:
PHP код:
    if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == && gTeam[playerid] != gTeam[issuerid])
    {
        new 
string[128], dead[24], killer[24];
        
GameTextForPlayer(issuerid"~r~Headshot!",3000,4); 
        
GetPlayerName(playeriddeadsizeof(dead)); 
        
GetPlayerName(issueridkillersizeof(killer));
        
format(stringsizeof(string), "{FFFF00}%s (%i) {FF0000}Popped {FFFF00}%s (%i) {FF0000}head with a Sniper Rifle"killerissueriddeadplayerid);
        
SendClientMessageToAll(COLOR_WHITEstring); 
        
SetPlayerHealth(playerid0.0);
    } 
thx bro but i need one more help pls

i want to this to be open/close with key only but it's closing automatically

CODE :

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys 131072)
    {
        if(
IsPlayerInRangeOfPoint(playerid4.0, -1750.30103985.9364620.30861))
        {
            if(
IsObjectMoving(pddoor1)) return GameTextForPlayer(playerid"~w~please wait"10003);
            {   
                if(
gTeam[playerid] != GROVE) return SendClientMessage(playeridCOLOR_RED"You can't access this gate");
                {
                    
MoveObject(pddoor1, -1750.30103985.936464.388913.0);
                    
SetTimerEx("doorclose1"5000false"i"playerid);
                    
SendClientMessage(playeridCOLOR_GREEN"Gate Opening, It will close automatically after 5 seconds");
                    
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {33CC33}Opened\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
                }
            }
        }
    }
    return 
1;
}
forward doorclose1(playerid);
public 
doorclose1(playerid)
{
    
MoveObject(pddoor1, -1750.30103985.9364620.308613.0);
    
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {FF0000}Closed\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
    return 
1;

Reply
#4

Well, i think this can do the job:
PHP код:
//a global boolean variable. (Boolean = Can only have true/ false valories)
new bool:door_grove;
//And now the code looks like (well, should look)
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys 131072)
    {
        if(
IsPlayerInRangeOfPoint(playerid4.0, -1750.30103985.9364620.30861))
        {
            if(
IsObjectMoving(pddoor1)) return GameTextForPlayer(playerid"~w~please wait"10003);
            {   
                if(
gTeam[playerid] != GROVE) return SendClientMessage(playeridCOLOR_RED"You can't access this gate");
                {
                    new 
statuslabeltext[90];
                    if(!
door_grove)
                    {
                       
MoveObject(pddoor1, -1750.30103985.936464.388913.0);
                       
SendClientMessage(playeridCOLOR_GREEN"Gate Open! Use N to close it.");
                       
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {33CC33}Opened\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
                        
door_grove true
                        return 
1;                    
                    }
                    
MoveObject(pddoor1, -1750.30103985.9364620.308613.0);
                    
SendClientMessage(playeridCOLOR_GREEN"Gate Closed! Use N to open it");
                    
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {FF0000}Closed\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
                    
door_grove false;
                    return 
1;
                }
            }
        }
    }
    return 
1;

Reply
#5

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
Well, i think this can do the job:
PHP код:
//a global boolean variable. (Boolean = Can only have true/ false valories)
new bool:door_grove;
//And now the code looks like (well, should look)
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys 131072)
    {
        if(
IsPlayerInRangeOfPoint(playerid4.0, -1750.30103985.9364620.30861))
        {
            if(
IsObjectMoving(pddoor1)) return GameTextForPlayer(playerid"~w~please wait"10003);
            {   
                if(
gTeam[playerid] != GROVE) return SendClientMessage(playeridCOLOR_RED"You can't access this gate");
                {
                    new 
statuslabeltext[90];
                    if(!
door_grove)
                    {
                       
MoveObject(pddoor1, -1750.30103985.936464.388913.0);
                       
SendClientMessage(playeridCOLOR_GREEN"Gate Open! Use N to close it.");
                       
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {33CC33}Opened\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
                        
door_grove true
                        return 
1;                    
                    }
                    
MoveObject(pddoor1, -1750.30103985.9364620.308613.0);
                    
SendClientMessage(playeridCOLOR_GREEN"Gate Closed! Use N to open it");
                    
Update3DTextLabelText(pdlabel10xFFFFFFFF"{33CC33}=Grove=\n{FFFFFF}Gate Status: {FF0000}Closed\n{FFFFFF}Press {FF6600}N {FFFFFF}key");
                    
door_grove false;
                    return 
1;
                }
            }
        }
    }
    return 
1;

ERROR:

Код:
bare.pwn(274) : warning 203: symbol is never used: "status"
Reply
#6

You have a variable named status, which is not used... Search for status and remove it, ONLY if you think you don't need it.
Reply
#7

Quote:
Originally Posted by 10MIN
Посмотреть сообщение
You have a variable named status, which is not used... Search for status and remove it, ONLY if you think you don't need it.
that's in your code bro
Reply
#8

Ops. Now I realized... Remove it, is useless, also remove labeltext
Reply
#9

thanks bro <3 You're the best


-Solved
Reply
#10

@10MIN i wanna add this WANTED textdraw on onplayerdeath

here : https://sampforum.blast.hk/showthread.php?tid=579978

ik it's easy but i'm just started learning scripting so.. xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)