SA-MP Forums Archive
Two questions.. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Two questions.. (/showthread.php?tid=125536)



Two questions.. - IVuljak - 04.02.2010

[b]Is it possible to detect with what weapons is player shot?
If yes, how?

WeA


Re: Two questions.. - ettans - 04.02.2010

Shot? No. Killed? Yes.

pawn Код:
OnPlayerDeath(playerid,killerid,reason)
{
  if(reason == 31) // M4
    return 31;

  return 1;
}
https://sampwiki.blast.hk/wiki/Weapons


Re: Two questions.. - mansonh - 04.02.2010

You can't detect when a player gets shot, (well not easily or accurately) there are some functions out there.


You can make a system to detect when a player fires a weapon(again not accurately);
The problem is people can tap their fire button, not actually firing any bullets.

pawn Код:
public OnPlayerUpdate(playerid)
{
  new keys, ud, lr, wpnid = GetPlayerWeapon(playerid);
  GetPlayerKeys(playerid, keys, ud, lr);
  //player on foot, pressing fire, holding a "firing" weapon
  if( GetPlayerState == PLAYER_STATE_ONFOOT && keys & KEY_FIRE && wpnid > 22 && wpnid < 38)
  {
     //player has fired weapon or is about to
  }
}