09.12.2012, 07:57
Hello,
I cannot find my bug why my address shows "1", while I gave it the address "4th palin street"
I cannot find my bug why my address shows "1", while I gave it the address "4th palin street"
pawn Код:
enum HouseData
{
hInteriorID,
hAddress[255],
Float: hInteriorX,
Float: hInteriorY,
Float: hInteriorZ,
Float: hInteriorA,
hExteriorID,
Float: hExteriorX,
Float: hExteriorY,
Float: hExteriorZ,
Float: hExteriorA,
hSpawnID,
Float: hSpawnX,
Float: hSpawnY,
Float: hSpawnZ,
Float: hSpawnA,
HPickupID,
hOwner[255],
HousePrice,
LockStatus,
hType[255],
LastLoginDay,
LastLoginMonth,
LastLoginYear,
};
pawn Код:
command(sethouseaddress, playerid, params[])
{
new address[255], string[128];
if(sscanf(params, "z", address))
{
if(Player[playerid][AdminLevel] >= 6)
{
SendClientMessage(playerid, WHITE, "SYNTAX: /sethouseaddress [address]");
}
}
else
{
if(Player[playerid][AdminLevel] >= 6)
{
for(new h = 0; h < MAX_HOUSES; h++)
{
if(strcmp(Houses[h][hAddress], address, true))
{
if(IsPlayerInRangeOfPoint(playerid, 2, Houses[h][hExteriorX], Houses[h][hExteriorY], Houses[h][hExteriorZ]))
{
format(Houses[h][hAddress], 255, "%s", address);
format(string, sizeof(string), "You succesfully renamed house id: %d's address to: %s", h, address);
SCM(playerid, YELLOW, string);
SaveHouse(h);
break;
}
}
else
{
SCM(playerid, RED, "This address already exists");
}
}
}
}
return 1;
}
pawn Код:
stock InitHouses()
{
new FileName[128];
for(new i = 0; i < MAX_HOUSES; i++)
{
format(FileName, sizeof(FileName), "Houses/House_%d.ini", i);
if(fexist(FileName))
{
Houses[i][hAddress] = dini_Get(FileName, "hAddress");
Houses[i][hType] = dini_Get(FileName, "hType");
Houses[i][hInteriorID] = dini_Int(FileName, "InteriorID");
Houses[i][hInteriorX] = dini_Float(FileName, "InteriorX");
Houses[i][hInteriorY] = dini_Float(FileName, "InteriorY");
Houses[i][hInteriorZ] = dini_Float(FileName, "InteriorZ");
Houses[i][hInteriorA] = dini_Float(FileName, "InteriorA");
Houses[i][hExteriorID] = dini_Int(FileName, "ExteriorID");
Houses[i][hExteriorX] = dini_Float(FileName, "ExteriorX");
Houses[i][hExteriorY] = dini_Float(FileName, "ExteriorY");
Houses[i][hExteriorZ] = dini_Float(FileName, "ExteriorZ");
Houses[i][hExteriorA] = dini_Float(FileName, "ExteriorA");
Houses[i][hSpawnID] = dini_Int(FileName, "SpawnID");
Houses[i][hSpawnX] = dini_Float(FileName, "SpawnX");
Houses[i][hSpawnY] = dini_Float(FileName, "SpawnY");
Houses[i][hSpawnZ] = dini_Float(FileName, "SpawnZ");
Houses[i][hSpawnA] = dini_Float(FileName, "SpawnA");
Houses[i][hOwner] = dini_Get(FileName, "Owner");
Houses[i][HousePrice] = dini_Int(FileName, "HousePrice");
Houses[i][LockStatus] = dini_Int(FileName, "LockStatus");
Houses[i][LastLoginDay] = dini_Int(FileName, "LastLoginDay");
Houses[i][LastLoginMonth] = dini_Int(FileName, "LastLoginMonth");
Houses[i][LastLoginYear] = dini_Int(FileName, "LastLoginYear");
if(strcmp(Houses[i][hOwner], "Nobody", true) == 0)
{
Houses[i][LockStatus] = 1;
Houses[i][HPickupID] = CreateDynamicPickup(1273, 23, Houses[i][hExteriorX], Houses[i][hExteriorY], Houses[i][hExteriorZ], 0, -1, -1, 150.0);
}
else
{
Houses[i][HPickupID] = CreateDynamicPickup(1318, 23, Houses[i][hExteriorX], Houses[i][hExteriorY], Houses[i][hExteriorZ], 0, -1, -1, 150.0);
}
printf("[system] House %d spawned.", i);
SpawnedHouses++;
}
}
return 1;
}
pawn Код:
stock SaveHouse(i)
{
new FileName[23];
format(FileName, sizeof(FileName), "Houses/House_%d.ini", i);
if(fexist(FileName))
{
dini_IntSet(FileName, "InteriorID", Houses[i][hInteriorID]);
dini_FloatSet(FileName, "InteriorX", Houses[i][hInteriorX]);
dini_FloatSet(FileName, "InteriorY", Houses[i][hInteriorY]);
dini_FloatSet(FileName, "InteriorZ", Houses[i][hInteriorZ]);
dini_FloatSet(FileName, "InteriorA", Houses[i][hInteriorA]);
dini_IntSet(FileName, "ExteriorID", Houses[i][hExteriorID]);
dini_FloatSet(FileName, "ExteriorX", Houses[i][hExteriorX]);
dini_FloatSet(FileName, "ExteriorY", Houses[i][hExteriorY]);
dini_FloatSet(FileName, "ExteriorZ", Houses[i][hExteriorZ]);
dini_FloatSet(FileName, "ExteriorA", Houses[i][hExteriorA]);
dini_IntSet(FileName, "SpawnID", Houses[i][hSpawnID]);
dini_FloatSet(FileName, "SpawnX", Houses[i][hSpawnX]);
dini_FloatSet(FileName, "SpawnY", Houses[i][hSpawnY]);
dini_FloatSet(FileName, "SpawnZ", Houses[i][hSpawnZ]);
dini_FloatSet(FileName, "SpawnA", Houses[i][hSpawnA]);
dini_Set(FileName, "Owner", Houses[i][hOwner]);
dini_Set(FileName, "hAddress", Houses[i][hAddress]);
dini_Set(FileName, "hType", Houses[i][hType]);
dini_IntSet(FileName, "HousePrice", Houses[i][HousePrice]);
dini_IntSet(FileName, "LockStatus", Houses[i][LockStatus]);
dini_IntSet(FileName, "LastLoginDay", Houses[i][LastLoginDay]);
dini_IntSet(FileName, "LastLoginMonth", Houses[i][LastLoginMonth]);
dini_IntSet(FileName, "LastLoginYear", Houses[i][LastLoginYear]);
printf("[system] House %d saved.", i);
}
return 1;
}