Errors with another house script i tried to make
#1

hi i tried to make my own House System but it has lots of errors

Code
Код:
#include <a_samp>
#include <zcmd>
#include <streamer>

new DB:database, DBResult:queryresult, fquery[300];

#define MAX_HOUSES 300 //MAX_HOUSES is currently 300.
#define MAX_HOUSES_PER_PLAYER 2 //MAX_HOUSES_PER_PLAYER is currently 2
#define databasename "housedb.db" //The Databasename is currently housedb.db

enum hinfo
{
    owner[24],
    Hname[100],
    costprice,
    Float:EnterPos[3],
    Float:TelePos[3],
    sellprice,
    interiors,
    Text3D:textid,
    checkpointidx[2]
};

new HouseInformation[MAX_HOUSES][hinfo], houseid;
new InHouse[MAX_PLAYERS], InHouseCP[MAX_PLAYERS];

public OnFilterScriptInit()
{
    database = db_open(databasename);
    db_query(database, "CREATE TABLE IF NOT EXISTS `HOUSEINFO` (housename varchar(51), houseowner varchar(25))");
    CreateHouse(1, 2317.130615, 692.398498, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
	CreateHouse(1, 2346.872802, 692.999267, 11.460937, 266.857757, 305.001586, 999.148437, 2, 1);
	CreateHouse(1, 2396.482666, 691.487060, 11.453125, 2196.850341, -1204.343261, 1049.023437, 6, 1);
	CreateHouse(1, 2398.476074, 735.344665, 11.460937, 2196.850341, -1204.343261, 1049.023437, 6, 1);
	CreateHouse(1, 2368.863525, 733.627502, 11.460937, 2196.850341, -1204.343261, 1049.023437, 6, 1);
	CreateHouse(1, 2013.253906, 731.041870, 11.453125, 266.857757, 305.001586, 999.148437, 5, 1);
	CreateHouse(1, 2449.826660, 742.588806, 11.460937, 266.857757, 305.001586, 999.148437, 5, 1);
	CreateHouse(1, 2449.662353, 714.210693, 11.468292, 266.857757, 305.001586, 999.148437, 5, 1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    InHouse[playerid] = -1;
    InHouseCP[playerid] = -1;
    return 1;
}

CreateHouse(CostP, Float:EnterX, Float:EnterY, Float:EnterZ, Float:TeleX, Float:TeleY, Float:TeleZ, Interiorx, SellP)
	CostP = the Cost price of the house
	Float:EnterX = The X entry point of the house, it will also be where the outside checkpoint will be (Ex: 1264.53433)
	Float:EnterY = The Y entry point of the house, it will also be where the outside checkpoint will be (Ex: 2625.6436)
	Float:EnterZ = The Z entry point of the house, it will also be where the outside checkpoint will be (Ex: 200.532)
	Float:TeleX = The X teleport that teleports the player into the interior (Ex: 432.4234)
	Float:TeleY = The Y teleport that teleports the player into the interior (Ex: 4216.4152)
	Float:TeleZ = The Z teleport that teleports the player into the interior (Ex: 10.53672)
	SellP = It's the selling price that the owner can sell the house for (Ex: 200000)
	Interiorx = The interior ID of the interior that we will teleport to.
    HouseInformation[houseid][costprice] = CostP;
    HouseInformation[houseid][EnterPos][0] = EnterX;
    HouseInformation[houseid][EnterPos][1] = EnterY;
    HouseInformation[houseid][EnterPos][2] = EnterZ;
    HouseInformation[houseid][TelePos][0] = TeleX;
    HouseInformation[houseid][TelePos][1] = TeleY;
    HouseInformation[houseid][TelePos][2] = TeleZ;
    HouseInformation[houseid][sellprice] = SellP;
    HouseInformation[houseid][interiors] = Interiorx;
    format(fquery, sizeof(fquery), "SELECT houseowner FROM HOUSEINFO WHERE housename = '%s'", HouseName); //Formats the SELECT query
    queryresult = db_query(database, fquery); //Query result variable has been used to query the string above.
    if(db_num_rows(queryresult) != 0) db_get_field_assoc(queryresult, "houseowner", HouseInformation[houseid][owner], 24); //Fetches the field information  db_free_result(queryresult);
    HouseInformation[houseid][checkpointidx][0] = CreateDynamicCP(EnterX, EnterY, EnterZ, 1.0);
    //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size);
    HouseInformation[houseid][checkpointidx][1] = CreateDynamicCP(TeleX, TeleY, TeleZ, 1.0, 15500000+houseid, Interiorx);
    //CreateDynamicCP(Float:x, Float:y, Float:z, Float:size, worldid, interiorid);
    if(!HouseInformation[houseid][owner][0]) format(fquery, sizeof(fquery), "House Name: %s \n House Price:$%d \n Sell Price: $%d", HouseName, CostP, SellP);
    //If there is nothing in the owners variable, we check if the first cell doesn't have a character.
    else if(HouseInformation[houseid][owner][0] != 0) format(fquery, sizeof(fquery), "House Name: %s \n Owner: %s", HouseName, HouseInformation[houseid][owner]);
    //If there is something in the owners variable we check if the first cell has a character.
    HouseInformation[houseid][textid] = CreateDynamic3DTextLabel(fquery, 0xFFFFFF, EnterX, EnterY, EnterZ + 0.5, 50.0);
    //CreateDynamic3DTextLabel(const text[], color, Float:x, Float:y, Float:z, Float:drawdistance, attachedplayer = INVALID_PLAYER_ID, attachedvehicle = INVALID_VEHICLE_ID, testlos = 0, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
    houseid ++; //We go to the next free slot in our variable.
    return 1;
}

SELECT [VARIABLE] FROM [TABLENAME] WHERE [ANOTHER VARIABLE] = [A VALUE]
VARIABLE = houseowner
TABLENAME = HOUSEINFO
ANOTHER VARIABLE = housename
A VALUE = our house name.

INSERT INTO [TABLENAME] ([FIELD1], [FIELD2]) VALUES ([VALUE1], [VALUE2])
TABLENAME - HOUSEINFO
FIELD1 - housename
FIELD2 - houseowner
VALUE1 - Our housename value
VALUE2 - Our houseowner value

DELETE FROM [TABLENAME] WHERE [FIELD] = [VALUE]
TABLENAME - HOUSEINFO
FIELD - housename
VALUE - the housename

stock SetOwner(HouseName[], ownername[], houseids)
{
    format(fquery, sizeof(fquery), "INSERT INTO `HOUSEINFO` (`housename`, `houseowner`)  VALUES('%s', '%s')", HouseName, ownername);
    db_query(database, fquery); //Queries the SQLite database.
    format(HouseInformation[houseids][owner], 24, "%s", ownername);
    format(fquery, sizeof(fquery), "House Name: %s \n Owner: %s", HouseName, HouseInformation[houseids][owner]);
    UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label.
    return 1;
}

stock DeleteOwner(HouseName[], houseids)
{
    format(HouseInformation[houseids][owner], 24, "%s", "\0");
    format(fquery, sizeof(fquery), "DELETE FROM `HOUSEINFO` WHERE `housename` = '%s'", HouseName);
    db_query(database, fquery); //Queries the SQLite database.
    format(fquery, sizeof(fquery), "House Name: %s \n House Price:$%d \n Sell Price: $%d", HouseName, HouseInformation[houseids][costprice], HouseInformation[houseids][sellprice]);
    UpdateDynamic3DTextLabelText(HouseInformation[houseids][textid], 0xFFFFFF, fquery); //Updates the text label.
    return 1;
}

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    for(new x; x<houseid; x++) //Loops through all current house ids.
    {
        if(HouseInformation[x][checkpointidx][0] == checkpointid) //If the entry checkpoint is entry checkpoint.
        {
            if(InHouse[playerid] != -1)
            {
                InHouse[playerid] = -1; //Sets the player to outside the house.
                return 1;
            }
            InHouseCP[playerid] = x; //Sets the InHouseCP variable.
            new Pname[24]; //Pname variable.
            GetPlayerName(playerid, Pname, 24); //Gets the players name.
            if(HouseInformation[x][owner][0] != 0 && !strcmp(Pname, HouseInformation[x][owner][0]))
            //The line above checks that the owner string has something in it, then it
            //Will compare it to our current player.
            {
                SetPlayerPos(playerid, HouseInformation[x][TelePos][0], HouseInformation[x][TelePos][1], HouseInformation[x][TelePos][2]); //Sets players position where x = houseid.
                SetPlayerInterior(playerid, HouseInformation[x][interiors]); //Sets players interior
                SetPlayerVirtualWorld(playerid, 15500000 + x); //Sets the virtual world
                //This is used if you want multiple houses per interior.
                 //Sets the inhouse variable to the house he's in.
            }
            if(!HouseInformation[x][owner][0]) SendClientMessage(playerid, -1, "This house is for sale /buy to buy it!");
            //If there is no owner, it will send a message telling the player to buy it :).
            return 1;
            //We do this so the loop doesn't continue after or it tries to go for more checkpoints
            //We could alternitivly use break;
        }
        if(HouseInformation[x][checkpointidx][1] == checkpointid) //If the player enters the house exit.
        {
            if(InHouse[playerid] == -1)
            {
                InHouse[playerid] = x;
                return 1;
            }
            SetPlayerPos(playerid, HouseInformation[x][EnterPos][0], HouseInformation[x][EnterPos][1], HouseInformation[x][EnterPos][2]);
            SetPlayerInterior(playerid, 0); //Sets the player back to interior 0 (Outside)
            SetPlayerVirtualWorld(playerid, 0); //Sets the players Virtual world to 0.
            return 1;
            //We do this so the loop doesn't continue after or it tries to go for more checkpoints
            //We could alternitivly use break;
        }
    }
    return 1;
}

