SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/06/2012, 08:16 PM   #1
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default housing system returns fault information

In my opinion the code below, should be working, instead, it says I'm not the owner of the house, and I can't enter the house.

/enter:
pawn Code:
COMMAND:enter(playerid, params[])
{
    // Setup local variables
    new HouseID, hLevel, BusID, BusType;

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/enter", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Make sure the player isn't inside a vehicle
        if (GetPlayerVehicleID(playerid) == 0)
        {
            // Loop through all houses
            for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
            {
                // Check if this house exists
                if (AHouseData[HouseID][PickupID] != 0)
                {
                    // 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)
                        {
                            // The house isn't open to the public, so keep anyone out who isn't the owner of the house
                            if (House_PlayerIsOwner(playerid, HouseID) == 0)
                            {
                                    // 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 level of the house
                        hLevel = AHouseData[HouseID][HouseLevel];
                        // Set the worldid so other players cannot see him anymore
                        SetPlayerVirtualWorld(playerid, 5000 + HouseID);
                        // Set the player inside the interior of the house
                        SetPlayerInterior(playerid, AHouseInteriors[hLevel][InteriorID]);
                        // Set the position of the player at the spawn-location of the house's interior
                        SetPlayerPos(playerid, AHouseInteriors[hLevel][IntX], AHouseInteriors[hLevel][IntY], AHouseInteriors[hLevel][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;
                    }
                }
            }

            // Loop through all player-owned businesses
            for (new i; i < MAX_BUSINESSPERPLAYER; i++)
            {
                // Get the business-id at the selected slot from the player
                BusID = APlayerData[playerid][Business][i];

                // Check if the player has owned a business in this slot
                if (BusID != 0)
                {
                    // Check if the player is in range of the business-pickup
                    if (IsPlayerInRangeOfPoint(playerid, 2.5, ABusinessData[BusID][BusinessX], ABusinessData[BusID][BusinessY], ABusinessData[BusID][BusinessZ]))
                    {
                        // Get the business-type
                        BusType = ABusinessData[BusID][BusinessType];
                        // Set the worldid so other players cannot see him anymore
                        SetPlayerVirtualWorld(playerid, 1000 + playerid);
                        // Set the player inside the interior of the business
                        SetPlayerInterior(playerid, ABusinessInteriors[BusType][InteriorID]);

                        // Set the position of the player at the spawn-location of the business's interior
                        SetPlayerPos(playerid, ABusinessInteriors[BusType][IntX], ABusinessInteriors[BusType][IntY], ABusinessInteriors[BusType][IntZ]);
                        // Also set a tracking-variable to enable /busmenu to track in which business the player is
                        APlayerData[playerid][CurrentBusiness] = BusID;
                        // Also let the player know he can use /busmenu to upgrade/exit his business
                        SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}Use {FFFF00}/busmenu{00FF00} to change options for your business");

                        // Exit the function
                        return 1;
                    }
                }
            }
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}

House_IsOwner:
pawn Code:
// his function returns "1" if the given player is the owner of the given house
House_PlayerIsOwner(playerid, HouseID)
{
   
        // Check if the player owns the house in any of his house-slots
    if (AHouseData[HouseID][Owner] == APlayerData[playerid][PlayerName])
    {
        return 1;
    }
    else
        return 0;
}

So the House_IsOwner returns that I'm not the owner of the house. What I actually really am.
What is wrong with the code?

Many thanks if you could help me this solved.
SomebodyAndMe is offline   Reply With Quote
Old 10/06/2012, 08:21 PM   #2
CidadeNovaRP
High-roller
 
CidadeNovaRP's Avatar
 
Join Date: Mar 2012
Posts: 1,120
Reputation: 98
Default Respuesta: housing system returns fault information

pawn Code:
// his function returns "1" if the given player is the owner of the given house
stock House_PlayerIsOwner(playerid, HouseID)
{
   
        // Check if the player owns the house in any of his house-slots
    if (AHouseData[HouseID][Owner] == APlayerData[playerid][PlayerName])
    {
        return 1;
    }
    return 0;
}
__________________
Eae Cidade, viu a versão 0.3x do SA-MP?
Onde?
Ta no fórum
To
CidadeNovaRP is offline   Reply With Quote
Old 10/06/2012, 08:24 PM   #3
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default Re: housing system returns fault information

Still the same error. And the stock u use, is no need for.
SomebodyAndMe is offline   Reply With Quote
Old 11/06/2012, 04:58 AM   #4
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default Re: housing system returns fault information

Anyone?
SomebodyAndMe is offline   Reply With Quote
Old 11/06/2012, 05:03 AM   #5
Extremo
Gangsta
 
Extremo's Avatar
 
Join Date: Jul 2008
Posts: 717
Reputation: 90
Default AW: housing system returns fault information

You cannot compare arrays.

A string is an array.

pawn Code:
if(array == someotherarray)

// is wrong! In order to compare an array you'll have to use strcmp

if(!strcmp(array, someotherarray, false))

Check this post:

EDIT: sorry wrong post, this one haha:
http://forum.sa-mp.com/showpost.php?...57&postcount=6
Extremo is offline   Reply With Quote
Old 11/06/2012, 05:11 AM   #6
SomebodyAndMe
Huge Clucker
 
SomebodyAndMe's Avatar
 
Join Date: Feb 2010
Location: 52.511938,6.092434 find it.
Posts: 471
Reputation: 21
Default Re: housing system returns fault information

Haha, that's some pretty advanced pawno scripting, can't really make out what you're telling there.
Maybe you can make an example with mine?
SomebodyAndMe is offline   Reply With Quote
Old 11/06/2012, 05:19 AM   #7
JhnzRep
Huge Clucker
 
JhnzRep's Avatar
 
Join Date: Jan 2012
Location: USA/Slovakia
Posts: 426
Reputation: 65
Default Re: housing system returns fault information

pawn Code:
if(strcmp(AHouseData[HouseID][Owner], APlayerData[playerid][PlayerName] ) == 0)
__________________
[center]Creations:

[Tutorial]
Business System
JhnzRep is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Housing system help..? Scarred Scripting Help 1 27/12/2011 05:14 PM
Enum Information returns C? knackworst Scripting Help 29 02/10/2011 02:03 AM
[Help]: Housing System Magazinez Help Archive 1 28/03/2011 02:06 PM
Housing System jamesb93 Help Archive 9 15/02/2010 10:08 PM
does someone has a housing system? Jackass123 Help Archive 1 06/12/2009 09:38 PM


All times are GMT. The time now is 06:49 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.