Key Press
#1

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new hits =0;
	if(IsPlayerInArea(playerid, 1728.8699,-1013.6041, 1699.0139,-1032.5679))
	{
	if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
	{
	SendClientMessage(playerid, COLOR_RED, "You are being warned. Donot fight in the party. Else you will be killed");
	hit[playerid] = 1;
	hits++;
	}
	}
	if(hit[playerid] == 1 &&(newkeys & KEY_FIRE) && (oldkeys & KEY_FIRE))
	{
	SetPlayerHealth(playerid, 0.0);
	}
	return 1;
}
Help me with this. i want to kill a player if he presses the fire key twice he must be killed.
Reply
#2

Your Problem is that you will set hit[playerid]=1; as soon as they press fire, then you right after test for it and kill them.
So instead use an else if.

You also/instead might want to disable players weapon.
SetPlayerArmedWeapon(playerid, 0); whenever they press, this way you don't need to worry too much about someone holding down fire.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new hits =0; //whats this for?
    if(IsPlayerInArea(playerid, 1728.8699,-1013.6041, 1699.0139,-1032.5679))
    {
    if(hit[playerid] == 1 &&(newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
    {
    SetPlayerHealth(playerid, 0.0);
    hit[playerid] = 0;
    }
    else if ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE))
    {
    SendClientMessage(playerid, COLOR_RED, "You are being warned. Donot fight in the party. Else you will be killed");
    SetPlayerArmedWeapon(playerid, 0);
    hit[playerid] = 1;
    hits++;
    }
    }
   
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)