Weird OnPlayerGiveDamage bug
#1

So I'm trying to setup a system, which involves three people at least.
Let's say there's Player A, B and C
Player A and B are normal players
Player C has started the police officer job.
I've created two vehicles which allow the player to start the police officer job.
When player B for instance, shoots at player A within the range specified (here 20m) he gets 1 wanted level.
This is my code:
PHP код:
public OnPlayerGiveDamage(playeriddamagedidFloatamountweaponidbodypart)
{
    for(new 
0MAX_PLAYERSi++)
    {
        if(
policeofficer[i]==1)
        {
            if(
GetDistanceBetweenPlayers(playerid,i) <= 20// If the player is near from the police
            
{
                
SetPlayerWantedLevel(playerid1);
                
SendClientMessage(playerid, -1"you have shot someone near a police officer");
            }
        }
    }
    return 
1;

Here is my GetDistanceBetweenPlayers:
PHP код:
forward Float:GetDistanceBetweenPlayers(playerid,targetplayerid);
public 
Float:GetDistanceBetweenPlayers(playerid,targetplayerid)
{
    new 
Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!
IsPlayerConnected(playerid) || !IsPlayerConnected(targetplayerid)) {
        return -
1.00;
    }
    
GetPlayerPos(playerid,x1,y1,z1);
    
GetPlayerPos(targetplayerid,x2,y2,z2);
    return 
floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));

The bug is whenever a police officer shoots / punches a player with wanted level, the two cars created for the police officer spawn again. So for instace if you punch a player with wanted level 2, there will be 6 exact same cars spawned above eachother (2 already spawned, and 4 more due to the 2 punches)
Any idea??
Reply


Messages In This Thread
Weird OnPlayerGiveDamage bug - by Adamoneoone - 29.06.2018, 07:07
Re: Weird OnPlayerGiveDamage bug - by Adamoneoone - 29.06.2018, 19:43
Re: Weird OnPlayerGiveDamage bug - by CodeStyle175 - 29.06.2018, 19:58

Forum Jump:


Users browsing this thread: 1 Guest(s)