Bite system
#1

Hi Every one i tried to make bite system no error but script i mean Bite System does't work
Check
Код:
#define KEY_AIM (128)
then
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new Float:health;
 	if(newkeys & KEY_AIM)
    {
        if(gTeam[playerid] == TEAM_ZOMBIES)
        {
            new victimid = GetClosestPlayer(playerid);
            GetPlayerHealth(victimid, health);
            if(gTeam[victimid] == TEAM_HUMANS)
            {
                if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
                {
	    			SetPlayerHealth(victimid, health - 6.0);
    				GameTextForPlayer(victimid, "~p~Biten", 1000, 3);
    				PlayerPlaySound(playerid, 1136, 0, 0, 0);
       				PlayerPlaySound(victimid, 1136, 0, 0, 0);
                }
            }
        }
    }
	return 1;
}
Reply
#2

One if statement was mismatched. newkeys == KEY_AIM should be there. Use the code below.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:health;
    if(newkeys == KEY_AIM) // This was the error here.
       {
        if(gTeam[playerid] == TEAM_ZOMBIES)
        {
            new victimid = GetClosestPlayer(playerid);
            GetPlayerHealth(victimid, health);
            if(gTeam[victimid] == TEAM_HUMANS)
            {
                if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
                {
                    SetPlayerHealth(victimid, health - 6.0);
                    GameTextForPlayer(victimid, "~p~Biten", 1000, 3);
                    PlayerPlaySound(playerid, 1136, 0, 0, 0);
                    PlayerPlaySound(victimid, 1136, 0, 0, 0);
                }
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
One if statement was mismatched. newkeys == KEY_AIM should be there. Use the code below.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:health;
    if(newkeys == KEY_AIM) // This was the error here.
       {
        if(gTeam[playerid] == TEAM_ZOMBIES)
        {
            new victimid = GetClosestPlayer(playerid);
            GetPlayerHealth(victimid, health);
            if(gTeam[victimid] == TEAM_HUMANS)
            {
                if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
                {
                    SetPlayerHealth(victimid, health - 6.0);
                    GameTextForPlayer(victimid, "~p~Biten", 1000, 3);
                    PlayerPlaySound(playerid, 1136, 0, 0, 0);
                    PlayerPlaySound(victimid, 1136, 0, 0, 0);
                }
            }
        }
    }
    return 1;
}
Does't work :\
Reply
#4

Quote:
Originally Posted by [D]ry[D]esert
Посмотреть сообщение
Does't work :\
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:health;
    if(newkeys == KEY_AIM) // This was the error here.
       {
        if(gTeam[playerid] == TEAM_ZOMBIES)
        {
            new victimid = GetClosestPlayer(playerid);
            GetPlayerHealth(victimid, health);
            if(gTeam[victimid] == TEAM_HUMANS)
            {
                if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
                {
                    SetPlayerHealth(victimid, health - 6.0);
                    GameTextForPlayer(victimid, "~p~Biten", 1000, 3);
                    PlayerPlaySound(playerid, 1136, 0, 0, 0);
                    PlayerPlaySound(victimid, 1136, 0, 0, 0);
                }
            }
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
One if statement was mismatched. newkeys == KEY_AIM should be there. Use the code below.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:health;
    if(newkeys == KEY_AIM) // This was the error here.
       {
        if(gTeam[playerid] == TEAM_ZOMBIES)
        {
            new victimid = GetClosestPlayer(playerid);
            GetPlayerHealth(victimid, health);
            if(gTeam[victimid] == TEAM_HUMANS)
            {
                if(GetDistanceBetweenPlayers(playerid,victimid) < 2)
                {
                    SetPlayerHealth(victimid, health - 6.0);
                    GameTextForPlayer(victimid, "~p~Biten", 1000, 3);
                    PlayerPlaySound(playerid, 1136, 0, 0, 0);
                    PlayerPlaySound(victimid, 1136, 0, 0, 0);
                }
            }
        }
    }
    return 1;
}
Wrong. Newkeys contains every key that's being pressed by the player. == will work if the only key that is being pressed by the player is that key, but & will work if the key is even one of the keys the player is pressing.

As for the poster, you could try using GetPlayerTargetPlayer which was added in 0.3d instead of GetClosestPlayer and try increasing the distance required between the players to about 3.
Reply
#6

Quote:
Originally Posted by SuperViper
Посмотреть сообщение
Wrong. Newkeys contains every key that's being pressed by the player. == will work if the only key that is being pressed by the player is that key, but & will work if the key is even one of the keys the player is pressing.

As for the poster, you could try using GetPlayerTargetPlayer which was added in 0.3d instead of GetClosestPlayer and try increasing the distance required between the players to about 3.
Allright. Thanks for the knowledge. I will keep that in mind. Can you give us the right and correct code for this?

Will help me to learn the usage of OnPlayerKeyStateChange. (3 Rep points added to SuperViper)
Reply
#7

what? newkeys is affected on everyone Keyboard button? i have "JUMP_KEY" and it"The script/code" only works with jump key..
Reply
#8

Multiple keys pressed at the same time will still be saved in that single variable. Hence, pressing sprint and jump simultaneously will produce a different value than pressing either sprint or jump.
Reply
#9

So pressing Sprint and jump both at once won't work? it does for me...
Reply
#10

So someone can please fix the code above? Even i want to know what will be the correct code lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)