SA-MP Forums Archive
Enter restriction - 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: Enter restriction (/showthread.php?tid=595674)



Enter restriction - vassilis - 06.12.2015

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


Re: Enter restriction - Sanady - 06.12.2015

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


Re: Enter restriction - SilverStand - 06.12.2015

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); 
                 }
            }
        }



Re: Enter restriction - PrO.GameR - 06.12.2015

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


Re: Enter restriction - vassilis - 06.12.2015

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..


Re: Enter restriction - jlalt - 06.12.2015

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


Re: Enter restriction - vassilis - 06.12.2015

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


Re: Enter restriction - vassilis - 06.12.2015

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