SA-MP Forums Archive
Admin can enter any house - 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: Admin can enter any house (/showthread.php?tid=321422)



Admin can enter any house - SnG.Scot_MisCuDI - 26.02.2012

Solved.


Re: Admin can enter any house - lewismichaelbbc - 26.02.2012

pawn Код:
if(!IsPlayerLuxAdmin(playerid))
{
    if (House_PlayerIsOwner(playerid, HouseID) == 0)
    {
        SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
        return 1;
    }
}



Re: Admin can enter any house - SnG.Scot_MisCuDI - 26.02.2012

pawn Код:
(1333) : warning 209: function "cmd_enter" should return a value
(1336) : error 010: invalid function or declaration
pawn Код:
1333: }
1336: return 0;



Re: Admin can enter any house - lewismichaelbbc - 26.02.2012

Try it now, I have edited the code


Re: Admin can enter any house - SnG.Scot_MisCuDI - 26.02.2012

I edited my comment


Re: Admin can enter any house - Bakr - 26.02.2012

-EDIT


Re: Admin can enter any house - SnG.Scot_MisCuDI - 26.02.2012

No errors but wont work (Deleted a } and changed to return 1)

pawn Код:
COMMAND:enter(playerid, params[])
{
    // Setup local variables
    new HouseID, IntID;

    // If a player hasn't logged in properly, he cannot use this command
    if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;

    // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
    if (GetPlayerVehicleSeat(playerid) == -1)
    {
        // Loop through all houses
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
        {
            // Check if the house exists
            if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
            {
                // Check if the player is in range of the house-pickup
                if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
                {
                    // Check if the house is closed to the public
                    if (AHouseData[HouseID][HouseOpened] == false)
                    {
                    if(!IsPlayerAdmin(playerid))
                    {
                    if (House_PlayerIsOwner(playerid, HouseID) == 0)
                    {
                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
                    return 1;
                    }
                    }
                            // Let the player know that this house isn't open to the public and he can't enter it
                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
                    return 1;
                        }
                    }

                    // The house is open to the public, or the player trying to enter is the owner, so let the player inside the house

                    // Get the interior to put the player in
                    IntID = AHouseData[HouseID][HouseLevel]; // Get the level of the house

                    // Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
                    SetPlayerVirtualWorld(playerid, 5000 + HouseID);
                    // Set the player inside the interior of the house
                    SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
                    // Set the position of the player at the spawn-location of the house's interior
                    SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
                    // Also set a tracking-variable to enable /housemenu to track in which house the player is
                    APlayerData[playerid][CurrentHouse] = HouseID;
                    // Also let the player know he can use /housemenu to upgrade/exit his house
                    SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/housemenu{00FF00} to change options for your house");

                    // Exit the function
                    return 1;
                }
            }
        }

    // If no house was in range, allow other script to use this command too (business-script for example)
    return 1;
}
im also thinking making another CMD called /fenter (force enter) so that admins cant enter,.. Would make it easier than changing this i think


Re: Admin can enter any house - Lynn - 26.02.2012

pawn Код:
COMMAND:enter(playerid, params[])
{
    // Setup local variables
    new HouseID, IntID;
   // If a player hasn't logged in properly, he cannot use this command
    if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
    // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
    if (GetPlayerVehicleSeat(playerid) == -1)
    {
        // Loop through all houses
        for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
        {
            // Check if the house exists
            if (IsValidDynamicPickup(AHouseData[HouseID][PickupID]))
            {
                // Check if the player is in range of the house-pickup
                if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]))
                {
                    // Check if the house is closed to the public
                    if (AHouseData[HouseID][HouseOpened] == false)
                    {
                        if(!IsPlayerAdmin(playerid))
                        {
                            if (House_PlayerIsOwner(playerid, HouseID) == 0)
                            {
                                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
                                return 1;
                            }
                        }
                       // Let the player know that this house isn't open to the public and he can't enter it
                        SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
                        return 1;
                    }
                    // The house is open to the public, or the player trying to enter is the owner, so let the player inside the house
                    // Get the interior to put the player in
                    IntID = AHouseData[HouseID][HouseLevel]; // Get the level of the house
                    // Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
                    SetPlayerVirtualWorld(playerid, 5000 + HouseID);
                    // Set the player inside the interior of the house
                    SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
                    // Set the position of the player at the spawn-location of the house's interior
                    SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
                    // Also set a tracking-variable to enable /housemenu to track in which house the player is
                    APlayerData[playerid][CurrentHouse] = HouseID;
                    // Also let the player know he can use /housemenu to upgrade/exit his house
                    SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/housemenu{00FF00} to change options for your house");
                    // Exit the function
                    return 1;
                }
            }
        }
    }
    // If no house was in range, allow other script to use this command too (business-script for example)
    return 1;
}
Try this, fixed some indention, and Brackets.


Re: Admin can enter any house - SnG.Scot_MisCuDI - 26.02.2012

Still doesnt let me enter


Re: Admin can enter any house - Lynn - 26.02.2012

pawn Код:
COMMAND:enter(playerid, params[])
{
    // Setup local variables
    new IntID;
   // If a player hasn't logged in properly, he cannot use this command
    if (INT_IsPlayerLoggedIn(playerid) == 0) return 0;
    // Check if the player isn't inside a vehicle (the player must be on foot to use this command)
    if (GetPlayerVehicleSeat(playerid) == -1)
    {
        // Loop through all houses
        for(new i = 0; i < sizeof(AHouseData); i++)
        {
            // Check if the house exists
            if (IsValidDynamicPickup(AHouseData[i][PickupID]))
            {
                // Check if the player is in range of the house-pickup
                if (IsPlayerInRangeOfPoint(playerid, 2.5, AHouseData[i][HouseX], AHouseData[i][HouseY], AHouseData[i][HouseZ]))
                {
                    // Check if the house is closed to the public
                    if (AHouseData[i][HouseOpened] == false)
                    {
                        if(!IsPlayerAdmin(playerid))
                        {
                            if (House_PlayerIsOwner(playerid, i) == 0)
                            {
                                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This house isn't open to the public, you can't enter it");
                            }
                        }
                        else
                        {
                            IntID = AHouseData[i][HouseLevel];
                            SetPlayerVirtualWorld(playerid, 5000 + i);
                            SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
                            SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
                            APlayerData[playerid][CurrentHouse] = i;
                            SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/housemenu{00FF00} to change options for your house");
                        }
                    }
                    else
                    {
                        // The house is open to the public, or the player trying to enter is the owner, so let the player inside the house
                        // Get the interior to put the player in
                        IntID = AHouseData[i][HouseLevel]; // Get the level of the house
                        // Set the worldid so other players cannot see him anymore (but allow all players in the same house to see eachother)
                        SetPlayerVirtualWorld(playerid, 5000 + i);
                        // Set the player inside the interior of the house
                        SetPlayerInterior(playerid, AHouseInteriors[IntID][InteriorID]);
                        // Set the position of the player at the spawn-location of the house's interior
                        SetPlayerPos(playerid, AHouseInteriors[IntID][IntX], AHouseInteriors[IntID][IntY], AHouseInteriors[IntID][IntZ]);
                        // Also set a tracking-variable to enable /housemenu to track in which house the player is
                        APlayerData[playerid][CurrentHouse] = i;
                        // Also let the player know he can use /housemenu to upgrade/exit his house
                        SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/housemenu{00FF00} to change options for your house");
                        // Exit the function
                    }
                }
            }
        }
    }
    // If no house was in range, allow other script to use this command too (business-script for example)
    return 1;
}