Command Doesn't Work At All
#1

Idk why ?!
PHP код:
CMD:buyhouse(playeridparams[])
{
    for(new 
acache_get_row_count(); != j; ++a)
    {
        if (
>= sizeof HouseInfo) break;
        if(
IsPlayerInRangeOfPoint(playerid7.0HouseInfo[a][EntranceX], HouseInfo[a][EntranceY], HouseInfo[a][EntranceZ]))
        {
            if(
HouseInfo[a][HousePrice] > GetPlayerMoney(playerid)) return SendClientMessage(playeridCOLOR_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(querysizeof(query), "UPDATE houses SET owner='%s', owned='true', text='%s'"PlayerName(playerid), draw);
            
Update3DTextLabelText(HouseLabelCOLOR_GREENdraw);
            
GivePlayerMoney(playerid, -HouseInfo[a][HousePrice]);
            
PlayerInfo[playerid][pHouseID] = HouseInfo[a][HouseID];
            
SendClientMessage(playeridCOLOR_GREEN"You've bought this house successfully!");
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"You are not near any house");
        }
    }
    return 
1;

Reply
#2

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).
Reply
#3

Can I make a variable and assign in it the number of houses loaded
Reply
#4

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.
Reply
#5

Fourth Thanks bro
Reply
#6

But I don't understand why this under OnHousesLoad
PHP код:
for(new x!= HousesLoaded; ++x
Reply
#7

It assigns the rows returned to HousesLoaded variable so no need to use local variables or calling cache_get_row_count again.
Reply
#8

PHP код:
for(new x!= HouseLoad; ++x); 
Код:
error 036: empty statement
Reply
#9

Remove the semicolon.
Reply
#10

PHP код:
public OnHousesLoad()
{
    for(new 
icache_get_row_count(); != j; ++i)
    {
        if (
>= 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], 1MAX_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], 1200);
        
HouseLabel Create3DTextLabel(HouseInfo[i][HouseText], COLOR_GREENHouseInfo[i][EntranceX], HouseInfo[i][EntranceY], HouseInfo[i][EntranceZ], 3001);
        
HouseLoad cache_get_row_count();
        for(new 
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)