[Include] Cops
#1

COPS

current version (v1.0)

This include creates cop ai, they will kill anyone who is wanted, they can detect crimes like if player shoot, if player damage other player or a cop, if player killed someone, however for now they only follow wanted players otherwise they just stand, and they cant drive (will add later), no melee support yet.
How to include:

Code:
#define FILTERSCRIPT 
#include <a_samp>
#include <fcnpc>
#include <cops> //requires fcnpc 2.0.0
Crime types:

Code:
CRIME_KILL 0 //called only if you kill players, for cops use oncopdeath
CRIME_SHOOT 1 
CRIME_DAMAGE 2 //called only if you shoot players, for cops use oncoptakedamage
Functions:

Code:
native CreateCop(skinid, name[], Float:detection_area, Float:health, Float:x, Float:y, Float:z, Float:angle, weapon, Float:accuracy);
native IsCopDead(cop_id);
native IsCopInvulnerable(cop_id);
native IsCopMoving(cop_id);
native IsCopValid(cop_id);
native GetCopHealth(cop_id);
native GetCopTarget(cop_id);
native GetClosestPlayerToCop(cop_id);
native GetCopDetectionArea(cop_id);
native GetCopPos(cop_id, &Float:x, &Float:y, &Float:z);
native GetCopAngle(cop_id, &Float:angle);
native GetCopCreationPos(cop_id, &Float:x, &Float:y, &Float:z);
native GetCopCreationAngle(cop_id, &Float:angle);
native GetCopInterior(cop_id);
native GetCopVirtualWorld(cop_id);
native GetCopSkin(cop_id);
native GetCopCustomSkin(cop_id);
native GetCopWeapon(cop_id);
native SetCopWeapon(cop_id, weaponid);
native SetCopInvulnerable(cop_id, bool:invulnerable);
native SetCopSkin(cop_id, skinid);
native SetCopInterior(cop_id, interiorid);
native SetCopVirtualWorld(cop_id, worldid);
native SetCopHealth(cop_id, Float:health);
native RespawnCop(cop_id);
native DestroyCop(cop_id);
Callbacks:

Code:
OnCopDeath(cop_id, killerid, weaponid);
OnCopTakeDamage(cop_id, damagerid, weaponid, bodypart, Float:health_loss);
OnCopKillPlayer(cop_id, playerid);
OnCrimeHappenNearCop(playerid, crime);
Example:

PHP Code:
#define FILTERSCRIPT
#include <a_samp>
#include <fcnpc>
#include <cops>
#include <zcmd>
new cop;
CMD:cop(playerid)
{
    new 
Float:xFloat:yFloat:z;
    if(!
IsCopValid(cop)) //you could do without the check as well the include checks if cop allready exist
    
{
        
GetPlayerPos(playeridxyz);
        
cop CreateCop(284"Cop01"45.0100.0x+4yz, -1221.0);
    }
    return 
1;
}
CMD:dcop(playerid)
{
    if(
IsCopValid(cop)) //could do without the check as well
    
{
        
DestroyCop(cop);
    }
    return 
1;
}
public 
OnCrimeHappenNearCop(playeridcrime)
{
    switch(
crime)
    {
        case 
CRIME_KILL:
        {
            if(
GetPlayerWantedLevel(playerid) < 5)
            {
                
SetPlayerWantedLevel(playerid5);
            }
        }
        case 
CRIME_SHOOT:
        {
            if(
GetPlayerWantedLevel(playerid) < 2)
            {
                
SetPlayerWantedLevel(playerid2);
            }
        }
        case 
CRIME_DAMAGE:
        {
            if(
GetPlayerWantedLevel(playerid) < 3)
            {
                
SetPlayerWantedLevel(playerid3);
            }
        }
    }
    return 
1;
}
public 
OnCopKillPlayer(cop_idplayerid)
{
    if(
GetPlayerWantedLevel(playerid) > 1)
    {
        
SetPlayerWantedLevel(playerid0);
    }
    return 
1;

Video: Click here

Download: Click here

requires:

fcnpc 2.0.0


Bugs:

If you find any bugs please report them and i will fix them in the next update!


Credits:

SA-MP team - a_samp
ZIGGI - fcnpc
Lokii - cops
Pottus - colandreas & optimizing
Crayder - colandreas
Reply


Messages In This Thread
Cops AI - by Lokii - 23.01.2019, 15:00
Re: Cops - by Pottus - 23.01.2019, 15:34
Re: Cops - by Lokii - 23.01.2019, 15:51
Re: Cops - by Hazon - 23.01.2019, 18:27
Re: Cops - by Lokii - 23.01.2019, 18:45
Re: Cops - by Lucky13 - 23.01.2019, 19:27
Re: Cops - by Lokii - 23.01.2019, 19:28
Re: Cops - by N0FeaR - 23.01.2019, 20:24
Re: Cops - by Lokii - 23.01.2019, 20:27
Re: Cops - by Pottus - 24.01.2019, 18:05
Re: Cops - by Lokii - 25.01.2019, 15:53
Re: Cops - by codExpert - 25.01.2019, 16:01
Re: Cops - by Lokii - 25.01.2019, 16:05
Re: Cops - by Pottus - 25.01.2019, 20:26
Re: Cops - by Lokii - 25.01.2019, 20:33
Re: Cops - by Lokii - 28.01.2019, 12:55

Forum Jump:


Users browsing this thread: 1 Guest(s)