Command is not returning problem.
#1

Hey, for some reason when I do this command it's coming up with the 'SERVER: Unknown command' message, although I've defined the error message to something else. So I'm guessing I'm putting the returns in the wrong place. I've tried just returning it at the end, but that doesn't work either, just the same message. Here is the command, I'm pretty damn tired at the moment and can't see anything wrong, So can anybody see anything wrong with it here?

pawn Код:
dcmd_Lock(playerid, params[])
{
    #pragma unused params
    new file[16];
    new i = GetHouseID(playerid);
    new j = GetBusinessID(playerid);
    if(i != -255)
    {
        if(PR[playerid][HouseID] != i) return SendClientMessage(playerid, COLOUR_RED, "* You don't own this house");
        format(file, sizeof(file), "Houses/%d.cfg",i);
        if(HR[i][Lock] == 1)
        {
            HR[i][Lock] = 0;
            dini_IntSet(file,"Locked",0);
            GameTextForPlayer(playerid,"~w~Door ~g~unlocked",3000,1);
        }
        else
        {
            HR[i][Lock] = 1;
            dini_IntSet(file,"Locked",1);
            GameTextForPlayer(playerid,"~w~Door ~r~locked",3000,1);
        }
        return 1;
    }
    if(j != -255)
    {
        if(PR[playerid][BusinessID] != j) return SendClientMessage(playerid, COLOUR_RED, "* You don't own this business");
        format(file, sizeof(file), "Business/%d.cfg",j);
        if(BR[j][Lock] == 1)
        {
            BR[j][Lock] = 0;
            dini_IntSet(file,"Locked",0);
            GameTextForPlayer(playerid,"~w~Door ~g~unlocked",3000,1);
        }
        else
        {
            BR[j][Lock] = 1;
            dini_IntSet(file,"Locked",1);
            GameTextForPlayer(playerid,"~w~Door ~r~locked",3000,1);
        }
        return 1;
    }
    if(j == -255 && i == -255)
    {
        SendClientMessage(playerid,COLOUR_RED,"* You are not at the door of a house or business");
    }
    return 1;
}
Reply
#2

add print("test"); every few lines, and see how many will come up in server console, i bet there will be less of those "test" texts. so that way you can see where the script is going wrong
Reply
#3

Try removing "return 1" after your else's. i514x_ That test thing would still return unknown command.
not sure but try this
pawn Код:
dcmd_Lock(playerid, params[])
{
    #pragma unused params
    new file[16];
    new i = GetHouseID(playerid);
    new j = GetBusinessID(playerid);
    if(i != -255)
    {
        if(PR[playerid][HouseID] != i) return SendClientMessage(playerid, COLOUR_RED, "* You don't own this house");
        format(file, sizeof(file), "Houses/%d.cfg",i);
        if(HR[i][Lock] == 1)
        {
            HR[i][Lock] = 0;
            dini_IntSet(file,"Locked",0);
            GameTextForPlayer(playerid,"~w~Door ~g~unlocked",3000,1);
            return 1;
        }
        else
        {
            HR[i][Lock] = 1;
            dini_IntSet(file,"Locked",1);
            GameTextForPlayer(playerid,"~w~Door ~r~locked",3000,1);
        }
    }
    if(j != -255)
    {
        if(PR[playerid][BusinessID] != j) return SendClientMessage(playerid, COLOUR_RED, "* You don't own this business");
        format(file, sizeof(file), "Business/%d.cfg",j);
        if(BR[j][Lock] == 1)
        {
            BR[j][Lock] = 0;
            dini_IntSet(file,"Locked",0);
            GameTextForPlayer(playerid,"~w~Door ~g~unlocked",3000,1);
            return 1;
        }
        else
        {
            BR[j][Lock] = 1;
            dini_IntSet(file,"Locked",1);
            GameTextForPlayer(playerid,"~w~Door ~r~locked",3000,1);
        }
    }
    if(j == -255 && i == -255)
    {
        SendClientMessage(playerid,COLOUR_RED,"* You are not at the door of a house or business");
    }
    return 1;
}
Reply
#4

Iggy, I've tried my returns in all different ways, But I have worked it out using i514x_'s method; It was my Business checker that was failing me. (:

Thanks guys.
Reply
#5

Quote:
Originally Posted by miokie
Посмотреть сообщение
Iggy, I've tried my returns in all different ways, But I have worked it out using i514x_'s method; It was my Business checker that was failing me. (:

Thanks guys.
no problem

and iggy, it works because when something is not working in my gamemode, im always doing that
Reply
#6

Quote:
Originally Posted by i514x_
Посмотреть сообщение
no problem

and iggy, it works because when something is not working in my gamemode, im always doing that
Printing test to the screen wouldn't stop a command from returning unknown command trust me. If its returning unknown command that means the script doesn't know the command exists (or it returns 0) so print just wouldn't get executed (because to the script it isn't there). It would work with stuff that partially gets executed, i just cant understand how it fixed the problem.
Reply
#7

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Printing test to the screen wouldn't stop a command from returning unknown command trust me. If its returning unknown command that means the script doesn't know the command exists (or it returns 0) so print just wouldn't get executed (because to the script it isn't there). It would work with stuff that partially gets executed, i just cant understand how it fixed the problem.
I think he means doing it likes this:

<Execute command>
<Print>
<Get required info>
<print>
<do something>
<print>
<return>

So you can see what prints are executed before the command breaks... Well, that's what I did anyway. (:
Reply
#8

Quote:
Originally Posted by miokie
Посмотреть сообщение
I think he means doing it likes this:

<Execute command>
<Print>
<Get required info>
<print>
<do something>
<print>
<return>

So you can see what prints are executed before the command breaks... Well, that's what I did anyway. (:
yes, thats exactly what i mean and then you can see whats causing the problem
Reply


Forum Jump:


Users browsing this thread: