Command Doesn't Work At All -
nezo2001 - 14.06.2015
Idk why ?!
PHP код:
CMD:buyhouse(playerid, params[])
{
for(new a, j = cache_get_row_count(); a != j; ++a)
{
if (a >= sizeof HouseInfo) break;
if(IsPlayerInRangeOfPoint(playerid, 7.0, HouseInfo[a][EntranceX], HouseInfo[a][EntranceY], HouseInfo[a][EntranceZ]))
{
if(HouseInfo[a][HousePrice] > GetPlayerMoney(playerid)) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money!");
new draw[200];
format(draw,sizeof(draw),"ID: %i\nPrice %i\nOwned: Yes\nOwner: %s",PlayerName(playerid));
new query[200];
format(query, sizeof(query), "UPDATE houses SET owner='%s', owned='true', text='%s'", PlayerName(playerid), draw);
Update3DTextLabelText(HouseLabel, COLOR_GREEN, draw);
GivePlayerMoney(playerid, -HouseInfo[a][HousePrice]);
PlayerInfo[playerid][pHouseID] = HouseInfo[a][HouseID];
SendClientMessage(playerid, COLOR_GREEN, "You've bought this house successfully!");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not near any house");
}
}
return 1;
}
Re: Command Doesn't Work At All -
Konstantinos - 14.06.2015
cache_get_row_count is only used when loading from mysql. In this case you'd use MAX_HOUSES but a variable that gets assigned with the rows returned on loading would be even better (you'd have to increase by one when a house is created and decrease when a house is removed).
Re: Command Doesn't Work At All -
nezo2001 - 14.06.2015
Can I make a variable and assign in it the number of houses loaded
Re: Command Doesn't Work At All -
Konstantinos - 14.06.2015
pawn Код:
// global:
new HousesLoaded;
// In OnHousesLoad public function:
HousesLoaded = cache_get_row_count();
for(new x; x != HousesLoaded; ++x)
// In the above command:
for(new a; a != HousesLoaded; ++a)
and remove this check from the command:
pawn Код:
if (a >= sizeof HouseInfo) break;
it only needs in the loading houses part in case there are more rows than the amount the variable can hold.
Re: Command Doesn't Work At All -
nezo2001 - 14.06.2015
Fourth Thanks bro
Re: Command Doesn't Work At All -
nezo2001 - 16.06.2015
But I don't understand why this under OnHousesLoad
PHP код:
for(new x; x != HousesLoaded; ++x)
Re: Command Doesn't Work At All -
Konstantinos - 16.06.2015
It assigns the rows returned to HousesLoaded variable so no need to use local variables or calling cache_get_row_count again.
Re: Command Doesn't Work At All -
nezo2001 - 16.06.2015
PHP код:
for(new x; x != HouseLoad; ++x);
Код:
error 036: empty statement
Re: Command Doesn't Work At All -
Konstantinos - 16.06.2015
Remove the semicolon.
Re: Command Doesn't Work At All -
nezo2001 - 16.06.2015
PHP код:
public OnHousesLoad()
{
for(new i, j = cache_get_row_count(); i != j; ++i)
{
if (i >= sizeof HouseInfo) break;
HouseInfo[i][HouseID] = cache_get_field_content_int(i, "id");
HouseInfo[i][EntranceX] = cache_get_field_content_float(i, "EntranceX");
HouseInfo[i][EntranceY] = cache_get_field_content_float(i, "EntranceY");
HouseInfo[i][EntranceZ] = cache_get_field_content_float(i, "EntranceZ");
HouseInfo[i][ExitX] = cache_get_field_content_float(i, "ExitX");
HouseInfo[i][ExitY] = cache_get_field_content_float(i, "ExitY");
HouseInfo[i][ExitZ] = cache_get_field_content_float(i, "ExitZ");
HouseInfo[i][InsideInt] = cache_get_field_content_int(i, "InsideInt");
cache_get_field_content(i, "owner", HouseInfo[i][owner], 1, MAX_PLAYER_NAME);
HouseInfo[i][owned] = cache_get_field_content_int(i, "owned");
HouseInfo[i][HousePrice] = cache_get_field_content_int(i, "price");
cache_get_field_content(i, "text", HouseInfo[i][HouseText], 1, 200);
HouseLabel = Create3DTextLabel(HouseInfo[i][HouseText], COLOR_GREEN, HouseInfo[i][EntranceX], HouseInfo[i][EntranceY], HouseInfo[i][EntranceZ], 30, 0, 1);
HouseLoad = cache_get_row_count();
for(new x; x != HouseLoad; ++x)
}
return 1;
}
Код:
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(880) : error 029: invalid expression, assumed zero
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(880 -- 881) : warning 215: expression has no effect
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(881) : error 001: expected token: ";", but found "return"
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(881) : warning 217: loose indentation
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(881) : error 079: inconsistent return types (array & non-array)
D:\samp037_svr_R1_win32\gamemodes\FM.pwn(881) : fatal error 107: too many error messages on one line