Código:
public OnGameModeInit()
{
if(!dini_Exists("/Interiores/int0.ini"))
{
dini_Create("/Interiores/int0.ini");
dini_IntSet("/Interiores/int0.ini", "Int", 1);
dini_FloatSet("/Interiores/int0.ini", "EX", 222.9534);
dini_FloatSet("/Interiores/int0.ini", "EY", 1287.7649);
dini_FloatSet("/Interiores/int0.ini", "EZ", 1082.1406);
}
return 1;
}
if(strcmp(cmd, "/criarcasa", true) == 0)
{
new preco, cint,
Float:X, Float:Y, Float:Z;
if(sscanf(cmdtext, "s[11]dd", cmd, preco, cint))
{
SendClientMessage(playerid, -1, "/criarcasa [preço] [interior]");
return 1;
}
GetPlayerPos(playerid, X, Y, Z);
PlayerCreateHause(playerid, preco, cint, X, Y, Z, GetPlayerInterior(playerid));
return 1;
}
stock PlayerCreateHause(playerid, casapreco, casaint, Float:Xp, Float:Yp, Float:Zp, Ip)
{
//new year, month, day, data[128], msg[128], strc[128], strc2[128], casafile[128], pickupid, iconid;
new year, month, day, data[128], pickupid, iconid, string[128];
if(!(casaint <= proximoint))
{
format(string, sizeof (string), "Use um interior válido de 0 até %d", proximoint);
SendClientMessage(playerid, -1, string);
return 1;
}
for(new c = 0; c < MAX_CASAS; c++)
{
format(string, sizeof (string), PASTA_CASAS, c);
if(dini_Exists(string))
{
if(IsPlayerInRangeOfPoint(playerid, 30.0, dini_Float(string, "PosX"), dini_Float(string, "PosY"), dini_Float(string, "PosZ")))
{
SendClientMessage(playerid, -1, "não pode ser criada mais casa neste local.");
return 1;
}
if(dini_Int(string, "TDono") == 3)
{
getdate(year, month, day);
format(data, sizeof(data), "%d/%d/%d", day, month, year);
dini_FloatSet(string, "PosX", Xp);
dini_FloatSet(string, "PosY", Yp);
dini_FloatSet(string, "PosZ", Zp);
dini_IntSet(string, "Int", casaint);
dini_IntSet(string, "IntID", Ip);
dini_IntSet(string, "Mundo", c);
dini_IntSet(string, "TDono", 0);
dini_Set(string, "Dono", "Ninguem");
dini_IntSet(string, "Preco", casapreco);
dini_IntSet(string, "Trancada", 0);
dini_IntSet(string, "TMorador", 0);
dini_Set(string, "Morador", "Ninguem");
dini_Set(string, "DataSet", data);
pickupid = CreateDynamicPickup(1273, 1, Xp, Yp, Zp, -1, -1, -1, 200.0);
dini_IntSet(string, "Id", pickupid);
iconid = CreateDynamicMapIcon(Xp, Yp, Zp, 31, 0, -1, -1, -1, 100.0);
dini_IntSet(string, "IconId", iconid);
format(string, sizeof (string), "Casa ID %d\nDono Ninguem\nMorador Ninguem\nValor R$%d\n\nUsada %s", c, casapreco, data);
ctextoid[c] = CreateDynamic3DTextLabel(string, -1, Xp, Yp, Zp, 30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 200.0);
format(string, sizeof (string), "%s criou uma casa. Local: %s, ID: %d", GetPlayerNameEx(playerid), GetPlayerArea(playerid), c);
SendClientMessageToAll(0x00FFFFAA, string);
CasaLog(string);
return 1;
}
}
}
if(proximacasa >= MAX_CASAS-1)
{
format(string, sizeof (string), "O limite de %d casas foi atingido, não ? poss?vel criar mais.", MAX_CASAS);
SendClientMessage(playerid, -1, string);
return 1;
}
format(string, sizeof (string), PASTA_CASAS, proximacasa);
if(dini_Exists(string))
{
proximacasa++;
}
getdate(year, month, day);
format(data, sizeof(data), "%d/%d/%d", day, month, year);
format(string, sizeof (string), PASTA_CASAS, proximacasa);
dini_Create(string);
dini_FloatSet(string, "PosX", Xp);
dini_FloatSet(string, "PosY", Yp);
dini_FloatSet(string, "PosZ", Zp);
dini_IntSet(string, "Int", casaint);
dini_IntSet(string, "IntID", Ip);
dini_IntSet(string, "Mundo", proximacasa);
dini_IntSet(string, "TDono", 0);
dini_Set(string, "Dono", "Ninguem");
dini_IntSet(string, "Preco", casapreco);
dini_IntSet(string, "Trancada", 0);
dini_IntSet(string, "TMorador", 0);
dini_Set(string, "Morador", "Ninguem");
dini_Set(string, "DataSet", data);
pickupid = CreateDynamicPickup(1273, 1, Xp, Yp, Zp, -1, -1, -1, 200.0);
dini_IntSet(string, "Id", pickupid);
iconid = CreateDynamicMapIcon(Xp, Yp, Zp, 31, 0, -1, -1, -1, 100.0);
dini_IntSet(string, "IconId", iconid);
format(string, sizeof (string), "Casa ID %d\nDono Ninguem\nMorador Ninguem\nValor R$%d\n\nUsada %s", proximacasa, casapreco, data);
ctextoid[proximacasa] = CreateDynamic3DTextLabel(string, -1, Xp, Yp, Zp, 30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, -1, -1, -1, 200.0);
format(string, sizeof (string), "%s criou uma casa! local %s id %d", GetPlayerNameEx(playerid), GetPlayerArea(playerid), proximacasa);
SendClientMessageToAll(0x00FFFFAA, string);
CasaLog(string);
proximacasa++;
return 1;
}