SA-MP Forums Archive
Help|| House System Command - 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: Help|| House System Command (/showthread.php?tid=490132)



Help|| House System Command - wakeuptomer - 25.01.2014

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;
}



Re: Help|| House System Command - Dignity - 25.01.2014

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
    }



Re: Help|| House System Command - wakeuptomer - 25.01.2014

Can you show me an expample for the script?

Thank's.


Re: Help|| House System Command - Dignity - 25.01.2014

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. (:


Re: Help|| House System Command - wakeuptomer - 25.01.2014

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;
}