ZCMD command error
#1

I have made this for deleting house...it includes furniture,but the problem is that when i put for example /deletehouse [houseid], if it's an invalid house id it says wrong house id,but if i put a right house id that is used it shows error message by ZCMD,why?here is the code:
pawn Код:
CMD:resethouse(houseid, params[])
{
    new house;
    if(!sscanf(params, "d", house))
    {
        if(hInfo[house][hcreated] != 1) return SendClientMessage(houseid, -1, "Invalid house id");
        else
        {
            hInfo[house][hcreated] = 0; //it only changes these two things
            hInfo[house][houseowned] = 0; //it only changes these two things
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(pInfo[i][playerhouse] == house)
                {
                    pInfo[i][playerhouse] = 0;
                }
            }
            hInfo[house][housepot] = 0;
            hInfo[house][housegun] = 0;
            hInfo[house][housecash] = 0;
            hInfo[house][houselock] = 0;
            format(string, sizeof(string), "You have deleted house id %d.", house);
            SendClientMessage(houseid, COLOR_GREY, string);
            new query[128];
            mysql_format(dbHandle, query, sizeof(query), "DELETE * FROM `houselist` WHERE `hID`=%d", house);
            printf("%d deleted", house);
            mysql_tquery(dbHandle, query, "", "");
        }
    }
    else
    {
        SendClientMessage(houseid, COLOR_GREY, "/resethouse [houseid]");
    }
    return 1;
}
Reply
#2

PHP код:
CMD:resethouse(houseidparams[])
{
    new 
house;
    if(
sscanf(params"i"house)) return SendClientMessage(houseidCOLOR_GREY"/resethouse [houseid]")
     if(
hInfo[house][hcreated] != 1) return SendClientMessage(houseid, -1"Invalid house id");
      else
    {
        
hInfo[house][hcreated] = 0//it only changes these two things
        
hInfo[house][houseowned] = 0//it only changes these two things
        
for(new 0MAX_PLAYERSi++)
        {
            if(
pInfo[i][playerhouse] == house)
            {
                
pInfo[i][playerhouse] = 0;
            }
        }
         
hInfo[house][housepot] = 0;
         
hInfo[house][housegun] = 0;
         
hInfo[house][housecash] = 0;
        
hInfo[house][houselock] = 0;
         
format(stringsizeof(string), "You have deleted house id %d."house);
         
SendClientMessage(houseidCOLOR_GREYstring);
         new 
query[128];
         
mysql_format(dbHandlequerysizeof(query), "DELETE * FROM `houselist` WHERE `hID`=%d"house);
         
printf("%d deleted"house);
        
mysql_tquery(dbHandlequery"""");
    
    }
    return 
1;

Reply
#3

still doesnt work
Reply
#4

Show the hInfo enum
Reply
#5

pawn Код:
enum housesinfo
{
        hcreated,
    houseowned,
    housepot,
    housegun,
    housecash,
    houselock,
    Float:houseX,
    Float:houseY,
    Float:houseZ
}
new hInfo[MAX_HOUSEAMOUNTS][housesinfo];
Reply
#6

Use crashdetect.dll and see if you gets something on server_log. Because, if there's any runtime error that is causing the callback to end, it will be printed on log.
Reply
#7

here is what crashdetect gives,when i put a valid id:
Код:
[07:13:29] [debug] Run time error 4: "Array index out of bounds"
[07:13:29] [debug]  Accessing element at index 100 past array upper bound 99
[07:13:29] [debug] AMX backtrace:
[07:13:29] [debug] #0 00009000 in public cmd_resethouse () from rp.amx
[07:13:29] [debug] #1 native CallLocalFunction () [00472ad0] from samp-server.exe
[07:13:29] [debug] #2 00000608 in public OnPlayerCommandText () from rp.amx
Reply
#8

What is your MAX_HOUSEAMOUNTS and with what valid id did you test the code?
Reply
#9

i created house,it was id 1,and when i do /resethouse 1,it sends me error message from the zcmd thingy,and if i do /resethouse 1 again it shows invalid house id
and MAX_HOUSEAMOUNTS is 200
Reply
#10

Put // before each line after 'else', test the code and see when the this thing is not printed on the log.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)