Property command not working
#1

If somebody already owns the property - it does nothing...

Code:

Код:
		if(strcmp(cmd, "/buyproperty", true)==0 || strcmp(cmd, "/buyprop", true)==0)
	{
	  new str[128];
	  #if ENABLE_LOGIN_SYSTEM == 1
		if(Logged[playerid] == 0)
		{
	 	format(str, 128, "You have to login before you can buy or sell properties! Use: %s", LOGIN_COMMAND);
		SendClientMessage(playerid, 0xFF0000AA, str);
		return 1;
		}
		#endif
		new propid = IsPlayerNearProperty(playerid);
		if(propid == -1)
		{
		SendClientMessage(playerid, 0xFF0000AA, "You're not close enough to a property");
		return 1;
		}
		if(PlayerProps[playerid] == MAX_PROPERTIES_PER_PLAYER)
	  {
		format(str, 128, "You already have %d properties, you can't buy more properties!", PlayerProps[playerid]);
		SendClientMessage(playerid, 0xFF0000AA, str);
		return 1;
		}
		if(PropInfo[propid][PropIsBought] == 1)
		{
		new ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
		if(ownerid == playerid)
		{
 		SendClientMessage(playerid, 0xFF0000AA, "You already own this property!");
 		return 1;
		}
		else
		{
	  if(PropInfo[propid][PropUnbuyableTime] > 0)
	  {
	  format(str, 128, "This property is already bought by %s. You'll have to wait %d minutes before you can buy it.", PropInfo[propid][PropOwner], PropInfo[propid][PropUnbuyableTime]);
	  SendClientMessage(playerid, 0xFF0000AA, str);
	  return 1;
	  }
	  }
	  	return 1;
	  }
		if(GetPlayerMoney(playerid) < PropInfo[propid][PropValue])
		{
		  format(str, 128, "You don't have enough money! You need $%d,-", PropInfo[propid][PropValue]);
		  SendClientMessage(playerid, 0xFF0000AA, str);
		  return 1;
		}
		new pName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, pName, sizeof(pName));
		if(PropInfo[propid][PropIsBought] && PropInfo[propid][PropUnbuyableTime] == 0)
		{
			new ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
		  format(str, 128, "%s has bought your property \"%s\". You recieved 50 percent of it's value ($%d)", pName, PropInfo[propid][PropName], (PropInfo[propid][PropValue]/2));
			GivePlayerMoney(ownerid, (PropInfo[propid][PropValue]/2));
			SendClientMessage(ownerid, 0xFFFF00AA, str);
			PlayerProps[ownerid]--;
		}
		PropInfo[propid][PropOwner] = pName;
		PropInfo[propid][PropIsBought] = 1;
		PropInfo[propid][PropUnbuyableTime] = UNBUYABLETIME;
		EarningsForPlayer[playerid] += PropInfo[propid][PropEarning];
    GivePlayerMoney(playerid, (0-PropInfo[propid][PropValue]));
		format(str, 128, "You have bought the property \"%s\" for $%d", PropInfo[propid][PropName], PropInfo[propid][PropValue]);
    SendClientMessage(playerid, 0xFFFF00AA, str);
    format(str, 128, "%s has bought the property \"%s\".", pName, PropInfo[propid][PropName]);
    SendClientMessageToAllEx(playerid, 0xFFFF00AA, str);
    PlayerProps[playerid]++;
		return 1;
	}
By Sandra
Reply
#2

Err, does nobody have a clue?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)