Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] IsPlayerInRangeOfPoint

 
  • 0 Vote(s) - 0 Average
Pawn IsPlayerInRangeOfPoint
Salesman
Offline

Burgershot Member
Posts: 21
Threads: 2
Joined: Apr 2019
Reputation: 0
#1
2019-06-18, 02:43 PM
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]+hInfo[i][hSawedOff]+hInfo[i][hM4]+hInfo[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;
}
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#2
2019-06-19, 09:13 AM
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.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode