PLayershooting
#1

How can i give player wanted level 2 if player is shooting and cops are close to him.

I mean, If a player is shooting randomly in public and if there's a cop close to him so player should get 2 wanted level after every 2 fires.
Reply
#2

This is just an idea , I didn't test this code so I don't know if it works but you should get the idea of what you can use to make this script.

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new Float:X, Float:Y, Float:Z;
    for(new i; i<MAX_PLAYERS; i++) // Loop through all the players
    {
        if(IsACop(i)) // Search for players that are cops
        {
            GetPlayerPos(i, X, Y, Z); // Get the cop's position.       
        }
    }
    if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z)) // Check to see if the player who shot the weapon is near a cop
    {
        // Do something
       
    }
}
Reply
#3

Hi !
you can do it using:
1. OnPlayerWeaponShot Callback ~~~~> https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot
2. GetPlayerPos ~~~~> https://sampwiki.blast.hk/wiki/GetPlayerPos
3. IsPlayerInRangeOfPoint ~~~~> https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
4. GetPlayerWantedLevel ~~~~> https://sampwiki.blast.hk/wiki/GetPlayerWantedLevel
5. SetPlayerWantedLevel ~~~~> https://sampwiki.blast.hk/wiki/SetPlayerWantedLevel
6. a Loop

OnPlayerWeaponShot Callback call when a player fires a shot from a weapon...
so Get player position and make a loop through all players and check if someone close to player and if he/she is cop > give wantedlevel to him

here is a simple ex.


pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    new Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(IsCop(i))
        {
            if(IsPlayerInRangeOfPoint(i, /*Your Range*/, pX, pY, pZ))
            {
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2);
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)