If player is near ANY hitman, how? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: If player is near ANY hitman, how? (
/showthread.php?tid=546373)
If player is near ANY hitman, how? -
Sellize - 15.11.2014
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 !");
}
}
Re: If player is near ANY hitman, how? -
dominik523 - 15.11.2014
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])
{
...
}
}
}
Re: If player is near ANY hitman, how? -
Bakr - 15.11.2014
@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.
Re: If player is near ANY hitman, how? -
Sellize - 15.11.2014
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
Re: If player is near ANY hitman, how? -
dominik523 - 15.11.2014
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.
Re: If player is near ANY hitman, how? -
Sellize - 15.11.2014
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