OnPlayerWeaponShot message - 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)
+--- Thread: OnPlayerWeaponShot message (
/showthread.php?tid=570823)
OnPlayerWeaponShot message -
DavidSparks - 13.04.2015
Hello guys so I am scripting a system so when you fire for example a Shotgun then the police will get an automatic warning, you know like neighbours calls the police.
So the system works fine but I have one problem, when the players fires the gun they of course dont fire one shot. Its multiple shots and it spams the police officers chats..
So how can I make it so only one message is sent?
Re: OnPlayerWeaponShot message - Emmet_ - 13.04.2015
Timestamps.
pawn Код:
new g_FiredTime[MAX_PLAYERS];
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if ((gettime() - g_FiredTime[playerid]) > 60)
{
// alert cops
g_FiredTime[playerid] = gettime();
}
return 1;
}
Make sure you clear the variable upon connection:
pawn Код:
public OnPlayerConnect(playerid)
{
g_FiredTime[playerid] = 0;
}
This will only send the warning every 60 seconds a player is shooting. Change "60" to your time.
Re: OnPlayerWeaponShot message -
DavidSparks - 13.04.2015
Quote:
Originally Posted by Emmet_
Timestamps.
pawn Код:
new g_FiredTime[MAX_PLAYERS];
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ) { if ((gettime() - g_FiredTime[playerid]) > 60) { // alert cops
g_FiredTime[playerid] = gettime(); } return 1; }
Make sure you clear the variable upon connection:
pawn Код:
public OnPlayerConnect(playerid) { g_FiredTime[playerid] = 0; }
This will only send the warning every 60 seconds a player is shooting. Change "60" to your time.
|
Thanks man! I was thinking of something like this but I've never made a timestamp :3
+rep