Sethouseowner problem
#1

I have this command, I can't figure out how to make it so it sets the house owner for everyone, like this;
/sethouseowner [playerid], and it will give that player every house created, I also want it so, if I do /sethouseowner -1, it will make all the houses for sale. Please help, I'm stuck. It currently just sets house owner for a house id, I need to change that, so it sets a house owner for all the houses.


Код HTML:
CMD:sethouseowner(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 3)
    {
        new house,playa;
        if(!sscanf(params, "iu", house, playa))
		{
		    if(HouseInfo[house][ID] < 1 || house < 0)
		    {
		        SendClientMessage(playerid, COLOR_LIGHTRED, "	Invalid house!");
		        return 1;
			}
			if(!IsPlayerConnectedEx(playa))
			{//He's not connected so we're selling the house
			    if(HouseInfo[house][Owned])
			    {
			        new owner = ReturnUser(HouseInfo[house][Owner]);
					if(IsPlayerConnectedEx(owner))
					{
					    SendClientMessage(owner, COLOR_ORANGE, "An Admin took one of your properties away from you!");
						PlayerInfo[owner][pHouses] --;
						UpdatePlayer(owner);
					}
				}
				HouseInfo[house][Locked] = 1;
	            foreach(Player,i)
	            {
                    if(PlayerInfo[i][pLocal] == house+1000)
                    {
                        SetPlayerPos(i, HouseInfo[house][ExitX], HouseInfo[house][ExitY], HouseInfo[house][ExitZ]);
	                    SetPlayerInterior(i, 0);
						SetPlayerVirtualWorld(i, 0);
						PlayerInfo[i][pLocal] = 0;
					}
				}
	            HouseInfo[house][Owned] = 0;
	            HouseInfo[house][Lights] = 0;
			    HouseInfo[house][Rentable] = 0;
			    HouseInfo[house][Rent] = 0;
			    format(HouseInfo[house][Renter], 24, "No-One");
				format(HouseInfo[house][Owner], 24, "No-One");
				DestroyDynamicPickup(HouseInfo[house][PickupID]);//Changes the House Icon to the "For Sale" state
				HouseInfo[house][PickupID] = CreateDynamicPickup(1273, 16, HouseInfo[house][EntranceX], HouseInfo[house][EntranceY], HouseInfo[house][EntranceZ]);
				new string[22];
				format(string, sizeof(string), "For Sale\n$%d",HouseInfo[house][Price]);
				UpdateDynamic3DTextLabelText(HouseInfo[house][TextID], 0x2BFF00AA, string);
				UpdateHouse(house);
				format(string, sizeof(string), "* Property %d is now for sale!", house);
				SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
				return 1;
			}
			else
			{
			    if(HouseInfo[house][Owned])
			    {
					new owner = ReturnUser(HouseInfo[house][Owner]);
					if(playa == owner)
					{
					    SendClientMessage(playerid, COLOR_LIGHTRED, "	Player already owns the house!");
					    return 1;
					}
					if(IsPlayerConnectedEx(owner))
					{
					    SendClientMessage(owner, COLOR_ORANGE, "An Admin took one of your Properties away from you!");
					    if(PlayerInfo[owner][pLocal] == house+1000)
					    {
					        SetPlayerPos(owner, HouseInfo[house][EntranceX], HouseInfo[house][EntranceY], HouseInfo[house][EntranceZ]);
					        SetPlayerInterior(owner, 0);
					        SetPlayerVirtualWorld(owner, 0);
							PlayerInfo[owner][pLocal] = 0;
						}
						PlayerInfo[owner][pHouses] --;
					}
					format(HouseInfo[house][Owner], 24, "%s", PlayerName(playa));
					UpdateHouse(house);
					PlayerInfo[playa][pHouses] ++;
					SendClientMessage(playa, COLOR_LIGHTGREEN, "* An Admin gave you a Property!");
					SendClientMessage(playerid, COLOR_LIGHTGREEN, "[INFO]: Done!");
				}
				else
				{
	                HouseInfo[house][Lights] = 0;
				    HouseInfo[house][Owned] = 1;
				    HouseInfo[house][Rentable] = 0;
				    HouseInfo[house][Rent] = 0;
				    HouseInfo[house][Locked] = 0;
				    format(HouseInfo[house][Renter], 24, "No-One");
					format(HouseInfo[house][Owner], 24, "%s", PlayerName(playa));
					DestroyDynamicPickup(HouseInfo[house][PickupID]);
					HouseInfo[house][PickupID] = CreateDynamicPickup(1272, 16, HouseInfo[house][EntranceX], HouseInfo[house][EntranceY], HouseInfo[house][EntranceZ]);
					UpdateDynamic3DTextLabelText(HouseInfo[house][TextID], 0x2BFF00AA, " ");
				    UpdateHouse(house);
					SendClientMessage(playa, COLOR_LIGHTGREEN, "* An Admin gave you a Property!");
					PlayerInfo[playa][pHouses] ++;
					SendClientMessage(playerid, COLOR_LIGHTGREEN, "[INFO]: Done!");
				}
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /SetHouseOwner [House ID] [playerid/PartOfName]");
			SendClientMessage(playerid, COLOR_LIGHTBLUE, "Makes the player the Owner of the House. (-1 to set FOR SALE)");
			return 1;
		}
	}
	return 1;
}
Reply


Messages In This Thread
Sethouseowner problem - by ZachKnoxx - 02.02.2014, 19:21

Forum Jump:


Users browsing this thread: 1 Guest(s)