11.03.2015, 16:59
I'm constantly getting, Error: You already own the max amount of houses.
Код:
#define MAX_OWNABLE_HOUSES 2 // Change this if you want a player to own more houses or less houses public OnPlayerConnect(playerid) { new string[128]; new house[128]; format(house, sizeof(house), "Houses/Users/%s.ini",PlayerName(playerid)); if(!DOF2_FileExists(house)) { for(new h = 0; h < MAX_OWNABLE_HOUSES;h++) { DOF2_CreateFile(house); format(string, sizeof(string), "HouseKey_%d", h); SetPVarInt(playerid, string, 1000); DOF2_SetInt(house, string, 1000); format(string, sizeof(string), "HouseRentKey_%d", h); SetPVarInt(playerid, string, 1000); DOF2_SetInt(house, string, 1000); DOF2_WriteFile(); } } if(DOF2_FileExists(house)) { for(new h = 0; h < MAX_OWNABLE_HOUSES;h++) { format(string, sizeof(string), "HouseKey_%d", h); SetPVarInt(playerid, string, DOF2_GetInt(house, string)); format(string, sizeof(string), "HouseRentKey_%d", h); SetPVarInt(playerid, string, DOF2_GetInt(house, string)); } } return 1; } //Dialog //if(GetPVarInt(playerid,"Bank") < HouseInfo[PlayerAtHouse[playerid]][Price]) return SendClientMessage(playerid, COLOR_RED, "Error: Not enough money."); //change to remove money from players bank. new house[256]; new string[256]; new sendername[MAX_PLAYER_NAME]; format(string, sizeof(string), "HouseKey_%d", MAX_OWNABLE_HOUSES); if(GetPVarInt(playerid,string) < 1000) return SendClientMessage(playerid, COLOR_RED, "Error: You already own the max number of houses."); format(house, sizeof(house), "Houses/house%i.ini",PlayerAtHouse[playerid]); DestroyDynamic3DTextLabel(House3D[PlayerAtHouse[playerid]]); //SetPVarInt(playerid,"Bank",GetPVarInt(playerid,"Bank")-HouseInfo[PlayerAtHouse[playerid]][Price]); Change to remove the money from players bank format(sendername, sizeof(sendername), "%s", PlayerName(playerid)); strmid(HouseInfo[PlayerAtHouse[playerid]][OwnerName], sendername, 0, strlen(sendername), 255); HouseInfo[PlayerAtHouse[playerid]][Owned] = 1; DOF2_SetString(house, "OwnerName", sendername); DOF2_SetInt(house, "Owned", 1); DOF2_WriteFile(); format(string, sizeof(string), "House Owned By %s:\n Price: %d\nPress H to enter", HouseInfo[PlayerAtHouse[playerid]][OwnerName], HouseInfo[PlayerAtHouse[playerid]][Price]); House3D[PlayerAtHouse[playerid]] = CreateDynamic3DTextLabel(string,0xFFFFFFFF,HouseInfo[PlayerAtHouse[playerid]][HouseEnterPos][0],HouseInfo[PlayerAtHouse[playerid]][HouseEnterPos][1],HouseInfo[PlayerAtHouse[playerid]][HouseEnterPos][2]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0); for(new h = 0; h < MAX_OWNABLE_HOUSES;h++) { format(string, sizeof(string), "HouseKey_%d", h); if(GetPVarInt(playerid,string) == 1000) { format(string, sizeof(string), "HouseKey_%d", h); SetPVarInt(playerid, string, PlayerAtHouse[playerid]); format(house, sizeof(house), "Houses/Users/%s.ini",PlayerName(playerid)); DOF2_SetInt(house, string, PlayerAtHouse[playerid]); DOF2_WriteFile(); PlayerAtHouse[playerid] = 0; return 1; } } }