Enter 1st house but not 2n
#1

I have bought 2 houses with 2 different names i can enter correctly first one but cant second why?
enter command
PHP код:
        else if(IsPlayerInRangeOfPoint(playerid2.0HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house!
        
{                
                if(
pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE":You can't enter the house since it's not yours");
                if(
pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1)
                {
                    
EnterHouse(playerid,hid);
                }
        
        } 
(used at keystate change)
enter house function
PHP код:
function EnterHouse(playerid,houseid)
{
            
SetPlayerPos(playerid,HouseInfo[houseid][XExit],HouseInfo[houseid][YExit],HouseInfo[houseid][ZExit]);
            
SetPlayerInterior(playerid,HouseInfo[houseid][HInterior]);
            
SetPlayerVirtualWorld(playerid,HouseInfo[houseid][HVirtualWorld]);
            
Loading(playerid);
            return 
1;

Reply
#2

First, find where the prob is:
Код:
        else if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house!
        {
print("1");
                if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE":You can't enter the house since it's not yours");
print("2");
                if(pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1)
                {
print("3");
                    EnterHouse(playerid,hid);
                }
        
        }
Or something like that... Then you can fix it easily.
Reply
#3

print your house info & player info to see if they're loaded right,
PHP код:
else if(IsPlayerInRangeOfPoint(playerid2.0HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house! 
        
{
                
printf(Player House ID: %dHouse OwnerID: %d",pinfo[playerid][ID],HouseInfo[hid][HOwnerID]);                 
                if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"
SERVER"COL_WHITE":You can't enter the house since it's not yours"); 
                if(pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) 
                { 
                    EnterHouse(playerid,hid); 
                } 
         
        } 
if setting player pos wrongly print your house float:
PHP код:
function EnterHouse(playerid,houseid

            
SetPlayerPos(playerid,HouseInfo[houseid][XExit],HouseInfo[houseid][YExit],HouseInfo[houseid][ZExit]); 
            
printf("%f, %f, %f",HouseInfo[houseid][XExit],HouseInfo[houseid][YExit],HouseInfo[houseid][ZExit]); 
            
SetPlayerInterior(playerid,HouseInfo[houseid][HInterior]); 
            
SetPlayerVirtualWorld(playerid,HouseInfo[houseid][HVirtualWorld]); 
            
Loading(playerid); 
            return 
1

Reply
#4

Quote:
Originally Posted by Yousha
Посмотреть сообщение
First, find where the prob is:
Код:
        else if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house!
        {
print("1");
                if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE":You can't enter the house since it's not yours");
print("2");
                if(pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1)
                {
print("3");
                    EnterHouse(playerid,hid);
                }
        
        }
Or something like that... Then you can fix it easily.
So this was suppose to help me?
I don't think the problem is related to the variables but i think it needs somehow a loop
Quote:
Originally Posted by jlalt
Посмотреть сообщение
print your house info & player info to see if they're loaded right,
PHP код:
else if(IsPlayerInRangeOfPoint(playerid2.0HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house! 
        
{
                
printf(Player House ID: %dHouse OwnerID: %d",pinfo[playerid][ID],HouseInfo[hid][HOwnerID]);                 
                if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"
SERVER"COL_WHITE":You can't enter the house since it's not yours"); 
                if(pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) 
                { 
                    EnterHouse(playerid,hid); 
                } 
         
        } 
if setting player pos wrongly print your house float:
PHP код:
function EnterHouse(playerid,houseid

            
SetPlayerPos(playerid,HouseInfo[houseid][XExit],HouseInfo[houseid][YExit],HouseInfo[houseid][ZExit]); 
            
printf("%f, %f, %f",HouseInfo[houseid][XExit],HouseInfo[houseid][YExit],HouseInfo[houseid][ZExit]); 
            
SetPlayerInterior(playerid,HouseInfo[houseid][HInterior]); 
            
SetPlayerVirtualWorld(playerid,HouseInfo[houseid][HVirtualWorld]); 
            
Loading(playerid); 
            return 
1

So i printed and realised that on the 2nd house it doesnt even print when i am in range of it and press f button
Reply
#5

Quote:
Originally Posted by vassilis
Посмотреть сообщение
So this was suppose to help me?
I don't think the problem is related to the variables but i think it needs somehow a loop

So i printed and realised that on the 2nd house it doesnt even print when i am in range of it and press f button
can you show how you're getting hid ?
Reply
#6

PHP код:
stock GetHouseID(playerid)
{
    for(new 
i=1i<MAX_HOUSESi++)
    {
        if(
IsPlayerInRangeOfPoint(playerid2HouseInfo[i][XExit], HouseInfo[i][YExit], HouseInfo[i][ZExit]))
        {
            return 
i;
        }
        else if(
IsPlayerInRangeOfPoint(playerid2HouseInfo[i][XEnt], HouseInfo[i][YEnt], HouseInfo[i][ZEnt]))
        {
            return 
i;
        }
    }
    return 
INVALID_HOUSE_ID;

Reply
#7

PHP код:
else if(hid != INVALID_HOUSE_ID)) //enter house!
        
{
                if(
pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1) return SendClientMessage(playerid,-1,""COL_RED"SERVER"COL_WHITE":You can't enter the house since it's not yours");
                if(
pinfo[playerid][ID] == HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned] == 1)
                {
                    
EnterHouse(playerid,hid);
                }

        } else return 
SendClienMessage(playerid,-1,"You're not near any house"); 
instead of isplayeinrangeofpint try to use if(hid != INVALID_HOUSE_ID) , and later down send message if it not valid house to see if the problem is it say player not in range of house or not
Reply
#8

Sorry for all this but had to mention that it happens vice versa it enters to house id 2 but not at houseid 1

anyway i did what you tell me
and i noticed that when i go at house id 1 again i can't enter and says you are not near any house but at house id 2 i can
Reply
#9

Quote:
Originally Posted by vassilis
Посмотреть сообщение
Sorry for all this but had to mention that it happens vice versa it enters to house id 2 but not at houseid 1

anyway i did what you tell me
and i noticed that when i go at house id 1 again i can't enter and says you are not near any house but at house id 2 i can
well if just on house id 1 then start here with number 0 >>
Код:
stock GetHouseID(playerid)
{
    for(new i=0; i<MAX_HOUSES; i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][XExit], HouseInfo[i][YExit], HouseInfo[i][ZExit]))
        {
            return i;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 2, HouseInfo[i][XEnt], HouseInfo[i][YEnt], HouseInfo[i][ZEnt]))
        {
            return i;
        }
    }
    return INVALID_HOUSE_ID;
}
Reply
#10

now to check what the real problem is i created and a 3rd house and now i cant enter my other 2 (i have bought all 3)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)