Enter restriction
#1

How to restrict player to enter house if it is not his own?
What i am using now is doing vice versa and i don't know why.

I want to check if houseownerid is the same as playerid(from table accounts)
so i am using the same variables
is there other way i can do it?
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 cant enter the house since it's not yours!");
            
EnterHouse(playerid,hid);
        } 
now with that way it doesn't allow me even if i am the owner of the house
Reply
#2

Quote:
Originally Posted by vassilis
Посмотреть сообщение
How to restrict player to enter house if it is not his own?
What i am using now is doing vice versa and i don't know why.

I want to check if houseownerid is the same as playerid(from table accounts)
so i am using the same variables
is there other way i can do it?
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 cant enter the house since it's not yours!");
            
EnterHouse(playerid,hid);
        } 
now with that way it doesn't allow me even if i am the owner of the house
Sorry but I am editing this post third time, I wrongly read topic. So you can do this:
pawn Код:
if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID] || HouseInfo[hid][HOwned] == 1)
It check is player is not the owner of house or if house is owned. But for me it`s same. I would like to change that to:
pawn Код:
if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID])
Try both ways
Reply
#3

Try Change
Код:
        else if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[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 cant enter the house since it's not yours!"); 
            EnterHouse(playerid,hid); 

        }
to

Код:
        else if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[hid][XEnt],HouseInfo[hid][YEnt],HouseInfo[hid][ZEnt])) //enter house! 
        { 
            if(pinfo[playerid][ID] != HouseInfo[hid][HOwnerID]) 
            {
                 if(HouseInfo[hid][HOwned]) == 1)
                 {
                      SendClientMessage(playerid, -1, ""COL_RED"SERVER"COL_WHITE":You cant enter the house since it's not yours!");
                 } 
            }
            else
            {
                 if(HouseInfo[hid][HOwned]) == 1)
                 {
                      EnterHouse(playerid,hid); 
                 }
            }
        }
Reply
#4

print them maybe ? work is simple and works for sure, you aren't saving ownerid right I guess.
Reply
#5

Quote:
Originally Posted by PrO.GameR
Посмотреть сообщение
print them maybe ? work is simple and works for sure, you aren't saving ownerid right I guess.
well at mysql it saves the correct ids.. it gets the id from players table and set it at houseownerid row as same..
Reply
#6

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 cant enter the house since it's not yours!"); 
            
EnterHouse(playerid,hid); 

        } 
probably its from that: https://sampforum.blast.hk/showthread.php?tid=595672
cause you were inserting string into int I think you were bugging all house enum saves, try to print house id on the command
PHP код:
printf("%d %d",HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned]); 
to see if it loaded perfect
Reply
#7

Quote:
Originally Posted by jlalt
Посмотреть сообщение
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 cant enter the house since it's not yours!"); 
            
EnterHouse(playerid,hid); 
        } 
probably its from that: https://sampforum.blast.hk/showthread.php?tid=595672
cause you were inserting string into int I think you were bugging all house enum saves, try to print house id on the command
PHP код:
printf("%d %d",HouseInfo[hid][HOwnerID] && HouseInfo[hid][HOwned]); 
to see if it loaded perfect
I am not inserting string into int the only string i use is for HName(HouseName)

EDIT: I FIXED I HAD TO USE ON MY BUYHOUSE FUNCTION that hownerid = account id
Reply
#8

It actually doesn't work if i restart sa-mp server.exe
i can enter unowned houses but not my owned.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)