12.06.2014, 09:20
Hello. So my problem is that when i type command /housecreate in game i create house but when i try to buy it server say that there is no house near me.. And i don't know where is the problem....
This is my command code..
And the code of buying command
In attachments you find some photos if you can't understand what i am talking about... And sorry for my bad english..
This is my command code..
Код:
CMD:housecreate(playerid, params[]) { new Float: X, Float: Y, Float: Z, hlabel[128], h; GetPlayerPos(playerid, X, Y, Z); if(pInfo[playerid][Admin] < 3) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You're not an administrator!"); new INI:File = INI_Open(HousePath(h)); INI_SetTag(File, "House Data"); INI_WriteString(File, "Owner", "None"); INI_WriteInt(File, "Price", 25000); INI_WriteInt(File, "Bought", 0); INI_WriteFloat(File, "extX", X); INI_WriteFloat(File, "extY", Y); INI_WriteFloat(File, "extZ", Z); INI_WriteFloat(File, "intX", 244.411987); INI_WriteFloat(File, "intY", 305.032989); INI_WriteFloat(File, "intZ", 999.148437); INI_WriteInt(File, "intVW", random(999)); INI_WriteInt(File, "intW", 1); INI_Close(File); format(hlabel, 128, "[HOUSE: FOR SALE]\n{46E850}[Owner]{FFFFFF}: None\n{46E850}[Price]{FFFFFF}: $25000"); Create3DTextLabel(hlabel, 0xFFFFFFFF, X, Y, Z, 15.0, 0, 1); return 1; }
Код:
CMD:housebuy(playerid, params[]) { new str1[128], name[MAX_PLAYER_NAME+1], pNearHouse[MAX_PLAYERS] = 0, fee, str2[128]; GetPlayerName(playerid, name, sizeof(name)); if(pInfo[playerid][HouseOwner] < 9999) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You already own a house!"); for(new i = 0; i < MAX_HOUSES; i++) { if(IsPlayerInRangeOfPoint(playerid, 2.0, hInfo[i][extX], hInfo[i][extY], hInfo[i][extZ])) { if(hInfo[i][Bought] == 1) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} This house is already bought!"); if(GetPlayerMoney(playerid) < hInfo[i][Price]) return SendClientMessage(playerid, 0x46E850FF, "SERVER:{FFFFFF} You can't afford this house!"); else if(hInfo[i][Bought] == 0) { pNearHouse[playerid] = 1; pInfo[playerid][HouseOwner] = i; hInfo[i][Owner] = name; hInfo[i][Bought] = 1; format(str2, 128, "[HOUSE]\n{46E850}[Owner]{FFFFFF}: %s\n{46E850}[Price]{FFFFFF}: %d", hInfo[i][Owner], hInfo[i][Price]); Update3DTextLabelText(Text3D: i, 0x46E850FF, str2); format(str1, sizeof(str1), "SERVER:{FFFFFF} You bought house ID %d for %d! (DEBUG: %d)", i, hInfo[i][Price], pInfo[playerid][HouseOwner]); fee = hInfo[i][Price]; } } } if(pNearHouse[playerid] == 0) format(str1, sizeof(str1), "SERVER:{FFFFFF} You're not near any house!"); SendClientMessage(playerid, 0x46E850FF, str1); GivePlayerMoney(playerid, -fee); ReloadLabels(); return 1; }