This function never returns -1 value?
#1

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 
1<= MAX_HOUSESi++){
        if(
IsPlayerInRangeOfPoint(playerid2.0CharacterHouse[i][chExteriorX], CharacterHouse[i][chExteriorY], CharacterHouse[i][chExteriorZ])){
            if(
GetPlayerVirtualWorld(playerid) == CharacterHouse[i][chExteriorVW]){
                return 
i;
            }
        }
    }    
    print(
"Exterior ID : -1");
    return -
1;

Reply
#2

It does not print "Exterior ID : 1" because you need to return 1 in order for it to be displayed.
Reply
#3

PHP код:
GetHouseExteriorNear(playerid) { 
    for(new 
0MAX_HOUSESi++) { 
        if(
IsPlayerInRangeOfPoint(playerid2.0CharacterHouse[i][chExteriorX], CharacterHouse[i][chExteriorY], CharacterHouse[i][chExteriorZ])) { 
            if(
GetPlayerVirtualWorld(playerid) == CharacterHouse[i][chExteriorVW]) { 
                return 
i
            } 
        } 
    }     
    print(
"Exterior ID : -1"); 
    return -
1

Reply
#4

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?
Reply
#5

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
PHP код:
GetHouseExteriorNear(playerid) { 
    for(new 
0MAX_HOUSESi++) { 
        if(
IsPlayerInRangeOfPoint(playerid2.0CharacterHouse[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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)