Help me with my Dynamic Housing System
#1

I've been working on it for a few weeks still cant get it to work right, thanks.

Code:
	}
	if(strcmp(cmd, "/buyhouse", true) == 0) //by Ian_Stuart
 	{
		if(IsPlayerConnected(playerid))
    {

        new x_nr[256];
        x_nr = strtok(cmdtext, idx);
        if(!strlen(x_nr))
        {
					SendClientMessage(playerid, COLOR_GREY, "Stand where you wish your house entrance to be and type '/buyhouse <1 - 9>'.");
					SendClientMessage(playerid, COLOR_GREY, "After you buy your house, type '/buyhouse confirm' and you will have your house");
					SendClientMessage(playerid, COLOR_GREY, "Make sure that your house is in a realistic place or Administration will be");
					SendClientMessage(playerid, COLOR_GREY, "notifed and your house WILL BE TAKEN WITH NO REFUND and you will be banned from");
					SendClientMessage(playerid, COLOR_GREY, "buying a house on the server again. If you need any other help type '/buyhouse help'.");
					SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
					SendClientMessage(playerid, COLOR_GREY, "Type '/househelp' to see what levels and how much the cost is.");
					return 1;
        }
      	  if(strcmp(x_nr,"help",true) == 0)
          	{
						SendClientMessage(playerid, COLOR_GREY, "Type '/househelp' to see what levels and how much the cost is.");

         	  return 1;
          }
					else if(strcmp(x_nr,"1",true) == 0)
          {
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,1.200000,-3.400000,999.400024,0,0,0,0,0,0,The State,Trailer,25000,0,0,2,1,0,0,1000,1,3045,418,-1,-1,132,3,%d\n ", X, Y, Z);
						hFile = fopen("property.cfg", io_append);
						fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
					}
          else if(strcmp(x_nr,"2",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,244.500000,305.000000,999.099975,0,0,0,0,0,0,The State, Bedsit,50000,0,0,1,1,0,1,100,1,0,418,-1,-1,133,0,%d\n ", X, Y, Z);
						hFile = fopen("property.cfg", io_append);
						fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
					}
          else if(strcmp(x_nr,"3",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,446.100006,507.899993,1001.400024,0,0,0,0,0,0,The State,2 Room Apartment,100000,0,0,12,1,0,1,666,1,77256,418,-1,-1,132,0,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
					}
      		else if(strcmp(x_nr,"4",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,221.600006,1143.599975,1082.599975,0,0,0,0,0,0,The State,3 Room Apartment,150000,0,0,4,1,0,1,5000,1,100,418,-1,-1,132,0,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
					}
      		else if(strcmp(x_nr,"5",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,261.000000,1286.000000,1080.199951,0,0,0,0,0,0,The State,4 Room House,250000,0,0,4,1,0,0,1500,1,0,418,-1,-1,133,0,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
 					}
      		else if(strcmp(x_nr,"6",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,234.199996,1064.900024,1084.199951,0,0,0,0,0,0,The State,5 Room House,2500000,0,0,6,1,0,0,0,0,0,418,-1,-1,131,0,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
 					}
      		else if(strcmp(x_nr,"7",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,140.399993,1370.300048,1083.800048,0,0,0,0,0,0,The State,6 Room House,2000000,0,0,5,1,0,0,5000,0,20000,418,-1,-1,132,9,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
 					}
      		else if(strcmp(x_nr,"8",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,-285.899993,1470.800048,1084.300048,0,0,0,0,0,0,The State,4 Room Luxury,2000000,0,0,15,1,0,0,1,0,124,418,-1,-1,132,8,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
 					}
      		else if(strcmp(x_nr,"9",true) == 0)
					{
						new entry[252];
						new Float:X, Float:Y, Float:Z;
		        new File:hFile;
		        GetPlayerPos(playerid, X, Y, Z);
		        format(entry, 250, "%.2f,%.2f,%.2f,234.199996,1064.900024,1084.199951,0,0,0,0,0,0,The State,5 Room House,2500000,0,0,6,1,0,0,0,0,0,418,-1,-1,131,10,%d\n ", X, Y, Z);
		        hFile = fopen("property.cfg", io_append);
		        fwrite(hFile, entry);
		        fclose(hFile);
						SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
						SendClientMessage(playerid, COLOR_GREY, "You made your house type '/buyhouse confirm' to buy your house.");
						SendClientMessage(playerid, COLOR_GREY, "NOTE: Remember not to make a house that isn't your level.");
						LoadProperty();
						return 1;
 					}
      		else if(strcmp(x_nr,"confirm",true) == 0)
					{
					  if(IsPlayerConnected(playerid))
					  {
							new Float:oldposx, Float:oldposy, Float:oldposz;
							GetPlayerName(playerid, playername, sizeof(playername));
							GetPlayerPos(playerid, oldposx, oldposy, oldposz);
							for(new h = 0; h < sizeof(HouseInfo); h++)
							{
								if(PlayerToPoint(2.0, playerid, HouseInfo[h][hEntrancex], HouseInfo[h][hEntrancey], HouseInfo[h][hEntrancez]) && HouseInfo[h][hOwned] == 0)
								{
									if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel])
									{
										format(string, sizeof(string), "  You must be Level %d to purchase this !", HouseInfo[h][hLevel]);
										SendClientMessage(playerid, COLOR_GRAD5, string);
										return 1;
									}
									if(PlayerInfo[playerid][pPhousekey] != 255 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pPhousekey]][hOwner], true) == 0)
									{
										SendClientMessage(playerid, COLOR_WHITE, "  You already own a house, type /sellhouse if you want to buy this one !");
										return 1;
									}
									if(GetPlayerMoney(playerid) > HouseInfo[h][hValue])
									{
										PlayerInfo[playerid][pPhousekey] = h;
										HouseInfo[h][hOwned] = 1;
										GetPlayerName(playerid, sendername, sizeof(sendername));
										strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255);
										GivePlayerMoney(playerid,-HouseInfo[h][hValue]);
				//						PlayerPlayMusic(playerid);
										SetPlayerInterior(playerid,HouseInfo[h][hInt]);
										SetPlayerPos(playerid,HouseInfo[h][hExitx],HouseInfo[h][hExity],HouseInfo[h][hExitz]);
										GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit", 5000, 3);
										PlayerInfo[playerid][pInt] = HouseInfo[h][hInt];
										PlayerInfo[playerid][pLocal] = h;
										SendClientMessage(playerid, COLOR_DBLUE, "------------------------------------------------------");
										SendClientMessage(playerid, COLOR_GREY, "Congratulations, on your new Purchase !");
										SendClientMessage(playerid, COLOR_GREY, "Type /help to review the new property help section !");
				            DateProp(playerid);
										OnPropUpdate();
										OnPlayerUpdate(playerid);
										return 1;
									}
									else
									{
										SendClientMessage(playerid, COLOR_GREY, "  You don't have the cash for that !");
										return 1;
									}
								}
							}
						}
					}

		    }
		return 1;
  }
Reply


Messages In This Thread
Help me with my Dynamic Housing System - by Sean12 - 30.04.2009, 02:47
Re: Help me with my Dynamic Housing System - by ferriswheel - 30.04.2009, 07:36
Re: Help me with my Dynamic Housing System - by Sean12 - 30.04.2009, 08:26

Forum Jump:


Users browsing this thread: 2 Guest(s)