SA-MP Forums Archive
/asellallhouses - 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: /asellallhouses (/showthread.php?tid=542302)



/asellallhouses - MrCallum - 18.10.2014

Код:
CMD:asellallhouses(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 4)
	{
		new playername[MAX_PLAYER_NAME];
		GetPlayerName(playerid, playername, sizeof(playername));

		new string[128], house;
		if(sscanf(params, "d", house)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /asellallhouses");

		HouseInfo[house][hLock] = 1;
		new ip[32];
		GetPlayerIp(playerid,ip,sizeof(ip));
		format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
		Log("logs/house.log", string);
		ClearHouse(house);
		format( HouseInfo[house][hOwner], 128, "Nobody" );
		HouseInfo[house][hGLUpgrade] = 1;
		PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
		format(string, sizeof(string), "~w~You have sold house %d.", house);
		GameTextForPlayer(playerid, string, 10000, 3);
		SaveHouses();
		DestroyDynamicPickup(HouseInfo[house][hPickupID]);
		HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
		DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
		format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
		HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
		return 1;
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
	}
	return 1;
}
It only sells one house, why?


Re: /asellallhouses - Neil. - 18.10.2014

You're only dealing with one house id. If you want to delete them all, loop through all house ids whilst executing the different functions such as ClearHouse, Destroying of Pickups among others for each house id.


Re: /asellallhouses - osman2571 - 18.10.2014

Try to make loop and set 700 number in loop


Re: /asellallhouses - MrCallum - 18.10.2014

How could I do that?


Re: /asellallhouses - Abagail - 18.10.2014

pawn Код:
CMD:asellallhouses(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 4)
    {
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));

        new string[128], house;
        for (new i = 0; i != MAX_HOUSES; ++i)
        {
        new house = i;
        HouseInfo[house][hLock] = 1;
        new ip[32];
        GetPlayerIp(playerid,ip,sizeof(ip));
        format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
        Log("logs/house.log", string);
        ClearHouse(house);
        format( HouseInfo[house][hOwner], 128, "Nobody" );
        HouseInfo[house][hGLUpgrade] = 1;
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        format(string, sizeof(string), "~w~You have sold house %d.", house);
        GameTextForPlayer(playerid, string, 10000, 3);
        SaveHouses();
        DestroyDynamicPickup(HouseInfo[house][hPickupID]);
        HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
        DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
        format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
        HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
        return 1;
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
    }
    return 1;
}
Assuming you have a MAX_HOUSES define or something this should work. I'd recommend checking if the house is valid or not too but I don't really know how your script handles it so here's an example,

pawn Код:
if(IsHouseValid(i)) continue;



Re: /asellallhouses - Crayder - 18.10.2014

Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
CMD:asellallhouses(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 4)
    {
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));

        new string[128];
        for (new house = 0; house != MAX_HOUSES; house++)
        {
        new house = i;
        HouseInfo[house][hLock] = 1;
        new ip[32];
        GetPlayerIp(playerid,ip,sizeof(ip));
        format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
        Log("logs/house.log", string);
        ClearHouse(house);
        format( HouseInfo[house][hOwner], 128, "Nobody" );
        HouseInfo[house][hGLUpgrade] = 1;
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        format(string, sizeof(string), "~w~You have sold house %d.", house);
        GameTextForPlayer(playerid, string, 10000, 3);
        SaveHouses();
        DestroyDynamicPickup(HouseInfo[house][hPickupID]);
        HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
        DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
        format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
        HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
        return 1;
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
    }
    return 1;
}
Assuming you have a MAX_HOUSES define or something this should work. I'd recommend checking if the house is valid or not too but I don't really know how your script handles it so here's an example,

pawn Код:
if(IsHouseValid(i)) continue;
Ehh,
for(new i
new i

Symbol already defined coming right up!




Assuming Abagails was almost right, here ya go!
pawn Код:
CMD:asellallhouses(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] >= 4)
    {
        new playername[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));

        new string[128];
        for (new house = 0; house != MAX_HOUSES; house++)
        {
        new house = i;
        HouseInfo[house][hLock] = 1;
        new ip[32];
        GetPlayerIp(playerid,ip,sizeof(ip));
        format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
        Log("logs/house.log", string);
        ClearHouse(house);
        format( HouseInfo[house][hOwner], 128, "Nobody" );
        HouseInfo[house][hGLUpgrade] = 1;
        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
        format(string, sizeof(string), "~w~You have sold house %d.", house);
        GameTextForPlayer(playerid, string, 10000, 3);
        SaveHouses();
        DestroyDynamicPickup(HouseInfo[house][hPickupID]);
        HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
        DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
        format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
        HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1,  -1, 30.0);
        return 1;
        }
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
    }
    return 1;
}