SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 18/06/2019, 02:37 PM   #1
Coox
Little Clucker
 
Coox's Avatar
 
Join Date: Feb 2018
Posts: 22
Reputation: 0
Default IsPlayerInRangeOfPoint

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.

HTML 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;
}
Coox is offline   Reply With Quote
Old 18/06/2019, 03:00 PM   #2
1sbedx
Huge Clucker
 
Join Date: Dec 2015
Posts: 248
Reputation: 38
Default Re: IsPlayerInRangeOfPoint

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;
}
"return" breaks the loop.

Try this:
PHP Code:
cmd:hangar(playerid){
  new 
hangar = -1;

  if ((
hangar GetNearestHangar(playerid)) == -1)
    return 
ErrorMessage(playerid"Ne nalazite se u blizini nekog hangara.");

  if(
hangartimer[playerid] == 1) return ErrorMessage(playerid"Nije proslo 30 minuta od uzimanja proslog oruzija.");
  if(
hInfo[hangar][hDeagle]+hInfo[hangar][hSawedOff]+hInfo[hangar][hM4]+hInfo[hangar][hMats] == 0) return ErrorMessage(playerid"Hangar je prazan.");
  if(
hInfo[hangar][hStatus] == 0) return ErrorMessage(playerid"Hangar nije u funkciji."), printf("hstatus: %d"hInfo[hangar][hStatus]);
  
  new 
    
str[100];

  
format(strsizeof str"\tPacket name\tPacket quantity\nDesert Eagle \t%d\nSawed Off \t%d\nM4 \t%d\nMaterials \t%d"hInfo[hangar][hDeagle], hInfo[hangar][hSawedOff], hInfo[hangar][hM4], hInfo[hangar][hMats]);
  
SPD(playeridDIALOG_HANGARDIALOG_STYLE_TABLIST_HEADERS""SERVER"Hangar"str"Odaberi""Odustani");
  
phangar[playerid] = hangar;
  return 
true;
}

GetNearestHangar(playeridFloat:range 4.0) {
  for (new 
0MAX_HANGARSi++) {
    if (
IsPlayerInRangeOfPoint(playeridrangehInfo[i][hPosX], hInfo[i][hPosY], hInfo[i][hPosZ]))
      return 
i;
  }
  return -
1;

__________________
Estou desenvolvendo por dinheiro, qualquer dúvida entre em contato para negociação.
1sbedx is offline   Reply With Quote
Old 18/06/2019, 03:16 PM   #3
Coox
Little Clucker
 
Coox's Avatar
 
Join Date: Feb 2018
Posts: 22
Reputation: 0
Default Re: IsPlayerInRangeOfPoint

Works as a charm, thanks +rep
Coox is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] IsPlayerInRangeOfPoint TheBob Português/Portuguese 13 08/09/2016 10:17 PM
IsPlayerInRangeOfPoint Blademaster680 Scripting Help 1 08/09/2014 09:26 PM
IsPlayerInRangeOfPoint Sergeant Scripting Help 9 14/03/2014 08:34 AM
IsPlayerInRangeOfPoint Miguel_Teixeira Help Archive 6 08/05/2011 06:30 PM
NPC + IsPlayerInRangeOfPoint Shoko Lacho Help Archive 0 11/03/2011 04:10 AM


All times are GMT. The time now is 02:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.