All pastes #446377 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-18 13:13 UTC
rendered paste body
	if(strcmp(cmd, "/buyprop", true) == 0)
	{
	    new filename[256];
	    GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
    	proptemp[playerid] = dini_Int(udb_encode(sendername), "propowned");
    	format(filename, sizeof(filename), "%d", PROP_AMOUNT);
		tmp = dini_Get(filename, "owner");
		if(Logged[playerid] != 1) {
			SendClientMessage(playerid, COLOR_RED, "You must be logged in to purchase a property!");
			return 1;
		}
		if (gPlayerCheckpointStatus[playerid] != MAX_PROPS && (!(IsPlayerInCheckpoint(playerid))) && Logged[playerid] == 1) {
			SendClientMessage(playerid, COLOR_RED, "You must be at a property to buy it!");
			return 1;
		}
		if (strcmp(tmp, sendername, false) == 0) {
				SendClientMessage(playerid, COLOR_WHITE, "You already own this property");
				return 1;
			}
		format(filename, sizeof(filename), "%d", PROP_AMOUNT);
		bought[playerid] = dini_Int(filename, "bought");
		if (proptemp[playerid] == 0 && bought[playerid] == 1) {
			format(string, sizeof(string), "This property is owned by %s and is not for sale!", tmp);
			SendClientMessage(playerid, COLOR_YELLOW, string);
			return 1;
		}
		if (proptemp[playerid] > 0) {
  			SendClientMessage(playerid, COLOR_RED, "You can only own ONE property at a time!
     		return 1;
		}
		if(Logged[playerid] == 1 && gPlayerCheckpointStatus[playerid] == MAX_PROPS && IsPlayerInCheckpoint(playerid)) {
			new cash[MAX_PLAYERS];
			cash[playerid] = GetPlayerMoney(playerid);
			if(cash[playerid] >= propcost[playerid]) {
			    new stringa[256];
	   	 		format(stringa, sizeof(stringa), "-%d", propcost[playerid]);
				GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
				format(filename, sizeof(filename), "%d", PROP_AMOUNT);
				dini_Set(filename, "owner", sendername);
				dini_Set(udb_encode(sendername), "carowned", filename);
				dini_IntSet(filename, "bought", 1);
				dini_Set(udb_encode(sendername), "car", "1");
				GivePlayerMoney(playerid, -propcost[playerid]);
				new string2[256];
				format(string2, sizeof(string2), "You just bought this property for $%d, Welcome to your new home.", propcost[playerid]);
				SendClientMessage(playerid, COLOR_LIGHTGREEN, string2);
				return 1;
			}
			if(cash[playerid] < propcost[playerid]) {
			    new string3[256];
				format(string3, sizeof(string3), "You do not have $%d and therefore cannot purchase this property!", propcost[playerid]);
				SendClientMessage(playerid, COLOR_RED, string3);
				return 1;
			}
		}
		return 1;
	}