09.11.2013, 09:51
Hello, here is a command that I was doing last night.
Question is, whenever I do a house with the same address as other house, for example.
House ID 1: Troll
and then I do house ID 2's Address to:
House ID 2: Troll
it should say Error: A house with the same address is already existed. HID: 1.
But no, it would change House ID 2's Address to what I said, instead of saying error. It does check the strcmp tho, like, it would spam test3 in console and then it would go to test4.
Any Idea how to fix it, or I did it wrong?
pawn Код:
CMD:haddress(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
return 1;
}
new string[128], houseid, des[30];
if(sscanf(params, "ds[30]", houseid, des)) return SendClientMessageEx(playerid, COLOR_WHITE, "{1AB7D6}USAGE:{FFFFFF}: /haddress [House ID] [House Address]");
if( !( 0 <= houseid < MAX_HOUSES ) ) return SendClientMessageEx(playerid, COLOR_WHITE, "Invalid House ID");
for(new h = 0; h < MAX_HOUSES; h++)
{
if(strcmp(des, "none", true) == 0)
{
format(HouseInfo[houseid][hAddress], 30, "");
format(string, sizeof(string), "You have removed the house address.");
print("test1");
}
else if(strcmp(des, "Private Address", true) == 0)
{
format(HouseInfo[houseid][hAddress], 30, "Private Address");
format(string, sizeof(string), "You have set the house address to %s", HouseInfo[houseid][hAddress]);
print("test2");
}
else
{
if(!strcmp(HouseInfo[h][hAddress], des, false))
{
format(string, sizeof(string), "ERROR: A house with the same address is already existed! House ID: %d", h);
print("test3");
}
else
{
format(HouseInfo[houseid][hAddress], 30, "%s", des);
format(string, sizeof(string), "You have changed the house address to %s.", des);
print("test4");
}
}
}
SendClientMessageEx(playerid, COLOR_WHITE, string);
DestroyDynamicPickup(HouseInfo[houseid][hPickupID]);
DestroyDynamic3DTextLabel( HouseInfo[ houseid ][ hTextID ]);
CreateHouse( houseid );
format(string, sizeof(string), "%s has edited House ID %d's Address to %s.", GetPlayerNameEx(playerid), houseid, des);
Log("RP/Logs/haddress.log", string);
print("test last");
return 1;
}
House ID 1: Troll
and then I do house ID 2's Address to:
House ID 2: Troll
it should say Error: A house with the same address is already existed. HID: 1.
But no, it would change House ID 2's Address to what I said, instead of saying error. It does check the strcmp tho, like, it would spam test3 in console and then it would go to test4.
pawn Код:
if(!strcmp(HouseInfo[h][hAddress], des, false))
{
format(string, sizeof(string), "ERROR: A house with the same address is already existed! House ID: %d", h);
print("test3");
}
else
{
format(HouseInfo[houseid][hAddress], 30, "%s", des);
format(string, sizeof(string), "You have changed the house address to %s.", des);
print("test4");
}