SA-MP Forums Archive
OnPlayerWeaponShot Help? - 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 Help? (/showthread.php?tid=639975)



OnPlayerWeaponShot Help? - RedRex - 26.08.2017

Hi. I need your help with OnPlayerWeaponShot How to i can create a When Player Take 1shot From Warrent the Cops cannot arrest him if he were wanted +4star. How to do that? I've adding this but when I push him i'll got +4 but i dont want Like this

Example: YOU CANNOT ARREST THIS PLAYER BECAUSE HE SHOOTING YOU!! Do you know what i mean? If a warrent shooted cops and the cop need arrest him Make it Cannot How?


PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ

    if(
hittype == BULLET_HIT_TYPE_PLAYER
    { 
        if(
gTeam[hitid] == IsPlayerACop
        { 
            
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);  
        } 
    } 
    return 
1




Re: OnPlayerWeaponShot Help? - RedRex - 26.08.2017

Is there any help?


Re: OnPlayerWeaponShot Help? - aoky - 27.08.2017

On the top of your script add:
PHP код:
new CannotArrest[MAX_PLAYERS]; 
PHP код:
    if(gTeam[playerid] != IsPlayerACop)
    {
        if(
GetPlayerWantedLevel(hitid) == 4)
        {
            
SendClientMessage(playerid, -1"You cannot shoot this player as his wanted level is greater than 4.);
            CannotArrest[hitid] = 1;
            return 0;
        }
    } 
In your /arrest command add so he can only be arrested if CannotArrest = 0.


Re: OnPlayerWeaponShot Help? - RedRex - 27.08.2017

Sit in not mean to cops cannot shot wanted level 4 I mean

If a player wanted lecel+4 and heek shoot the cops the policeMan cannot arrest because he took damage how to do that
Thanks for reply


Re: OnPlayerWeaponShot Help? - Kane - 27.08.2017

Just check with your arrest command if the player has 4 wanted levels he she cannot be arrested...


Re: OnPlayerWeaponShot Help? - RedRex - 27.08.2017

XD That's my problem i dont know how to do that!!


Re: OnPlayerWeaponShot Help? - aoky - 27.08.2017

No problem, just do this.

On the top of your script add:
PHP код:
new CriminalDamage[MAX_PLAYERS]; 
PHP код:
    if(gTeam[playerid] != IsPlayerACop)
    {
        if(
GetPlayerWantedLevel(playerid) == 4)
        {
            
SendClientMessage(playerid, -1"You shot this police officer, he can no longer arrest you as your wanted level is 4.");
            
CriminalDamage[hitid] = 1;
            return 
0;
        }
    } 
In your /arrest command add this:
PHP код:
CMD:arrest
{
if(
CriminalDamage[playerid] > 0) return SendClientMessage(playerid, -1"You may not arrest this player as you took damage from a wanted suspect who had a wanted level of 4.");

Make a timer etc to remove the global variable.


Re: OnPlayerWeaponShot Help? - RedRex - 27.08.2017

A Error:

Код:
error 076: syntax error in the expression, or invalid function call

if(gTeam[playerid] != IsPlayerACop)



Re: OnPlayerWeaponShot Help? - aoky - 27.08.2017

Can you show the code for IsPlayerACop


Re: OnPlayerWeaponShot Help? - RedRex - 27.08.2017

This!
Код:
stock IsPlayerACop(skinid)
{
	// includes corrupt cops from singleplayer, SWAT, FBI and Army skin and 0.3.7 cop ones
	switch(skinid)
	{
		case 265..267, 280..288, 300..302, 306, 307, 309..311: return 1;
	    default: return 0;
	}

	return 0;
}