Help|| House System Command
#1

Hey all,
I'm trying to make a command which sell all the houses in the server,

this is the code but it's ain't sell it all..


Код:
COMMAND:asellhouse(playerid, params[])
{
	new id,
{
	    if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
		if(GetPVarInt(playerid, "Admin") >= 9)
		{
      		format(string, sizeof(string), "You have sold all the houses in the server!);
      		SendClientMessage(playerid,COLOR_GREY,string);
		    HouseInfo[id][hLock] = 1;
		    HouseInfo[id][hOwned] = 0;
		    HouseInfo[id][hMoney] = 0;
		    HouseInfo[id][hLock] = 0;
      		strmid(HouseInfo[id][hOwner], "The State", 0, strlen("The State"), 255);
      		DestroyDynamicPickup(HouseInfo[id][hPickupID]);
		    HouseInfo[id][hPickupID]=CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
		    format(string, sizeof(string), "housedata/%d.ini", id);
            if(DOF2_FileExists(string)) DOF2_RemoveFile(string);
		}
		else
		{
            SendClientMessage(playerid, COLOR_LIGHTRED, "You do not have access to this command !");
		}
	}
	return 1;
}
Reply
#2

You need to use a loop to go through all existing houses I believe.

Example (taking from my vehicle system):
pawn Код:
for(new VID = 1; VID < sizeof(VehicleInfo); VID++)
    {
    // code
    }
Reply
#3

Can you show me an expample for the script?

Thank's.
Reply
#4

pawn Код:
COMMAND:asellhouse(playerid, params[])
{
    new id,
   
    for(new id = 1; id < sizeof(HouseInfo); id++)
        {
            if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
            if(GetPVarInt(playerid, "Admin") >= 9)
            {
                format(string, sizeof(string), "You have sold all the houses in the server!");
                SendClientMessage(playerid,COLOR_GREY,string);
                HouseInfo[id][hLock] = 1;
                HouseInfo[id][hOwned] = 0;
                HouseInfo[id][hMoney] = 0;
                HouseInfo[id][hLock] = 0;
                strmid(HouseInfo[id][hOwner], "The State", 0, strlen("The State"), 255);
                DestroyDynamicPickup(HouseInfo[id][hPickupID]);
                HouseInfo[id][hPickupID]=CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
                format(string, sizeof(string), "housedata/%d.ini", id);
                if(DOF2_FileExists(string)) DOF2_RemoveFile(string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "You do not have access to this command !");
            }
        }
    }
    return 1;
}


Not sure if this is the correct way, but this is a method that should work.

EDIT: I just found a flaw in your code aswell, some formats are not properly closed. I fixed them though.

Also,

pawn Код:
format(string, sizeof(string), "You have sold all the houses in the server!");
SendClientMessage(playerid,COLOR_GREY,string);
A format "formats a string to include variables and other strings inside it", and since you are not adding anything to the format function, you technically do not need it, you can just use SendClientMessage. (:
Reply
#5

Still not working, I need a command which selling all the houses that founds on the server..

pawn Код:
COMMAND:asellallhouses(playerid, params[])
{
    new id,

    for(new id = 1; id < sizeof(HouseInfo); id++)
        {
            if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
            if(GetPVarInt(playerid, "Admin") >= 11)
            {
                format(string, sizeof(string), "You have sold all the houses in the server!");
                SendClientMessage(playerid,COLOR_GREY,string);
                HouseInfo[id][hLock] = 1;
                HouseInfo[id][hOwned] = 0;
                HouseInfo[id][hMoney] = 0;
                HouseInfo[id][hLock] = 0;
                strmid(HouseInfo[id][hOwner], "The State", 0, strlen("The State"), 255);
                DestroyDynamicPickup(HouseInfo[id][hPickupID]);
                HouseInfo[id][hPickupID]=CreateDynamicPickup(1273, 1, HouseInfo[id][hEnterX], HouseInfo[id][hEnterY], HouseInfo[id][hEnterZ]);
                format(string, sizeof(string), "housedata/%d.ini", id);
                if(DOF2_FileExists(string)) DOF2_RemoveFile(string);
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "You do not have access to this command !");
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)