This function never returns -1 value? - 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: This function never returns -1 value? (
/showthread.php?tid=631630)
This function never returns -1 value? -
DuyDang2412 - 02.04.2017
I made a function to get the house id which player is near with the range is 2.0.
the problem is it never returns -1, it just returns the house id when the player is near any houses, but if the player is not near any houses, it doesn't return anything.
and it also doesn't print "Exterior ID : -1" on the console.
PHP код:
GetHouseExteriorNear(playerid){
for(new i = 1; i <= MAX_HOUSES; i++){
if(IsPlayerInRangeOfPoint(playerid, 2.0, CharacterHouse[i][chExteriorX], CharacterHouse[i][chExteriorY], CharacterHouse[i][chExteriorZ])){
if(GetPlayerVirtualWorld(playerid) == CharacterHouse[i][chExteriorVW]){
return i;
}
}
}
print("Exterior ID : -1");
return -1;
}
Re: This function never returns -1 value? -
Krexx - 02.04.2017
It does not print "Exterior ID : 1" because you need to return 1 in order for it to be displayed.
Re: This function never returns -1 value? -
ISmokezU - 02.04.2017
PHP код:
GetHouseExteriorNear(playerid) {
for(new i = 0; i < MAX_HOUSES; i++) {
if(IsPlayerInRangeOfPoint(playerid, 2.0, CharacterHouse[i][chExteriorX], CharacterHouse[i][chExteriorY], CharacterHouse[i][chExteriorZ])) {
if(GetPlayerVirtualWorld(playerid) == CharacterHouse[i][chExteriorVW]) {
return i;
}
}
}
print("Exterior ID : -1");
return -1;
}
Re: This function never returns -1 value? -
RoboN1X - 02.04.2017
The code seems fine, In which part of lines you are using this GetHouseExteriorNear function and does not return anything? and can you show the enum array for CharacterHouse please?
Re: This function never returns -1 value? -
DuyDang2412 - 02.04.2017
Quote:
Originally Posted by ISmokezU
PHP код:
GetHouseExteriorNear(playerid) {
for(new i = 0; i < MAX_HOUSES; i++) {
if(IsPlayerInRangeOfPoint(playerid, 2.0, CharacterHouse[i][chExteriorX], CharacterHouse[i][chExteriorY], CharacterHouse[i][chExteriorZ])) {
if(GetPlayerVirtualWorld(playerid) == CharacterHouse[i][chExteriorVW]) {
return i;
}
}
}
print("Exterior ID : -1");
return -1;
}
|
Solved! Thank you guys.