• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] IsPlayerInRangeOfPoint
#1
Okay so I did this command and it should be able to loop from all of the Hangars to find the one where the player is close to, but it always returns the else message.

Code:
cmd:hangar(playerid){

for(new i = 0; i<MAX_HANGARS; i){

if(IsPlayerInRangeOfPoint(playerid, 4.0, hInfo[i][hPosX], hInfo[i][hPosY], hInfo[i][hPosZ])){

if(hangartimer[playerid] == 1) return ErrorMessage(playerid, "Nije proslo 30 minuta od uzimanja proslog oruzija.");

if(hInfo[i][hDeagle]蒉[i][hSawedOff]蒉[i][hM4]蒉[i][hMats] == 0) return ErrorMessage(playerid, "Hangar je prazan.");

if(hInfo[i][hStatus] == 0) return ErrorMessage(playerid, "Hangar nije u funkciji."), printf("hstatus: %d", hInfo[i][hStatus]);

new?

str[100];

format(str, sizeof str, "\tPacket name\tPacket quantity\nDesert Eagle \t%d\nSawed Off \t%d\nM4 \t%d\nMaterials \t%d", hInfo[i][hDeagle], hInfo[i][hSawedOff], hInfo[i][hM4], hInfo[i][hMats]);

SPD(playerid, DIALOG_HANGAR, DIALOG_STYLE_TABLIST_HEADERS, ""SERVER"Hangar", str, "Odaberi", "Odustani");

phangar[playerid] = i;

}

else return ErrorMessage(playerid, "Ne nalazite se u blizini nekog hangara.");

}

return true;

}
  Reply
#2
Because you have `return` inside the loop. So the first hangar they aren't near ends the loop. Move the failure case outside the loop and add `return` to the success case inside the loop.
  Reply


Forum Jump: