[INCLUDE] Casas
#4

Code:
	if(!strcmp(cmd,"/casa",true)){
	  new tmp[256];
	  tmp = strtok(cmdtext, idx);
	  if(!strlen(tmp)){
	    SendClientMessage(playerid, COLOR_RED, "/casa [preзo]");
	    return 1;
	  }
	  
		if(IsPlayerConnected(playerid)){
		  new Float:X, Float:Y, Float:Z, Float:A, str[256], File:temp;
		  GetPlayerPos(playerid, X, Y, Z);
		  GetPlayerFacingAngle(playerid, A);
		  format(str,sizeof(str),"%f %f %f %f %d\r\n", X, Y, Z, A, strval(tmp));
		  temp = fopen("Casas/Coords.info", io_append);
		  fwrite(temp, str);
		  fclose(temp);
			CreatePickup(1273, 1, X, Y, Z);
			return 1;
		}
	if(strcmp(cmd, "/comprar", true) == 0) {
	  new Float:X, Float:Y, Float:Z, Float:A;
		if(IsPlayerInAnyHouse(playerid)){
		  new h = GetPlayerHouseID(playerid);
		  if(IsHouseSold(h)){
		    SendClientMessage(playerid, COLOR_RED, "Essa casa jб foi comprada.");
		    return 1;
		  } else {
			  if(GetPlayerMoney(playerid) >= GetHousePrice(h)){
			    SendClientMessage(playerid, COLOR_JUIZ, "Casa comprada.");
					GivePlayerMoney(playerid, 0 - GetHousePrice(h));
					GetHousePos(h, X, Y, Z, A);
					db_SetPlayerPos(PlayerName(playerid), X, Y, Z, A);
					SetHouseOwn(h, PlayerName(playerid));
					SetHouseSold(h, 1);
					DestroyAllHousePickups();
					LoadHousePickups();
					return 1;
				} else {
				  SendClientMessage(playerid, COLOR_RED, "Vocк nгo tem dinheiro suficiente para comprar essa casa.");
				  return 1;
				}
			}
		} else {
		  SendClientMessage(playerid, COLOR_RED, "Vocк nгo estб em uma casa.");
		  return 1;
		}
	}	}
stock LoadHouses()
{
  new File:temp;
	new index = 0;
	new tmp[256];
	new Float:X, Float:Y, Float:Z, Float:A, Price;
	temp = fopen("Casas/Coords.info", io_readwrite);
	while(fread(temp, tmp, sizeof(tmp), false)) {
		index = 0;
		X     = Float:floatstr(strtok(tmp, index));
		Y     = Float:floatstr(strtok(tmp, index));
		Z     = Float:floatstr(strtok(tmp, index));
		A	    = Float:floatstr(strtok(tmp, index));
		Price   = strval(strtok(tmp, index));

		CreateHouse(X, Y, Z, A, Price);
	}
	fclose(temp);
}
Reply


Messages In This Thread
[INCLUDE] Casas - by [BR]Michael - 12.11.2009, 22:11
Re: [INCLUDE] Casas - by rannyere - 13.11.2009, 02:59
Re: [INCLUDE] Casas - by Kutrhys - 13.11.2009, 12:39
Re: [INCLUDE] Casas - by [BR]Michael - 13.11.2009, 21:45
Re: [INCLUDE] Casas - by ashiuashiu - 15.11.2009, 16:11
Re: [INCLUDE] Casas - by LeoH - 05.01.2010, 15:05
Re: [INCLUDE] Casas - by John_Race - 24.01.2010, 15:29
Re: [INCLUDE] Casas - by ScriptGameS - 04.01.2014, 23:51

Forum Jump:


Users browsing this thread: 1 Guest(s)