public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(InHouseCP[playerid] != - 1) InHouseCP[playerid] = -1; //Sets the players InHouseCP variable to 0.
    return 1;
}

CMD:buy(playerid, params)
{
    if(InHouseCP[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You are not in any house checkpoints!");
    if(HouseInformation[InHouseCP[playerid]][owner][0] != 0) return SendClientMessage(playerid, 0xFF0000, "This house has a owner");
    if(GetPlayerMoney(playerid) < HouseInformation[InHouseCP[playerid]][costprice]) return SendClientMessage(playerid, 0xFF0000, "You don't have enough money!"); //Player has a lack of cash!
    new PlayerName[24];
    GetPlayerName(playerid, PlayerName, 24);
    format(fquery, sizeof(fquery), "SELECT `houseowner` FROM `HOUSEINFO` WHERE `houseowner` = '%s'", PlayerName); //Formats the SELECT query
    queryresult = db_query(database, fquery); //Query result variable has been used to query the string above.
    if(db_num_rows(queryresult) == MAX_HOUSES_PER_PLAYER) return SendClientMessage(playerid, 0xFF0000, "You already have the max amount of houses"); //If the player has the max houses
    db_free_result(queryresult);
    //This is the point where the player can buy the house
    SetOwner(HouseInformation[InHouseCP[playerid]][Hname], PlayerName, InHouseCP[playerid]);
    //SetOwner(HouseName[], ownername[], houseids)
    SetPlayerPos(playerid, HouseInformation[InHouseCP[playerid]][TelePos][0], HouseInformation[InHouseCP[playerid]][TelePos][1], HouseInformation[InHouseCP[playerid]][TelePos][2]); //Sets players position where InHouseCP[playerid] = houseid.
    SetPlayerInterior(playerid, HouseInformation[InHouseCP[playerid]][interiors]); //Sets players interior
    SetPlayerVirtualWorld(playerid, 15500000 + InHouseCP[playerid]); //Sets the virtual world
    GivePlayerMoney(playerid, - HouseInformation[InHouseCP[playerid]][costprice]);
    GameTextForPlayer(playerid, "House ~r~Purchased!", 3000, 3); //Tells them they have purchased a house
    return 1;
}

CMD:sell(playerid, params)
{
    if(InHouse[playerid] == -1) return SendClientMessage(playerid, 0xFF0000, "You have to be inside your house to sell it!");
    new Pname[24];
    GetPlayerName(playerid, Pname, 24);
    if(strcmp(HouseInformation[InHouse[playerid]][owner], Pname) != 0) return SendClientMessage(playerid, 0xFF0000, "This is not your house!");
    //This is the point where the player can sell the house
    DeleteOwner(HouseInformation[InHouse[playerid]][Hname], InHouse[playerid]);
    //DeleteOwner(HouseName[], houseids)
    GivePlayerMoney(playerid, HouseInformation[InHouse[playerid]][sellprice]);
    SetPlayerPos(playerid, HouseInformation[InHouse[playerid]][EnterPos][0], HouseInformation[InHouse[playerid]][EnterPos][1], HouseInformation[InHouse[playerid]][EnterPos][2]);
    SetPlayerInterior(playerid, 0); //Sets the player back to interior 0 (Outside)
    SetPlayerVirtualWorld(playerid, 0); //Sets the players Virtual world to 0.
    InHouseCP[playerid] = InHouse[playerid];
    GameTextForPlayer(playerid, "House ~g~sold!", 3000, 3); //Tells them they have sold a house
    return 1;
}
Errors
Код:
C:\DOCUME~1\Bella\Desktop\SAMP03~2\FILTER~1\HOUSE_~2.PWN(50) : error 017: undefined symbol "the"
C:\DOCUME~1\Bella\Desktop\SAMP03~2\FILTER~1\HOUSE_~2.PWN(50) : error 010: invalid function or declaration
C:\DOCUME~1\Bella\Desktop\SAMP03~2\FILTER~1\HOUSE_~2.PWN(50 -- 73) : error 010: invalid function or declaration
C:\DOCUME~1\Bella\Desktop\SAMP03~2\FILTER~1\HOUSE_~2.PWN(50 -- 73) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Line 50 is the most errors and this is the line
Код:
CostP = the Cost price of the house
it says undefined Symbol but when i remove it it goes to the next line can u help plz

Line 73
Код:
HouseInformation[houseid][checkpointidx][1] = CreateDynamicCP(TeleX, TeleY, TeleZ, 1.0, 15500000+houseid, Interiorx);
a few Errors here but other than that the script is fine

Please Help Me

Regards Zonoya
Reply
#2

Looks like its from a tutorial, if so start again and follow it more carefully, And if its not from a tutorial, find one and use it. I'm not even going to get started on whats wrong with that code. (nearly everything you posted)

Try this one https://sampforum.blast.hk/showthread.php?tid=118379

EDIT: I just realised that thread has been edited and thats where you get the errors, you dont put this in your code:
pawn Код:
HouseName[] - The unique house name that you have chosen for the house (Ex: "Big Mansion5")
CostP - The Cost price of the house (Ex: 500000)
Float:EnterX - The X entry point of the house, it will also be where the outside checkpoint will be (Ex: 1264.53433)
Float:EnterY - The Y entry point of the house, it will also be where the outside checkpoint will be (Ex: 2625.6436)
Float:EnterZ - The Z entry point of the house, it will also be where the outside checkpoint will be (Ex: 200.532)
Float:TeleX - The X teleport that teleports the player into the interior (Ex: 432.4234)
Float:TeleY - The Y teleport that teleports the player into the interior (Ex: 4216.4152)
Float:TeleZ - The Z teleport that teleports the player into the interior (Ex: 10.53672)
SellP - It's the selling price that the owner can sell the house for (Ex: 200000)
Interiorx - The interior ID of the interior that we will teleport to.

//or this

SELECT [VARIABLE] FROM [TABLENAME] WHERE [ANOTHER VARIABLE] = [A VALUE]
VARIABLE = houseowner
TABLENAME = HOUSEINFO
ANOTHER VARIABLE = housename
A VALUE = our house name.

INSERT INTO [TABLENAME] ([FIELD1], [FIELD2]) VALUES ([VALUE1], [VALUE2])
TABLENAME - HOUSEINFO
FIELD1 - housename
FIELD2 - houseowner
VALUE1 - Our housename value
VALUE2 - Our houseowner value

DELETE FROM [TABLENAME] WHERE [FIELD] = [VALUE]
TABLENAME - HOUSEINFO
FIELD - housename
VALUE - the housename
They are just explaining what things do, not what you need in your code. Read the tut more careful.
Reply
#3

fixed^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)