Near Cops
#2

This might be caused by a too high range: 2- if a civlian shoots he gets wanted level too even if there's no cop

KK, changed some stuff, but overall it looka like it should work:

PHP Code:
if(GetTeam(playerid) == CLASS_CIV || GetTeam(playerid) == CLASS_MEDIC)
{
    if(
IsPlayerNearLawEnforcement(playerid) && GetPlayerWantedLevel(playerid) < 6
    { 
        
shotsfired[playerid] ++; 
        if(
shotsfired[playerid] >= 2
        { 
            new 
msg[128], ID
            
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 1); 
            
format(msgsizeof(msg), "Comitted A Crime: Shooting in public - Wanted Level %d"GetPlayerWantedLevel(playerid)); 
            
SendClientMessage(playeridCOLOR_WANTEDmsg); 
            
//Decide for one way, either use var++, var = var + 1 or var += 1;
            
pInfo[playerid][pCrimes] ++; 
            
pInfo[playerid][pWantedLevel] ++; 
            
format(msgsizeof(msg), "Suspect %s (%d) has shooting in public near %s"GetName(playerid), playeridReturnPlayerZone(ID)); 
            
SendRadioMessageToCops(msg); 
            
shotsfired[playerid] = 0
        } 
    }  
}
IsPlayerNearLawEnforcement(playerid

    static 
Float:range 100.0;
    new 
Float:xFloat:yFloat:z;
    foreach(
Playeri
    { 
        if(
GetTeam(i) == CLASS_CIV || GetTeam(i) == CLASS_MEDIC)
        {
            continue;
        } 
        
GetPlayerPos(ixyz); 
        if(
IsPlayerInRangeOfPoint(playeridrangexyz)) 
        { 
            return 
1
        } 
    } 
    return 
0

As you can see, i changed a couple of things, first of all, i changed the coding style a little, sorry, personal preference :P.

Also, i removed an unnecessary variable, shortend the msg variable, replaced ranged with a static, the position array with single variables (faster) and added an additional teamcheck to the first piece of code.

also i replaced the "{" and "}" behind GetTeam with "(" and ")".
Reply


Messages In This Thread
Near Cops - by STONEGOLD - 17.02.2017, 18:25
Re: Near Cops - by BiosMarcel - 17.02.2017, 19:36
Re: Near Cops - by STONEGOLD - 17.02.2017, 20:51

Forum Jump:


Users browsing this thread: 1 Guest(s)