12.12.2013, 08:22
Hello, I still can't figure it out why this command isn't working.. Can anyone please check it out? Thanks in advance.
Wheneve anyone types /buyhouse.. Nothing appears at all , no text .. but if i change the level to say like 99 and my level is only 4 .. then it would say "You must be Level 99 to purchase this!"
Here's the code.
Command itself.
SaveHouse
RehashHouse
LoadHouse
I know.. the code is kinda long to be looked at .. but i hope i'll get some help.. Thank you in advance 
EDIT:It's really werid , i still can't find the problem..
Wheneve anyone types /buyhouse.. Nothing appears at all , no text .. but if i change the level to say like 99 and my level is only 4 .. then it would say "You must be Level 99 to purchase this!"
Here's the code.
Command itself.
Код:
CMD:buyhouse(playerid, params[]) { if(IsPlayerInRangeOfPoint(playerid, 100.0, 1109.0, 1537.0, 5.0) && PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_WHITE, "You cannot use this command in this area!"); new string[128]; new playername[MAX_PLAYER_NAME]; new sendername[MAX_PLAYER_NAME]; 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(IsPlayerInRangeOfPoint(playerid,2.0,HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]) ) { if(PlayerInfo[playerid][pFreezeHouse] == 1) { return SendClientMessageEx(playerid, COLOR_WHITE, "ERROR: Your house assets are frozen, you cannot buy a house!"); } if( 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]); SendClientMessageEx(playerid, COLOR_GRAD5, string); return 1; } if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID) { if(GetPlayerCash(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); GivePlayerCash(playerid,-HouseInfo[h][hValue]); SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]); SetPlayerPosEx(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]); 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][hHInteriorWorld]; SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!"); SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!"); SaveHouse(h); OnPlayerStatsUpdate(playerid); PlayerInfo[playerid][pVW] = h+6000; SetPlayerVirtualWorld(playerid, h+6000); DestroyPickupEx(HouseInfo[h][hPickupID]); HouseInfo[h][hPickupID] = CreatePickupEx(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]); format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h); UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string); format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),GetPlayerIpEx(playerid),h,HouseInfo[h][hValue]); Log("logs/house.log", string); if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME); return 1; } else { SendClientMessageEx(playerid, COLOR_WHITE, " You don't have the cash for that!"); return 1; } } else if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID) { if(GetPlayerCash(playerid) > HouseInfo[h][hValue]) { PlayerInfo[playerid][pPhousekey2] = h; HouseInfo[h][hOwned] = 1; GetPlayerName(playerid, sendername, sizeof(sendername)); strmid(HouseInfo[h][hOwner], sendername, 0, strlen(sendername), 255); GivePlayerCash(playerid,-HouseInfo[h][hValue]); SetPlayerInterior(playerid,HouseInfo[h][hHInteriorWorld]); SetPlayerPosEx(playerid,HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ]); 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][hHInteriorWorld]; SendClientMessageEx(playerid, COLOR_WHITE, "Congratulations on your new purchase!"); SendClientMessageEx(playerid, COLOR_WHITE, "Type /help to review the property help section!"); SaveHouse(h); OnPlayerStatsUpdate(playerid); PlayerInfo[playerid][pVW] = h+6000; SetPlayerVirtualWorld(playerid, h+6000); DestroyPickupEx(HouseInfo[h][hPickupID]); HouseInfo[h][hPickupID] = CreatePickupEx(1273, 23, HouseInfo[h][hExteriorX], HouseInfo[h][hExteriorY], HouseInfo[h][hExteriorZ]); format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[h][hOwner],HouseInfo[h][hLevel],h); UpdateDynamic3DTextLabelText(HouseInfo[h][hTextID], COLOR_GREEN, string); format(string,sizeof(string),"%s (IP: %s) has bought house ID %d for $%d.",GetPlayerNameEx(playerid),GetPlayerIpEx(playerid),h,HouseInfo[h][hValue]); Log("logs/house.log", string); if(HouseInfo[h][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[h][hInteriorX],HouseInfo[h][hInteriorY],HouseInfo[h][hInteriorZ], FREEZE_TIME); return 1; } else { SendClientMessageEx(playerid, COLOR_WHITE, " You don't have the cash for that!"); return 1; } } } else { SendClientMessageEx( playerid, COLOR_WHITE, "This house is owned." ); } } } return 1; }
Код:
stock SaveHouse(houseid) { new string[2048]; format(string, sizeof(string), "UPDATE `houses` SET \ `Owned`=%d, \ `Level`=%d, \ `HInteriorWorld`=%d, \ `Description`='%s', \ `Owner`='%s', \ `ExteriorX`=%f, \ `ExteriorY`=%f, \ `ExteriorZ`=%f, \ `ExteriorR`=%f, \ `InteriorX`=%f, \ `InteriorY`=%f, \ `InteriorZ`=%f, \ `InteriorR`=%f,", HouseInfo[houseid][hOwned], HouseInfo[houseid][hLevel], HouseInfo[houseid][hHInteriorWorld], HouseInfo[houseid][hDescription], HouseInfo[houseid][hOwner], HouseInfo[houseid][hExteriorX], HouseInfo[houseid][hExteriorY], HouseInfo[houseid][hExteriorZ], HouseInfo[houseid][hExteriorR], HouseInfo[houseid][hInteriorX], HouseInfo[houseid][hInteriorY], HouseInfo[houseid][hInteriorZ], HouseInfo[houseid][hInteriorR] ); format(string, sizeof(string), "%s \ `Lock`=%d, \ `Rentable`=%d, \ `RentFee`=%d, \ `Value`=%d, \ `SafeMoney`=%d, \ `Pot`=%d, \ `Crack`=%d, \ `Materials`=%d, \ `Weapons0`=%d, \ `Weapons1`=%d, \ `Weapons2`=%d, \ `Weapons3`=%d, \ `Weapons4`=%d, \ `GLUpgrade`=%d, \ `CustomInterior`=%d, \ `CustomExterior`=%d, \ `ExteriorA`=%f, \ `InteriorA`=%f WHERE `id`=%d", string, HouseInfo[houseid][hLock], HouseInfo[houseid][hRentable], HouseInfo[houseid][hRentFee], HouseInfo[houseid][hValue], HouseInfo[houseid][hSafeMoney], HouseInfo[houseid][hPot], HouseInfo[houseid][hCrack], HouseInfo[houseid][hMaterials], HouseInfo[houseid][hWeapons][0], HouseInfo[houseid][hWeapons][1], HouseInfo[houseid][hWeapons][2], HouseInfo[houseid][hWeapons][3], HouseInfo[houseid][hWeapons][4], HouseInfo[houseid][hGLUpgrade], HouseInfo[houseid][hCustomInterior], HouseInfo[houseid][hCustomExterior], HouseInfo[houseid][hExteriorA], HouseInfo[houseid][hInteriorA], houseid+1 ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one). mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD); }
Код:
stock SaveHouses() { for(new i = 0; i < MAX_HOUSES; i++) { SaveHouse(i); } return 1; }
Код:
stock RehashHouse(houseid) { printf("[RehashHouse] Deleting HouseID %d from server...", houseid); DestroyPickupEx(HouseInfo[houseid][hPickupID]); if(IsValidDynamic3DTextLabel(HouseInfo[houseid][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[houseid][hTextID]); HouseInfo[houseid][hSQLId] = -1; HouseInfo[houseid][hOwned] = 0; HouseInfo[houseid][hLevel] = 0; HouseInfo[houseid][hHInteriorWorld] = 0; HouseInfo[houseid][hExteriorX] = 0.0; HouseInfo[houseid][hExteriorY] = 0.0; HouseInfo[houseid][hExteriorZ] = 0.0; HouseInfo[houseid][hExteriorR] = 0.0; HouseInfo[houseid][hInteriorX] = 0.0; HouseInfo[houseid][hInteriorY] = 0.0; HouseInfo[houseid][hInteriorZ] = 0.0; HouseInfo[houseid][hInteriorR] = 0.0; HouseInfo[houseid][hLock] = 0; HouseInfo[houseid][hRentable] = 0; HouseInfo[houseid][hRentFee] = 0; HouseInfo[houseid][hValue] = 0; HouseInfo[houseid][hSafeMoney] = 0; HouseInfo[houseid][hPot] = 0; HouseInfo[houseid][hCrack] = 0; HouseInfo[houseid][hMaterials] = 0; HouseInfo[houseid][hWeapons][0] = 0; HouseInfo[houseid][hWeapons][1] = 0; HouseInfo[houseid][hWeapons][2] = 0; HouseInfo[houseid][hWeapons][3] = 0; HouseInfo[houseid][hWeapons][4] = 0; HouseInfo[houseid][hGLUpgrade] = 0; HouseInfo[houseid][hCustomInterior] = 0; HouseInfo[houseid][hCustomExterior] = 0; HouseInfo[houseid][hExteriorA] = 0; HouseInfo[houseid][hInteriorA] = 0; LoadHouse(houseid); }
Код:
stock RehashHouses() { printf("[RehashHouses] Deleting houses from server..."); for(new i = 0; i < MAX_HOUSES; i++) { DestroyPickupEx(HouseInfo[i][hPickupID]); if(IsValidDynamic3DTextLabel(HouseInfo[i][hTextID])) DestroyDynamic3DTextLabel(HouseInfo[i][hTextID]); HouseInfo[i][hSQLId] = -1; HouseInfo[i][hOwned] = 0; HouseInfo[i][hLevel] = 0; HouseInfo[i][hHInteriorWorld] = 0; HouseInfo[i][hExteriorX] = 0.0; HouseInfo[i][hExteriorY] = 0.0; HouseInfo[i][hExteriorZ] = 0.0; HouseInfo[i][hExteriorR] = 0.0; HouseInfo[i][hInteriorX] = 0.0; HouseInfo[i][hInteriorY] = 0.0; HouseInfo[i][hInteriorZ] = 0.0; HouseInfo[i][hInteriorR] = 0.0; HouseInfo[i][hLock] = 0; HouseInfo[i][hRentable] = 0; HouseInfo[i][hRentFee] = 0; HouseInfo[i][hValue] = 0; HouseInfo[i][hSafeMoney] = 0; HouseInfo[i][hPot] = 0; HouseInfo[i][hCrack] = 0; HouseInfo[i][hMaterials] = 0; HouseInfo[i][hWeapons][0] = 0; HouseInfo[i][hWeapons][1] = 0; HouseInfo[i][hWeapons][2] = 0; HouseInfo[i][hWeapons][3] = 0; HouseInfo[i][hWeapons][4] = 0; HouseInfo[i][hGLUpgrade] = 0; HouseInfo[i][hCustomInterior] = 0; HouseInfo[i][hCustomExterior] = 0; HouseInfo[i][hExteriorA] = 0; HouseInfo[i][hInteriorA] = 0; } LoadHouses(); }
Код:
stock LoadHouse(houseid) { new string[128]; printf("[LoadHouse] Loading HouseID %d's data from database...", houseid); format(string, sizeof(string), "SELECT * FROM `houses` WHERE `id`=%d",houseid+1); // Array starts at zero, MySQL starts at one. mysql_function_query(MainPipeline, string, true, "OnLoadHouse", "i", houseid); }
Код:
forward OnLoadHouse(index); public OnLoadHouse(index) { new string[64]; new rows, fields; cache_get_data(rows, fields, MainPipeline); for(new field;field<fields;field++) { cache_get_row(index, field, string, MainPipeline); switch(field) { case 0: HouseInfo[index][hSQLId] = strval(string); case 1: HouseInfo[index][hOwned] = strval(string); case 2: HouseInfo[index][hLevel] = strval(string); case 3: HouseInfo[index][hHInteriorWorld] = strval(string); case 4: format(HouseInfo[index][hDescription], 16, "%s", string); case 5: format(HouseInfo[index][hOwner], 24, "%s", string); case 6: HouseInfo[index][hExteriorX] = floatstr(string); case 7: HouseInfo[index][hExteriorY] = floatstr(string); case 8: HouseInfo[index][hExteriorZ] = floatstr(string); case 9: HouseInfo[index][hExteriorR] = floatstr(string); case 10: HouseInfo[index][hInteriorX] = floatstr(string); case 11: HouseInfo[index][hInteriorY] = floatstr(string); case 12: HouseInfo[index][hInteriorZ] = floatstr(string); case 13: HouseInfo[index][hInteriorR] = floatstr(string); case 14: HouseInfo[index][hLock] = strval(string); case 15: HouseInfo[index][hRentable] = strval(string); case 16: HouseInfo[index][hRentFee] = strval(string); case 17: HouseInfo[index][hValue] = strval(string); case 18: HouseInfo[index][hSafeMoney] = strval(string); case 19: HouseInfo[index][hPot] = strval(string); case 20: HouseInfo[index][hCrack] = strval(string); case 21: HouseInfo[index][hMaterials] = strval(string); case 22: HouseInfo[index][hWeapons][0] = strval(string); case 23: HouseInfo[index][hWeapons][1] = strval(string); case 24: HouseInfo[index][hWeapons][2] = strval(string); case 25: HouseInfo[index][hWeapons][3] = strval(string); case 26: HouseInfo[index][hWeapons][4] = strval(string); case 27: HouseInfo[index][hGLUpgrade] = strval(string); case 28: HouseInfo[index][hPickupID] = strval(string); case 29: HouseInfo[index][hCustomInterior] = strval(string); case 30: HouseInfo[index][hCustomExterior] = strval(string); case 31: HouseInfo[index][hExteriorA] = floatstr(string); case 32: HouseInfo[index][hInteriorA] = floatstr(string); } } if(HouseInfo[index][hOwned]) { if(!HouseInfo[index][hRentable]) format(string, sizeof(string), "This house is owned by\n%s\nLevel: %d\nID: %d",HouseInfo[index][hOwner], HouseInfo[index][hLevel], index); else format(string, sizeof(string), "This house is owned by\n%s\nRent: $%d\nLevel: %d\nID: %d\nType /rentroom to rent a room", HouseInfo[index][hOwner], HouseInfo[index][hRentFee], HouseInfo[index][hLevel], index); } else format(string, sizeof(string), "This house is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nID: %d\nTo buy this house type /buyhouse",HouseInfo[index][hDescription],HouseInfo[index][hValue],HouseInfo[index][hLevel],index); HouseInfo[index][hPickupID] = CreatePickupEx(1273, 23, HouseInfo[index][hExteriorX], HouseInfo[index][hExteriorY], HouseInfo[index][hExteriorZ]); HouseInfo[index][hTextID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[index][hExteriorX], HouseInfo[index][hExteriorY], HouseInfo[index][hExteriorZ]+0.5,10.0, .testlos = 1, .streamdistance = 10.0); return 1; }
Код:
stock LoadHouses() { printf("[LoadHouses] Loading data from database..."); mysql_function_query(MainPipeline, "SELECT * FROM `houses`", true, "OnLoadHouses", ""); }
Код:
forward OnLoadHouses(); public OnLoadHouses() { new string[512], iIndex; new rows, fields; cache_get_data(rows, fields, MainPipeline); while(iIndex<rows) { for(new field;field<fields;field++) { cache_get_row(iIndex, field, string, MainPipeline); switch(field) { case 0: HouseInfo[iIndex][hSQLId] = strval(string); case 1: HouseInfo[iIndex][hOwned] = strval(string); case 2: HouseInfo[iIndex][hLevel] = strval(string); case 3: HouseInfo[iIndex][hHInteriorWorld] = strval(string); case 4: format(HouseInfo[iIndex][hDescription], 16, "%s", string); case 5: format(HouseInfo[iIndex][hOwner], 24, "%s", string); case 6: HouseInfo[iIndex][hExteriorX] = floatstr(string); case 7: HouseInfo[iIndex][hExteriorY] = floatstr(string); case 8: HouseInfo[iIndex][hExteriorZ] = floatstr(string); case 9: HouseInfo[iIndex][hExteriorR] = floatstr(string); case 10: HouseInfo[iIndex][hInteriorX] = floatstr(string); case 11: HouseInfo[iIndex][hInteriorY] = floatstr(string); case 12: HouseInfo[iIndex][hInteriorZ] = floatstr(string); case 13: HouseInfo[iIndex][hInteriorR] = floatstr(string); case 14: HouseInfo[iIndex][hLock] = strval(string); case 15: HouseInfo[iIndex][hRentable] = strval(string); case 16: HouseInfo[iIndex][hRentFee] = strval(string); case 17: HouseInfo[iIndex][hValue] = strval(string); case 18: HouseInfo[iIndex][hSafeMoney] = strval(string); case 19: HouseInfo[iIndex][hPot] = strval(string); case 20: HouseInfo[iIndex][hCrack] = strval(string); case 21: HouseInfo[iIndex][hMaterials] = strval(string); case 22: HouseInfo[iIndex][hWeapons][0] = strval(string); case 23: HouseInfo[iIndex][hWeapons][1] = strval(string); case 24: HouseInfo[iIndex][hWeapons][2] = strval(string); case 25: HouseInfo[iIndex][hWeapons][3] = strval(string); case 26: HouseInfo[iIndex][hWeapons][4] = strval(string); case 27: HouseInfo[iIndex][hGLUpgrade] = strval(string); case 28: HouseInfo[iIndex][hPickupID] = strval(string); case 29: HouseInfo[iIndex][hCustomInterior] = strval(string); case 30: HouseInfo[iIndex][hCustomExterior] = strval(string); case 31: HouseInfo[iIndex][hExteriorA] = floatstr(string); case 32: HouseInfo[iIndex][hInteriorA] = floatstr(string); } } if(HouseInfo[iIndex][hOwned]) { if(!HouseInfo[iIndex][hRentable]) format(string, sizeof(string), "This house is owned by\n%s\nLevel: %d\nID: %d",HouseInfo[iIndex][hOwner], HouseInfo[iIndex][hLevel], iIndex); else format(string, sizeof(string), "This house is owned by\n%s\nRent: $%d\nLevel: %d\nID: %d\nType /rentroom to rent a room", HouseInfo[iIndex][hOwner], HouseInfo[iIndex][hRentFee], HouseInfo[iIndex][hLevel], iIndex); } else format(string, sizeof(string), "This house is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\nID: %d\nTo buy this house type /buyhouse",HouseInfo[iIndex][hDescription],HouseInfo[iIndex][hValue],HouseInfo[iIndex][hLevel],iIndex); HouseInfo[iIndex][hPickupID] = CreatePickupEx(1273, 23, HouseInfo[iIndex][hExteriorX], HouseInfo[iIndex][hExteriorY], HouseInfo[iIndex][hExteriorZ]); HouseInfo[iIndex][hTextID] = CreateDynamic3DTextLabel(string, COLOR_GREEN, HouseInfo[iIndex][hExteriorX], HouseInfo[iIndex][hExteriorY], HouseInfo[iIndex][hExteriorZ]+0.5,10.0, .testlos = 1, .streamdistance = 10.0); iIndex++; } if(iIndex > 0) printf("[LoadHouses] %d houses rehashed/loaded.", iIndex); else printf("[LoadHouses] Failed to load any houses."); return 1; }

EDIT:It's really werid , i still can't find the problem..