07.12.2014, 17:23
Sure. Here it is:
Sorry for all the code, it looks really messy but I hope it will help.
Here is some more info:
pawn Код:
CMD:payrent(playerid, params[])
{
new id = PlayerInfo[playerid][HotelRoom];
if(!IsPlayerConnected(playerid)) return 1;
if(id == -1) return SendClientMessage(playerid, -1, "You don't own a hotel room.");
//new year, month, day, minute, hour, second;
new year, month, day, hour, minute, second;
new string[128];
if(HotelInfo[id][Paid] == true)
{
printf("id: %d | timestamp: %d", id, HotelInfo[id][PayDate]);
TimestampToDate(HotelInfo[id][PayDate], year, month, day, hour, minute, second, 2);
SendClientMessage(playerid, -1, "You have already paid the rent.");
format(string, sizeof(string), "Your rent will expire on %d.%d.%d %d:%d", day, month, year, minute, hour);
SendClientMessage(playerid, -1, string);
return 1;
}
// from now on this isn't so important I think
switch(HotelInfo[id][Level])
{
case 1:
{
PlayerMoney(playerid, -LEVEL_1_RENT);
}
case 2:
{
PlayerMoney(playerid, -LEVEL_2_RENT);
}
case 3:
{
PlayerMoney(playerid, -LEVEL_3_RENT);
}
}
HotelInfo[id][PayDate] = gettime() + RENT_DAYS * 86400;
HotelInfo[id][Paid] = true;
TimestampToDate(HotelInfo[id][PayDate], year, month, day, hour, minute, second, 2);
SendClientMessage(playerid, -1, "You have paid your rent.");
format(string, sizeof(string), "You rent will expire in %d days, which is on:", RENT_DAYS);
SendClientMessage(playerid, -1, string);
format(string, sizeof(string), "%d.%d.%d %d:%d", day, month, year, minute, hour);
SendClientMessage(playerid, -1, string);
return 1;
}
Here is some more info:
pawn Код:
enum hInfo
{
Owner[MAX_PLAYER_NAME],
bool:Paid,
PayDate // timestamp is stored here
};
new HotelInfo[MAX_HOTEL_ROOMS][hInfo];