10-15-2017, 05:43 PM
(This post was last modified: 10-15-2017, 05:47 PM by [Ds]PwN3R_B0T Edited 2 times in total.)
very good suggestion and idea 
There is only one critical thing about it:
I think we all agree, that global timers, which CONSTANTLY run can cause laggs, when the server uses many OTHER timers..
You can get the same result without ANY timer (but I think you knew that too)
Another advantage with THIS version, is that he ALREADY gets punished when he even TRIES to get in (not when he does the animation - reached the door)
Edited code:

There is only one critical thing about it:
I think we all agree, that global timers, which CONSTANTLY run can cause laggs, when the server uses many OTHER timers..
You can get the same result without ANY timer (but I think you knew that too)
Another advantage with THIS version, is that he ALREADY gets punished when he even TRIES to get in (not when he does the animation - reached the door)
Edited code:
Code:
#include <a_samp>
#define HIT_TIME 10 //Seconds: Can be increased as dev's wish.
new
MadeWeaponShot[MAX_PLAYERS],
TookDamage[MAX_PLAYERS];
main(){}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsInFight(playerid))
{
ClearAnimations(playerid); // clear the animations
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
SetPlayerPos(playerid, pos[0], pos[1], pos[2] + 3); // Just making sure that player is stunned.
SendClientMessage(playerid, 0xff9900FF, "** You can't enter in a car while you are in a fight or fired a weapon!");
}
return 1;
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
MadeWeaponShot[playerid] = gettime(); // Saving it in a variable
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
TookDamage[playerid] = gettime(); // Saving it in a variable
}
return 1;
}
stock IsInFight(playerid) // to check as if player is in fight or not
{
if(gettime() - MadeWeaponShot[playerid] < HIT_TIME) return 1;
if(gettime() - TookDamage[playerid] < HIT_TIME) return 1;
return 0;
}