housecreate command doesn't work...
#1

Hello. So my problem is that when i type command /housecreate in game i create house but when i try to buy it server say that there is no house near me.. And i don't know where is the problem....

This is my command code..
Код:
CMD:housecreate(playerid, params[])
{
	new Float: X, Float: Y, Float: Z, hlabel[128], h;
	GetPlayerPos(playerid, X, Y, Z);

	if(pInfo[playerid][Admin] < 3) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");

	new INI:File = INI_Open(HousePath(h));

    INI_SetTag(File, "House Data");

    INI_WriteString(File, "Owner", "None");
    INI_WriteInt(File, "Price", 25000);
    INI_WriteInt(File, "Bought", 0);

    INI_WriteFloat(File, "extX", X);
    INI_WriteFloat(File, "extY", Y);
    INI_WriteFloat(File, "extZ", Z);

    INI_WriteFloat(File, "intX", 244.411987);
    INI_WriteFloat(File, "intY", 305.032989);
    INI_WriteFloat(File, "intZ", 999.148437);

    INI_WriteInt(File, "intVW", random(999));
    INI_WriteInt(File, "intW", 1);

    INI_Close(File);

	format(hlabel, 128, "[HOUSE: FOR SALE]\n{46E850}[Owner]{FFFFFF}: None\n{46E850}[Price]{FFFFFF}: $25000");
	Create3DTextLabel(hlabel, 0xFFFFFFFF, X, Y, Z, 15.0, 0, 1);

	return 1;
}
And the code of buying command
Код:
CMD:housebuy(playerid, params[])
{
	new str1[128], name[MAX_PLAYER_NAME+1], pNearHouse[MAX_PLAYERS] = 0, fee, str2[128];
	GetPlayerName(playerid, name, sizeof(name));

	if(pInfo[playerid][HouseOwner] < 9999) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You already own a house!");

	for(new i = 0; i < MAX_HOUSES; i++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][extX], hInfo[i][extY], hInfo[i][extZ]))
		{
			if(hInfo[i][Bought] == 1) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} This house is already bought!");
			if(GetPlayerMoney(playerid) < hInfo[i][Price]) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You can't afford this house!");

			else if(hInfo[i][Bought] == 0)
			{
				pNearHouse[playerid] = 1;
				pInfo[playerid][HouseOwner] = i;

				hInfo[i][Owner] = name;
				hInfo[i][Bought] = 1;

				format(str2, 128, "[HOUSE]\n{46E850}[Owner]{FFFFFF}: %s\n{46E850}[Price]{FFFFFF}: %d", hInfo[i][Owner], hInfo[i][Price]);
				Update3DTextLabelText(Text3D: i, 0x46E850FF, str2);

			    format(str1, sizeof(str1), "SERVER:{FFFFFF} You bought house ID %d for %d! (DEBUG: %d)", i, hInfo[i][Price], pInfo[playerid][HouseOwner]);
				fee = hInfo[i][Price];
			}
		}
	}

	if(pNearHouse[playerid] == 0) format(str1, sizeof(str1), "SERVER:{FFFFFF} You're not near any house!");

	SendClientMessage(playerid, 0x46E850FF, str1);
	GivePlayerMoney(playerid, -fee);

	ReloadLabels();

	return 1;
}
In attachments you find some photos if you can't understand what i am talking about... And sorry for my bad english..
Reply
#2

Why double detection to find the players range to the house? Try this.
pawn Код:
CMD:housebuy(playerid, params[])
{
    new str1[128], name[MAX_PLAYER_NAME+1], pNearHouse[MAX_PLAYERS] = 0, fee, str2[128];
    GetPlayerName(playerid, name, sizeof(name));

    if(pInfo[playerid][HouseOwner] < 9999) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You already own a house!");

    for(new i = 0; i < MAX_HOUSES; i++)
    {
        if(!IsPlayerInRangeOfPoint(playerid, 3.0, hInfo[i][extX], hInfo[i][extY], hInfo[i][extZ])) return SendClientMessage(playerid, -1, "You are not near any house!");
                 else
        {
            if(hInfo[i][Bought] == 1) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} This house is already bought!");
            if(GetPlayerMoney(playerid) < hInfo[i][Price]) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You can't afford this house!");

            else if(hInfo[i][Bought] == 0)
            {
                pNearHouse[playerid] = 1;
                pInfo[playerid][HouseOwner] = i;

                hInfo[i][Owner] = name;
                hInfo[i][Bought] = 1;

                format(str2, 128, "[HOUSE]\n{46E850}[Owner]{FFFFFF}: %s\n{46E850}[Price]{FFFFFF}: %d", hInfo[i][Owner], hInfo[i][Price]);
                Update3DTextLabelText(Text3D: i, 0x46E850FF, str2);

                format(str1, sizeof(str1), "SERVER:{FFFFFF} You bought house ID %d for %d! (DEBUG: %d)", i, hInfo[i][Price], pInfo[playerid][HouseOwner]);
                fee = hInfo[i][Price];
            }
        }
    }
    SendClientMessage(playerid, 0x46E850FF, str1);
    GivePlayerMoney(playerid, -fee);

    ReloadLabels();

    return 1;
}
Reply
#3

So yeah... One problem gone now server let me to get in the house but still dont let me to buy it because of the same problem... ( You are not near eny house )
Reply
#4

Edited the housecreate command!
pawn Код:
CMD:housecreate(playerid, params[])
{
   for(new idx=1; idx<MAX_HOUSES; idx++)
   {
    new Float: X, Float: Y, Float: Z, hlabel[128], h;
    GetPlayerPos(playerid, X, Y, Z);

    if(pInfo[playerid][Admin] < 3) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!");

    new INI:File = INI_Open(HousePath(h));
        HouseInfo[idx][hX] = X;
        HouseInfo[idx][hY] = Y;
        HouseInfo[idx][hZ] = Z;
        INI_SetTag(File, "House Data");

    INI_WriteString(File, "Owner", "None");
    INI_WriteInt(File, "Price", 25000);
    INI_WriteInt(File, "Bought", 0);
    INI_WriteFloat(File, "extX", X);
    INI_WriteFloat(File, "extY", Y);
    INI_WriteFloat(File, "extZ", Z);

    INI_WriteFloat(File, "intX", 244.411987);
    INI_WriteFloat(File, "intY", 305.032989);
    INI_WriteFloat(File, "intZ", 999.148437);

    INI_WriteInt(File, "intVW", random(999));
    INI_WriteInt(File, "intW", 1);  
    INI_Close(File);

    format(hlabel, 128, "[HOUSE: FOR SALE]\n{46E850}[Owner]{FFFFFF}: None\n{46E850}[Price]{FFFFFF}: $25000");
    Create3DTextLabel(hlabel, 0xFFFFFFFF, X, Y, Z, 15.0, 0, 1);
        idx = MAX_HOUSES;
      }

    return 1;
}
Change the variables to your own if needed.
Reply
#5

(3709) : error 028: invalid subscript (not an array or too many subscripts): "HouseInfo"
(3709) : warning 215: expression has no effect
(3709) : error 001: expected token: ";", but found "]"
(3709) : error 029: invalid expression, assumed zero
(3709) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#6

Told you to change to your own variable, show your house enumerator? I will do it for you.
Reply
#7

I'am green in theese things so i giving you this GM in PM thats not my GM so i don't afraid of anything
Reply
#8

Get another gamemode, not only this but everything is messede up in your server, none of the dynamics are working fine in your script brother.. Switch to next GM thats all i can say. I tried my best but couldnt do, and fixing from beginning is a hard stuff.
Reply
#9

Well thank you for youre advice man..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)