CMD:createhouse(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GRAD1, " You are not authorized to use that command !");
new price, interiorid, houseid, Float:X, Float:Y, Float:Z, Float:A, check = 0;
if(sscanf(params, "dd", price, interiorid))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /createhouse [price] [interior id]");
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /viewinterior [1-31]");
return 1;
}
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
for(new i = 1; i < sizeof(HouseInfo); i++)
{
if(HouseInfo[i][hCreated] == 0)
{
check = 1;
houseid = i;
break;
}
}
if(!check) return SendClientMessage(playerid, COLOR_GRAD2, " 2000/2000 houses have already been created !");
HouseInfo[houseid][hOutsideX] = X;
HouseInfo[houseid][hOutsideY] = Y;
HouseInfo[houseid][hOutsideZ] = Z;
HouseInfo[houseid][hOutsideA] = A;
HouseInfo[houseid][hCreated] = 1;
HouseInfo[houseid][hValue] = price;
strdel(HouseInfo[houseid][hTag], 0, strlen(HouseInfo[houseid][hTag]));
strins(HouseInfo[houseid][hTag], "House", 0);
SetHouseInterior(houseid, interiorid);
if(HouseInfo[houseid][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]); }
HouseInfo[houseid][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
new location[MAX_ZONE_NAME], string3[500];
Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
format(string3, sizeof(string3), "This property is for sale!\nAddress: %d %s\nType /buyhouse to buy it for $%d", houseid, location, HouseInfo[houseid][hValue]);
if(HouseInfoText3D[houseid]) { Delete3DTextLabel(HouseInfoText3D[houseid]); }
HouseInfoText3D[houseid] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
format(string, sizeof(string), " You have created houseid %d with the price of $%d and interiorid %d", houseid, price, interiorid);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
public LoadHouses()
{
new arrCoords[26][126], strFromFile2[256], File: file = fopen("houses.cfg", io_read);
if( file)
{
HouseInfo[0][hOutsidePickup] = CreateDynamicPickup(1273, 1, 0.0, 0.0, 0.0);
new idx = 1;
while (idx < sizeof(HouseInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(HouseInfo[idx][hOwner], arrCoords[0], 0, strlen(arrCoords[0]), 255);
HouseInfo[idx][hCreated] = strval(arrCoords[1]);
HouseInfo[idx][hOwned] = strval(arrCoords[2]);
HouseInfo[idx][hValue] = strval(arrCoords[3]);
HouseInfo[idx][hOutsideX] = floatstr(arrCoords[4]);
HouseInfo[idx][hOutsideY] = floatstr(arrCoords[5]);
HouseInfo[idx][hOutsideZ] = floatstr(arrCoords[6]);
HouseInfo[idx][hOutsideA] = floatstr(arrCoords[7]);
HouseInfo[idx][hInsideX] = floatstr(arrCoords[8]);
HouseInfo[idx][hInsideY] = floatstr(arrCoords[9]);
HouseInfo[idx][hInsideZ] = floatstr(arrCoords[10]);
HouseInfo[idx][hInsideA] = floatstr(arrCoords[11]);
HouseInfo[idx][hInterior] = strval(arrCoords[12]);
HouseInfo[idx][hLocked] = strval(arrCoords[13]);
HouseInfo[idx][hAlarm] = strval(arrCoords[14]);
HouseInfo[idx][hAlarmStatus] = strval(arrCoords[15]);
HouseInfo[idx][hCash] = strval(arrCoords[16]);
HouseInfo[idx][hMaterials] = strval(arrCoords[17]);
HouseInfo[idx][hPot] = strval(arrCoords[18]);
HouseInfo[idx][hCrack] = strval(arrCoords[19]);
HouseInfo[idx][hGun1] = strval(arrCoords[20]);
HouseInfo[idx][hGun2] = strval(arrCoords[21]);
HouseInfo[idx][hGun3] = strval(arrCoords[22]);
HouseInfo[idx][hGun4] = strval(arrCoords[23]);
strmid(HouseInfo[idx][hTag], arrCoords[24], 0, strlen(arrCoords[24]), 255);
new rpos = strfind(HouseInfo[idx][hTag], "\r", true);
new npos = strfind(HouseInfo[idx][hTag], "\n", true);
if(rpos != -1) { strdel(HouseInfo[idx][hTag], rpos, rpos+2); }
if(npos != -1) { strdel(HouseInfo[idx][hTag], npos, npos+2); }
HouseInfo[idx][hLevel] = strval(arrCoords[25]);
if(HouseInfo[idx][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[idx][hOutsidePickup]); }
HouseInfo[idx][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[idx][hOutsideX], HouseInfo[idx][hOutsideY], HouseInfo[idx][hOutsideZ]);
new location[MAX_ZONE_NAME], string3[500];
Get2DZone(location, MAX_ZONE_NAME, HouseInfo[idx][hOutsideX], HouseInfo[idx][hOutsideY], HouseInfo[idx][hOutsideZ]);
if(HouseInfo[idx][hOwned] == 1)
{
format(string3, sizeof(string3), "%s\nOwner: %s\nAddress: %d %s\nType /enter to go inside.", HouseInfo[idx][hTag], HouseInfo[idx][hOwner], idx, location);
HouseInfoText3D[idx] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[idx][hOutsideX], HouseInfo[idx][hOutsideY], HouseInfo[idx][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[idx], COLOR_HOUSETEXT, string3);
}
else
{
format(string3, sizeof(string3), "This property is for sale!\nAddress: %d %s\nType /buyhouse to buy it for $%d", idx, location, HouseInfo[idx][hValue]);
HouseInfoText3D[idx] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[idx][hOutsideX], HouseInfo[idx][hOutsideY], HouseInfo[idx][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[idx], COLOR_HOUSETEXT, string3);
}
format(string, sizeof(string), "%0.2f,%0.2f,%0.2f", HouseInfo[idx][hOutsideX], HouseInfo[idx][hOutsideY], HouseInfo[idx][hOutsideZ]);
if(strcmp(string, "0.00,0.00,0.00", true) == 0)
{
DestroyDynamicPickup(HouseInfo[idx][hOutsidePickup]);
Delete3DTextLabel(HouseInfoText3D[idx]);
}
idx++;
}
fclose(file);
}
return 1;
}
CMD:edithouse(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new tmp2[128];
new houseid;
if(sscanf(params, "s[128] ", tmp))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /edithouse [action] [houseid]");
SendClientMessage(playerid, COLOR_GRAD2, "ACTIONS: entrance, interior, value");
return 1;
}
if(strcmp(tmp, "entrance", true) == 0)
{
if(sscanf(params, "s[8] d", tmp2, houseid))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /edithouse entrance [houseid]");
return 1;
}
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1," That house has not even been created yet !");
HouseInfo[houseid][hOutsideX] = X;
HouseInfo[houseid][hOutsideY] = Y;
HouseInfo[houseid][hOutsideZ] = Z;
HouseInfo[houseid][hOutsideA] = A;
if(HouseInfo[houseid][hOutsidePickup]) { DestroyDynamicPickup(HouseInfo[houseid][hOutsidePickup]); }
HouseInfo[houseid][hOutsidePickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
new location[MAX_ZONE_NAME], string3[500];
Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
Delete3DTextLabel(HouseInfoText3D[houseid]);
if(HouseInfo[houseid][hOwned] == 1)
{
format(string3, sizeof(string3), "%s\nOwner: %s\nAddress: %d %s\nType /enter to go inside.", HouseInfo[houseid][hTag], HouseInfo[houseid][hOwner], houseid, location);
HouseInfoText3D[houseid] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
}
else
{
format(string3, sizeof(string3), "This property is for sale!\nAddress: %d %s\nType /buyhouse to buy it for $%d", houseid, location, HouseInfo[houseid][hValue]);
HouseInfoText3D[houseid] = Create3DTextLabel(string3, COLOR_HOUSETEXT, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]+0.88, 20.0, 0, 1);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
}
format(string, sizeof(string), " You have moved houseid %d's entrance.", houseid);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
else if(strcmp(tmp, "interior", true) == 0)
{
new interiorid;
if(sscanf(params, "s[128] dd", tmp2, houseid, interiorid))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /edithouse interior [houseid] [interiorid]");
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /viewinterior [1-31]");
return 1;
}
if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, " That house has not even been created yet !");
SetHouseInterior(houseid, interiorid);
format(string, sizeof(string), " You have edited houseid %d's interiorid to %d.", houseid, interiorid);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
else if(strcmp(tmp, "value", true) == 0)
{
new value;
if(sscanf(params, "s[128] dd", tmp2, houseid, value))
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /edithouse value [houseid] [new value]");
return 1;
}
if(HouseInfo[houseid][hCreated] == 0) return SendClientMessage(playerid, COLOR_GRAD1, " That house has not even been created yet !");
HouseInfo[houseid][hValue] = value;
new location[MAX_ZONE_NAME], string3[500];
Get2DZone(location, MAX_ZONE_NAME, HouseInfo[houseid][hOutsideX], HouseInfo[houseid][hOutsideY], HouseInfo[houseid][hOutsideZ]);
if(HouseInfo[houseid][hOwned] == 1)
{
format(string3, sizeof(string3), "%s\nOwner: %s\nAddress: %d %s\nType /enter to go inside.", HouseInfo[houseid][hTag], HouseInfo[houseid][hOwner], houseid, location);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
}
else
{
format(string3, sizeof(string3), "This property is for sale!\nAddress: %d %s\nType /buyhouse to buy it for $%d", houseid, location, HouseInfo[houseid][hValue]);
Update3DTextLabelText(HouseInfoText3D[houseid], COLOR_HOUSETEXT, string3);
}
format(string, sizeof(string), " You have edited houseid %d's value to $%d.", houseid, value);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
else
{
format(string, sizeof(string), " Invalid action \"%s\" !", tmp);
SendClientMessage(playerid, COLOR_GRAD1, string);
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " Shoma dastresie kafi baraye anjame inkar ra ndarid !");
}
return 1;
}
public SaveHouses()
{
new idx = 1;
new File:file;
file = fopen("houses.cfg", io_write);
fclose(file);
file = fopen("houses.cfg", io_append);
while(idx < sizeof(HouseInfo))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%s|%d|%d|%d|%f|%f|%f|%f|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%d\r\n",
HouseInfo[idx][hOwner],
HouseInfo[idx][hCreated],
HouseInfo[idx][hOwned],
HouseInfo[idx][hValue],
HouseInfo[idx][hOutsideX],
HouseInfo[idx][hOutsideY],
HouseInfo[idx][hOutsideZ],
HouseInfo[idx][hOutsideA],
HouseInfo[idx][hInsideX],
HouseInfo[idx][hInsideY],
HouseInfo[idx][hInsideZ],
HouseInfo[idx][hInsideA],
HouseInfo[idx][hInterior],
HouseInfo[idx][hLocked],
HouseInfo[idx][hAlarm],
HouseInfo[idx][hAlarmStatus],
HouseInfo[idx][hCash],
HouseInfo[idx][hMaterials],
HouseInfo[idx][hPot],
HouseInfo[idx][hCrack],
HouseInfo[idx][hGun1],
HouseInfo[idx][hGun2],
HouseInfo[idx][hGun3],
HouseInfo[idx][hGun4],
HouseInfo[idx][hTag],
HouseInfo[idx][hLevel]);
fwrite(file, coordsstring);
idx++;
}
fclose(file);
return 1;
}
|
Can't understand the objective of this, at "createhouse" cmd:
if(HouseInfoText3D[houseid]) { Delete3DTextLabel(HouseInfoText3D[houseid]); } Anyway, why? lol. seems weird to me |