14.04.2016, 10:28
hi guys i did an auto sell house but is not completed the house will auto sell only if player will connect after 7 days or the house contract expire but the house will auto sell and give for all a message only if the player will connect to server , how can i do after 7 days if the player didn't connect to server the house will auto sell ? some ideas
This is the system:
/buyhouse - command
WhenPlayerLogin - when the player login to server here is the message and auto sell if the house contract expires
how can i do only for 7 days timer then activate the auto sell house
This is the system:
/buyhouse - command
Код HTML:
CMD:buyhouse(playerid, params[]) { if(gLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are not logged in."); if(PlayerInfo[playerid][pHouseKey] != 0) return SendClientMessage(playerid, COLOR_ERROR, "You already own a house, type /sellhouse if you want to buy this one."); new h = 0; for(new i = 1; i < sizeof(HouseInfo); i++) { if(IsPlayerInRangeOfPoint(playerid, 2.0, HouseInfo[i][hEntranceX], HouseInfo[i][hEntranceY], HouseInfo[i][hEntranceZ])) { h = i; break; // Iesire din loop , nu mai e nevoie sa caute alta casa din moment ce a gasit una. } } if(!h) return 1; new bool: success = false, price = 0; if(!HouseInfo[h][hOwned]) { if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel]) { format(gString, sizeof(gString), "You need level %d to purchase this house.", HouseInfo[h][hLevel]); SendClientMessage(playerid, COLOR_ERROR, gString); return 1; } success = true; price = HouseInfo[h][hValue]; } else if(HouseInfo[h][hOwned] && HouseInfo[h][hSellPrice] > 0) { if(PlayerInfo[playerid][pLevel] < HouseInfo[h][hLevel]) { format(gString, sizeof(gString), "You need level %d to purchase this house.", HouseInfo[h][hLevel]); SendClientMessage(playerid, COLOR_ERROR, gString); return 1; } success = true; price = HouseInfo[h][hSellPrice]; } else if(HouseInfo[h][hOwned] && !HouseInfo[h][hSellPrice]) { success = false; return SendClientMessage(playerid, COLOR_ERROR, "This house is not for sale."); } if(success) { if(GetPlayerCash(playerid) < price) return SendClientMessage(playerid, COLOR_ERROR, "You don't have enough money."); PlayerInfo[playerid][pHouseKey] = h; Update(playerid,pHouseKeyx); PlayerInfo[playerid][pRentKey] = 0; Update(playerid,pRentKeyx); if(HouseInfo[h][hOwned] && HouseInfo[h][hSellPrice]) { new id = GetPlayerID(HouseInfo[h][hOwner]); if(id != INVALID_PLAYER_ID) { GivePlayerCash(id, HouseInfo[h][hSellPrice] - HouseInfo[h][hLevel]*10000); SendClientMessage(id, COLOR_YELLOW, "Your house has been sold."); PlayerInfo[id][pHouseKey] = 0; Update(id,pHouseKeyx); } else { if(ExistName(HouseInfo[h][hOwner])) { gQuery[0] = EOS; mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `Cash`='Cash'+'%d',`HouseKey`='0' WHERE Name='%e'", price - HouseInfo[h][hLevel]*10000, HouseInfo[h][hOwner]); mysql_query(handle, gQuery); } } } new day,month,year; getdate(year,month,day); new monthh; new dayy; new yearr; new x_nr = 7; if(x_nr <= 31) { if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if(day+x_nr>31) { monthh = month + 1; dayy = x_nr+day-31; } else { dayy = day + x_nr; monthh = month; } if(monthh > 12) { yearr = year + 1; monthh = monthh % 12; } else { yearr = year; } } else if(month == 4 || month == 6 || month == 9 || month == 11) { if(day+x_nr>30) { monthh = month + 1; dayy = x_nr+day-30; } else { dayy = day + x_nr; monthh = month; } if(monthh > 12) { yearr =year + 1; monthh = monthh % 12; } else { yearr = year; } } else { if(day+x_nr>28 && year / 4 != 0) { monthh = month + 1; dayy = x_nr+day-28; } else if(day+x_nr>29 && year / 4 == 0) { monthh = month + 1; dayy = x_nr+day-29; } else { dayy = day + x_nr; monthh = month; } yearr = year; } } else { monthh = month + (x_nr / 30); dayy = (day+ x_nr) % 30; yearr = year + (monthh / 12); monthh = monthh % 12; } PlayerInfo[playerid][pPCday] = dayy; PlayerInfo[playerid][pPCmonth] = monthh; PlayerInfo[playerid][pPCyear] = yearr; gQuery[0] = EOS; mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCday` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCday], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCmonth` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCmonth], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCyear` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCyear], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); HouseInfo[h][hOwned] = 1; hUpdate(h, hOwnedx); strmid(HouseInfo[h][hOwner], GetName(playerid), 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME); hUpdate(h, hOwnerx); HouseInfo[h][hSellPrice] = 0; hUpdate(h, hSellPricex); HouseInfo[h][hValue] = HouseInfo[h][hLevel]*10000; hUpdate(h, hValuex); GivePlayerCash(playerid, -price); SetPlayerInterior(playerid,HouseInfo[h][hInt]); SetPlayerVirtualWorld(playerid,HouseInfo[h][hWorld]); SetPlayerPos(playerid,HouseInfo[h][hExitX],HouseInfo[h][hExitY],HouseInfo[h][hExitZ]); HouseEntered[playerid] = h; PlayerInfo[playerid][pSpawnChange] = 2; Update(playerid, pSpawnChangex); GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by moving to this door and typing /exit", 5000, 3); SendClientMessage(playerid, COLOR_SYN2, "Congratulations, for your new purchase !"); SendClientMessage(playerid, COLOR_SYN2, "Type /househelp to review the new property help section !"); HouseUpdate(h); GiveAchievement(playerid, 3, "Buy a house", 100); } return 1; }
how can i do only for 7 days timer then activate the auto sell house
Код HTML:
function WhenPlayerLogin(playerid) { if(IsPlayerConnected(playerid)) { new dayy, monthh, yearr; getdate(yearr, monthh, dayy); if(yearr > PlayerInfo[playerid][pPCyear]) { if(PlayerInfo[playerid][pPCday] != 0) { gQuery[0] = EOS; PlayerInfo[playerid][pPCday] = 0; PlayerInfo[playerid][pPCmonth] = 0; PlayerInfo[playerid][pPCyear] = 0; mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCday` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCday], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCmonth` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCmonth], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCyear` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCyear], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); format(gString, 256, "{a9c4e4}Bot:{a9c4e4} Casa lui: %s este acum de vanzare", PlayerInfo[playerid][pSQLID]); SendClientMessageToAll(0xE0FFFFAA, gString); } } else if(yearr == PlayerInfo[playerid][pPCyear] && monthh >= PlayerInfo[playerid][pPCmonth]) { if(monthh > PlayerInfo[playerid][pPCmonth]) { if(PlayerInfo[playerid][pPCday] != 0) { gQuery[0] = EOS; PlayerInfo[playerid][pPCday] = 0; PlayerInfo[playerid][pPCmonth] = 0; PlayerInfo[playerid][pPCyear] = 0; mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCday` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCday], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCmonth` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCmonth], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCyear` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCyear], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); format(gString, 256, "{a9c4e4}Bot:{a9c4e4} Casa lui: %s este acum de vanzare", PlayerInfo[playerid][pSQLID]); SendClientMessageToAll(0xE0FFFFAA, gString); } } else if(monthh == PlayerInfo[playerid][pPCmonth] && dayy >= PlayerInfo[playerid][pPCday]) { if(PlayerInfo[playerid][pPCday] != 0) { gQuery[0] = EOS; PlayerInfo[playerid][pPCday] = 0; PlayerInfo[playerid][pPCmonth] = 0; PlayerInfo[playerid][pPCyear] = 0; mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCday` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCday], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCmonth` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCmonth], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); mysql_format(handle, gQuery, sizeof(gQuery), "UPDATE `players` SET `PCyear` = '%d' WHERE `id` = %d", PlayerInfo[playerid][pPCyear], PlayerInfo[playerid][pSQLID]); mysql_query(handle, gQuery); format(gString, 256, "{a9c4e4}Bot:{a9c4e4} Casa lui: %s este acum de vanzare", PlayerInfo[playerid][pSQLID]); SendClientMessageToAll(0xE0FFFFAA, gString); } } } }