If player is near ANY hitman, how?
#1

How do I make this code so that it executes when the player is near ANY hitman?

Код:
if(moneys > 0 && playermoney >= moneys) // If player can place contract
                    {
                        for(new i = 0; i < MAX_PLAYERS; i++) // Loop through players and pick out hitmen
					    {
					        if(IsPlayerConnected(i)) continue;
                            if(PlayerInfo[i][pMember] == 8){
					        	new Float:x, Float:y, Float:z;
					        	GetPlayerPos(i, x, y, z);
					        	if(IsPlayerInRangeOfPoint(playerid, 4.0, x, y, z)){ // Player is near a hitman, send the contract
					        	    
					        	}
					        	else
					        	{
					        	
					        	}
					        }
					    }
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount !");
                    }
                }
Reply
#2

Try to make something like this:
pawn Код:
new Float:Pos[3];
foreach(Player, i)
{
    if(PlayerInfo[i][pHitman] > 0)
    {
        GetPlayerPos(i, Pos[0], Pos[1], Pos[2));
        if(IsPlayerInRangeOfPoint(playerid, 3, Pos[0], Pos[1], Pos[2])
        {
            ...
        }
    }
}
Reply
#3

@dominik523: Your code is practically identical. You are just using foreach and different variable names.

This is your problem:
pawn Код:
if(IsPlayerConnected(i)) continue;
You are stepping over that iteration of the loop when the player IS connected.
Reply
#4

Quote:
Originally Posted by Bakr
Посмотреть сообщение
@dominik523: Your code is practically identical. You are just using foreach and different variable names.

This is your problem:
pawn Код:
if(IsPlayerConnected(i)) continue;
You are stepping over that iteration of the loop when the player IS connected.
Changed it to
Код:
if(!IsPlayerConnected(i)) continue;
But now I still have the problem that it will only check if he is near 1 hitman and not for all
Reply
#5

Well, to be honest, I didn't really read the code above from the OP. I've just went to pawno and wrote that to make some example.
Nice job, that seems like the problem.
EDIT: you don't have "break" anywhere, your code should send the contract to every hitman near you.
Reply
#6

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Well, to be honest, I didn't really read the code above from the OP. I've just went to pawno and wrote that to make some example.
Nice job, that seems like the problem.
EDIT: then make a variable HitmanCount for example and do "HitmanCount ++;" every time you find that player is near any hitman.
Still don't quite understand it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)