They are both calling from id 10 which isn't good.
My OnPlayerKeyStateChange does do some checks for each of them before creating the pickups.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new string[128], wid;
new SarahNPC = GetPlayerIDFromName ("Sarah");
new JadeNPC = GetPlayerIDFromName ("Jade");
new Float:SarahX, Float:SarahY, Float:SarahZ;
new Float:JadeX, Float:JadeY, Float:JadeZ;
wid = GetPlayerWeapon(playerid);
GetPlayerPos(SarahNPC, SarahX, SarahY, SarahZ);
GetPlayerPos(JadeNPC, JadeX, JadeY, JadeZ);
if(IsPlayerInRangeOfPoint(playerid, 10, SarahX, SarahY, SarahZ) && gTeam[playerid] == TEAM_CIVILIAN && wid > 10)
{
if(PRESSED(KEY_HANDBRAKE))
{
if(IsPlayerFacingPlayer(playerid, SarahNPC, 10) == 1 && SarahNPCHandsUp == 0 && SarahHasBeenRobbed == 0)
{
ClearAnimations(SarahNPC);
SarahNPCHandsUp = 1;
SarahHasBeenRobbed = 1;
SetTimer("ResetCPDNPC", 300000, 0);
ApplyAnimation(SarahNPC, "ped", "handsup", 3.0, 0, 0, 0, 1, 0);
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
CashPickupForSarah = CreatePickup(1212, 2, 500.1288, -76.0403, 998.7578, -1);
SetPlayerChatBubble(SarahNPC, "Eeek, take the money!", 0xFFFFFFAA, 50, 5000);
format(string, sizeof (string), "Crime committed: Robbery. Wanted Level: %d.", GetPlayerWantedLevel(playerid));
SendClientMessage(playerid, COLOR_SERVER2, string);
return 1;
}
}
else if(RELEASED(KEY_HANDBRAKE))
{
if(IsPlayerFacingPlayer(playerid, SarahNPC, 10) == 1 && SarahHasBeenRobbed == 1 && SarahHiding == 0)
{
ClearAnimations(SarahNPC);
SarahNPCHandsUp = 0;
SarahHiding = 1;
ApplyAnimation(SarahNPC, "ON_LOOKERS", "panic_hide", 3.0, 1, 0, 0, 1, 0);
return 1;
}
}
}
else if(IsPlayerInRangeOfPoint(playerid, 10, JadeX, JadeY, JadeZ) && gTeam[playerid] == TEAM_CIVILIAN && wid > 10)
{
if(PRESSED(KEY_HANDBRAKE))
{
if(IsPlayerFacingPlayer(playerid, JadeNPC, 10) == 1 && JadeNPCHandsUp == 0 && JadeHasBeenRobbed == 0)
{
ClearAnimations(JadeNPC);
JadeNPCHandsUp = 1;
JadeHasBeenRobbed = 1;
SetTimer("ResetCPDNPC", 300000, 0);
ApplyAnimation(JadeNPC, "ped", "handsup", 3.0, 0, 0, 0, 1, 0);
SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
JadeCashPickup = CreatePickup(1212, 2, 208.2593, -100.4875, 1005.2578, -1);
SetPlayerChatBubble(JadeNPC, "Eeek, take the money!", 0xFFFFFFAA, 50, 5000);
format(string, sizeof (string), "Crime committed: Robbery. Wanted Level: %d.", GetPlayerWantedLevel(playerid));
SendClientMessage(playerid, COLOR_SERVER2, string);
return 1;
}
}
else if(RELEASED(KEY_HANDBRAKE))
{
if(IsPlayerFacingPlayer(playerid, JadeNPC, 10) == 1 && JadeHasBeenRobbed == 1 && JadeHiding == 0)
{
ClearAnimations(JadeNPC);
JadeNPCHandsUp = 0;
JadeHiding = 1;
ApplyAnimation(JadeNPC, "ON_LOOKERS", "panic_hide", 3.0, 1, 0, 0, 1, 0);
return 1;
}
}
}
return 1;
}