CMD -
MrCallum - 26.08.2016
Код:
CMD:asellallhouses(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] >= 1337)
{
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
new string[128];
for (new house = 0; house != MAX_HOUSES; house++)
{
HouseInfo[house][hLock] = 1;
new ip[32];
GetPlayerIp(playerid,ip,sizeof(ip));
format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
Log("logs/house.log", string);
ClearHouse(house);
format( HouseInfo[house][hOwner], 128, "Nobody" );
HouseInfo[house][hGLUpgrade] = 1;
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~You have sold house %d.", house);
GameTextForPlayer(playerid, string, 10000, 3);
SaveHouses();
DestroyDynamicPickup(HouseInfo[house][hPickupID]);
HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 30.0);
return 1;
}
}
else
{
SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use that command!");
}
return 1;
}
Sells ID 0, Not all houses
Re: CMD -
DarkSkull - 26.08.2016
PHP код:
for (new house = 0; house != MAX_HOUSES; house++)
{
HouseInfo[house][hLock] = 1;
new ip[32];
GetPlayerIp(playerid,ip,sizeof(ip));
format(string,sizeof(string),"Administrator %s (IP: %s) has admin-sold house ID %d (was owned by %s).",GetPlayerNameEx(playerid),ip,house,HouseInfo[house][hOwner]);
Log("logs/house.log", string);
ClearHouse(house);
format( HouseInfo[house][hOwner], 128, "Nobody" );
HouseInfo[house][hGLUpgrade] = 1;
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
format(string, sizeof(string), "~w~You have sold house %d.", house);
GameTextForPlayer(playerid, string, 10000, 3);
SaveHouses();
DestroyDynamicPickup(HouseInfo[house][hPickupID]);
HouseInfo[house][hPickupID] = CreateDynamicPickup(1273, 23, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]);
DestroyDynamic3DTextLabel(HouseInfo[house][hTextID]);
format(string, sizeof(string), "This home is\n for sale!\n Description: %s\nCost: $%d\n Level: %d\n/buyhouse to buy it.",HouseInfo[house][hDescription],HouseInfo[house][hValue],HouseInfo[house][hLevel]);
HouseInfo[house][hTextID] = CreateDynamic3DTextLabel( string, COLOR_GREEN, HouseInfo[house][hExteriorX], HouseInfo[house][hExteriorY], HouseInfo[house][hExteriorZ]+0.5,30.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 30.0);
}
Don't return inside a loop, It will break the loop. Try this code, It should work
Re: CMD -
Kwarde - 27.08.2016
Indeed. Basically this happens in a loop.
Let's say we have the following loop:
PHP код:
for (new i = 0; i < 5; i++) //Or 'i = 0; i != 5; i++' --The only danger here is, if that i get's one extra add in a loop, it might skip '5' in a new loop and you'll get an infinite loop. But if that would occur you would have done something really wrong :p
{
printf("<loop> I=%d", i);
}
What the server is gonna do:
PHP код:
doLoop()
{
//First loop
if (!(i<5)) break;
printf("<loop> I=%d", 0);
i++;
continue;
//Second loop
if (!(i<5)) break;
printf("<loop> I=%d", 1);
i++;
continue;
//Third loop
if (!(i<5)) break;
printf("<loop> I=%d", 2);
i++;
continue;
//Fourth loop
if (!(i<5)) break;
printf("<loop> I=%d", 3);
i++;
continue;
//Fifth loop
if (!(i<5)) break;
printf("<loop> I=%d", 4);
i++;
continue;
//Sixth loop
if (!(<i5)) break;
}
Both
break; and
return; stop the loop. As you can see in this example above, it breaks on the sixth loop because 'i' is no longer below 5; so 'break;' is called; and the loop goes no futher. And that's why it did not work. (Thought I'd explain the problem, that's better than just getting the right code).