Hello im looking for house system like CrazyBobs Cnr Server , but without sql
pawn Код:
//=========================Simple House System==================================
//-------------------------------Houses-----------------------------------------
#define MAX_HOUSES 1768
#define MAX_DISTANCE_TO_PROP 1.5
#define MAX_RENTCOST 1000
#define MIN_RENTCOST 500
new Text3D:hTextInfo[MAX_HOUSES];
new SaveFile[50] = "HouseCoord.txt";
//----------------------------
#define c_y 0xFFFF00AA
#define c_r 0xAA3333AA
new HousePickup[MAX_HOUSES];
new playerinterior[MAX_PLAYERS]=-1;
new Float:housex, Float:housey, Float:housez;
new housemapicon[MAX_HOUSES];
new playerworld[MAX_PLAYERS];
forward rentfee();
forward newcar();
forward KillVehicle(carid);
enum HouseInfo
{
Name[24],
Renter[24],
Rentable,
Rentcost,
Cost,
Sell,
Interior,
Virtualworld,
Locked,
Float:InteriorX,
Float:InteriorY,
Float:InteriorZ,
Float:iconx,
Float:icony,
Float:iconz,
Rentfee
}
new hInfo[MAX_HOUSES][HouseInfo];
new HouseID;
CMD:buyh(playerid,params[])
{
if(PlayerInfo[playerid][LoggedIn] == 0) {
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use this command");
return 1;
}
new str[255],str1[255],pname[24], housenumber;
housenumber = GetHouseID(playerid);
if(housenumber == -1) return SendClientMessage(playerid, c_r, "You are not in a house icon!");
GetPlayerName(playerid, pname, 24);
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if(dini_Exists(str1))
{
if (dini_Int(str1, "Houseid")!=-255) return SendClientMessage(playerid, c_r, "You can only buy one house!");
}
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
if (strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,true)) return SendClientMessage(playerid, c_r, "This house isn't for sale!");
if(GetPlayerMoney(playerid)<hInfo[housenumber][Cost]) return SendClientMessage(playerid, c_r, "Not enough money!");
new hsstring[128];
format(hsstring, sizeof(hsstring), "You just bought this House (ID:%i) for $%d.", housenumber, hInfo[housenumber][Cost]);
SendClientMessage(playerid, COLOR_GREEN, hsstring);
// SendClientMessage(playerid, c_y, "You have bought the house!");
format(str, sizeof(str), "%s has bought houseid %i",pname,housenumber);
print(str);
GivePlayerMoney(playerid, -hInfo[housenumber][Cost]);
dini_Set(str1, "Name", pname);
hInfo[housenumber][Name]=pname;
hInfo[housenumber][Locked] = dini_IntSet(str1,"Locked",0);
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if (!dini_Exists(str1)) dini_Create(str1);
new Float:sy, Float:sx, Float:sz;
dini_IntSet(str1, "Houseid", housenumber);
if(!dini_Isset(str1,"Rentid"))
{
dini_IntSet(str1, "Rentid", -255);
}
GetPlayerPos(playerid, sx,sy,sz);
dini_FloatSet(str1, "SpawnX", sx);
dini_FloatSet(str1, "SpawnY", sy);
dini_FloatSet(str1, "SpawnZ", sz);
dini_IntSet(str1, "SpawnInt", GetPlayerInterior(playerid));
DestroyDynamicPickup(HousePickup[housenumber]);
HousePickup[housenumber] = CreateDynamicPickup(1272, 23, hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz]);
new hnowner[30];
format(hnowner,128,"%s",hInfo[housenumber][Name]);
if(strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) {
format(hnowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner);
DestroyDynamicMapIcon(housemapicon[housenumber]);
housemapicon[housenumber] = CreateDynamicMapIcon(hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz],32,c_y);
return 1;
}
CMD:sellh(playerid,params[])
{
new str[255],str1[256],pname[24],housenumber;
housenumber = GetHouseID(playerid);
GetPlayerName(playerid, pname, 24);
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
if(PlayerInfo[playerid][LoggedIn] == 0) {
SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be logged in to use this command");
return 1;
}
if (strcmp(hInfo[housenumber][Name],pname,false)) return SendClientMessage(playerid, c_r, "This house isn't yours!");
new hsstring[128];
format(hsstring, sizeof(hsstring), "You just sold this House (ID:%i) for $%d.", housenumber, hInfo[housenumber][Sell]);
SendClientMessage(playerid, COLOR_GREEN, hsstring);
// SendClientMessage(playerid, c_y, "You have sold your house!");
format(str, sizeof(str), "%s has sold houseid %i",pname,housenumber);
print(str);
GivePlayerMoney(playerid, hInfo[housenumber][Sell]);
dini_Set(str1, "Name", DEFAULT_OWNER);
hInfo[housenumber][Locked] = dini_IntSet(str1,"Locked",1);
format(hInfo[housenumber][Name],255,DEFAULT_OWNER);
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if (!dini_Exists(str1)) dini_Create(str1);
dini_IntSet(str1, "Houseid", -255);
dini_IntSet(str1, "Rentid", -255);
DestroyDynamicPickup(HousePickup[housenumber]);
HousePickup[housenumber] = CreateDynamicPickup(1273, 23, hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz]);
new hnowner[30];
format(hnowner,128,"%s",hInfo[housenumber][Name]);
if(strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) {
format(hnowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0x00FF00FF,hnowner);
DestroyDynamicMapIcon(housemapicon[housenumber]);
housemapicon[housenumber] = CreateDynamicMapIcon(hInfo[housenumber][iconx], hInfo[housenumber][icony], hInfo[housenumber][iconz],31,c_y);
return 1;
}
CMD:enterh(playerid,params[])
{
new str1[255],pname[24],housenumber;
housenumber = GetHouseID(playerid);
GetPlayerPos(playerid, housex, housey, housez);
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
GetPlayerName(playerid, pname, 24);
if(hInfo[housenumber][Locked]==1) return SendClientMessage(playerid, c_r, "This house is locked!");
playerworld[playerid] = GetPlayerVirtualWorld(playerid);
SendClientMessage(playerid, COLOR_RED, "You entered the house! Type /exith to leave it, DONT use the doors!");
SetPlayerVirtualWorld(playerid, hInfo[housenumber][Virtualworld]);
SetPlayerInterior(playerid, hInfo[housenumber][Interior]);
SetPlayerPos(playerid, hInfo[housenumber][InteriorX], hInfo[housenumber][InteriorY], hInfo[housenumber][InteriorZ]);
playerinterior[playerid] = hInfo[housenumber][Interior];
return 1;
}
CMD:exith(playerid,params[])
{
if(GetPlayerInterior(playerid)==playerinterior[playerid])
{
SetPlayerPos(playerid, housex, housey, housez);
SetPlayerInterior(playerid, playerworld[playerid]);
}
else
{
SendClientMessage(playerid, c_r, "You have not entered a house!");
}
return 1;
}
CMD:gotoh(playerid,params[])
{
if(PlayerInfo[playerid][Jailed] == 1) return SendClientMessage(playerid,COLOR_BRIGHTRED,"You cannot escape your punishment!");
new str1[256],pname[24],str[256];
GetPlayerName(playerid, pname, sizeof(pname));
format(str1, sizeof(str1), "ladmin/users/%s.sav", udb_encode(pname));
if (dini_Exists(str1))
{
if(dini_Int(str1,"Houseid")!=-255)
{
TeleTimer[playerid] = SetTimerEx("ttimer", 1000, true, "i",playerid);
tseconds[playerid] = 6;
format(tstring,45,"You Must wait %d seconds before teleporting", tseconds[playerid]-1);
if(PlayerInfo[playerid][Level] == 0) SendClientMessage(playerid,COLOR_LIGHTBLUE, tstring);
vCount[playerid] = 1;
Tx[playerid] = dini_Float(str1,"SpawnX");
Ty[playerid] = dini_Float(str1,"SpawnY");
Tz[playerid] = dini_Float(str1,"SpawnZ");
Ti[playerid] = strval(str);
format(telestring,43,"Welcome Home!");
}
}
else return SendClientMessage(playerid, c_r, "You don't own a house!");
return 1;
}
AddHouse(houseid, Float:iconX, Float:iconY, Float:iconZ, Float:interiorX, Float:interiorY, Float:interiorZ, Costa, Sella, Interiora, virtualworld)
{
new house[256];
format(house, sizeof(house), "SATDM/Houses/houseid%d",houseid);
if(!dini_Exists(house))
{
dini_Create(house);
format(hInfo[houseid][Name], 24, DEFAULT_OWNER);
dini_Set(house, "Name", DEFAULT_OWNER);
format(hInfo[houseid][Renter], 24, "ForRent");
dini_Set(house, "Renter", "ForRent");
hInfo[houseid][Rentable] = 0;
dini_IntSet(house, "Rentable", 0);
hInfo[houseid][Rentcost] = 0;
dini_IntSet(house, "Rentcost", 0);
hInfo[houseid][Cost] = Costa;
dini_IntSet(house, "Cost", Costa);
hInfo[houseid][Sell] = Sella;
dini_IntSet(house, "Sell", Sella);
hInfo[houseid][Interior] = Interiora;
dini_IntSet(house, "Interior", Interiora);
dini_IntSet(house, "Virtualworld", virtualworld);
hInfo[houseid][Virtualworld] = virtualworld;
hInfo[houseid][Locked] = 1;
dini_IntSet(house, "Locked", 1);
hInfo[houseid][InteriorX] = interiorX;
hInfo[houseid][InteriorY] = interiorY;
hInfo[houseid][InteriorZ] = interiorZ;
dini_FloatSet(house, "X", interiorX);
dini_FloatSet(house, "Y", interiorY);
dini_FloatSet(house, "Z", interiorZ);
dini_IntSet(house, "RentPay", 0);
dini_IntSet(house, "RentGet", 0);
print("-");
print("--------------House Created--------------");
printf("- Houseid: %d", houseid);
printf("- Buy Cost: %d", Costa);
printf("- Sell Cost: %d", Sella);
printf("- Interior: %d", Interiora);
printf("- VirtualWorld: %d", virtualworld);
print("-----------------------------------------");
print("-");
}
else
{
format(hInfo[houseid][Name], 24, dini_Get(house, "Name"));
format(hInfo[houseid][Renter], 24, dini_Get(house, "Renter"));
hInfo[houseid][Rentable] = dini_Int(house, "Rentable");
hInfo[houseid][Rentcost] = dini_Int(house, "Rentcost");
hInfo[houseid][Cost] = dini_Int(house, "Cost");
hInfo[houseid][Sell] = dini_Int(house, "Sell");
hInfo[houseid][Interior] = dini_Int(house, "Interior");
hInfo[houseid][Locked] = dini_Int(house, "Locked");
hInfo[houseid][InteriorX] = dini_Float(house, "X");
hInfo[houseid][InteriorY] = dini_Float(house, "Y");
hInfo[houseid][InteriorZ] = dini_Float(house, "Z");
hInfo[houseid][Virtualworld] = dini_Int(house, "Virtualworld");
}
hInfo[houseid][iconx]=iconX;
hInfo[houseid][icony]=iconY;
hInfo[houseid][iconz]=iconZ;
format(house, sizeof(house), "SATDM/Houses/houseid%d",houseid);
hTextInfo[houseid] = Text3D:INVALID_3DTEXT_ID;
new hnowner[25];
format(hnowner,128,"%s",hInfo[houseid][Name]);
if(strcmp(hInfo[houseid][Name],DEFAULT_OWNER,true)==0)
{
format(hnowner,128,"Not Owned");
hTextInfo[houseid] = CreateDynamic3DTextLabel(hnowner,0x00FF00FF,iconX,iconY,iconZ+0.75,40);
HousePickup[houseid] = CreateDynamicPickup(1273, 23, iconX, iconY, iconZ);//not bought
housemapicon[houseid] = CreateDynamicMapIcon(iconX, iconY, iconZ,31,c_y);
}
else
{
hTextInfo[houseid] = CreateDynamic3DTextLabel(hnowner,0xFF0000FF,iconX,iconY,iconZ+0.75,40);
HousePickup[houseid] = CreateDynamicPickup(1272,23, iconX, iconY, iconZ);//bought
housemapicon[houseid] = CreateDynamicMapIcon(iconX, iconY, iconZ,32,c_y);
}
}
CMD:addhouseicon(playerid,params[])
{
AddHouse(houseid, Float:iconX, Float:iconY, Float:iconZ, Float:interiorX, Float:interiorY, Float:interiorZ, Costa, Sella, Interiora, virtualworld);
return 1;
}