Strange "unknown command" problem
#1

Ive made a house script and for some reason im getting strange results from my enter/exit commands (blank gamemode).
The problem is i enter game, use the /enter command to enter a house.

That works but ater that first /enter command- both /enter and /exit return "unknown command". I've never had this problem before and i'm quite confused
I hope someone knows whats wrong if so thanks in advance for any help heres the code.

pawn Код:
COMMAND:enter(playerid,params[])
{
    new str[70];
    for(new h; h <= MAX_HOUSES;h++)
    {
        if(IsPlayerInDynamicCP(playerid,CPID[h]))
        {
            SetPVarInt(playerid,"cpfix",GetTickCount() + 5000);
            SetPlayerPos(playerid,Hinfo[h][entposx],Hinfo[h][entposy],Hinfo[h][entposz]);
            SetPlayerFacingAngle(playerid,Hinfo[h][enterang]);
            SetCameraBehindPlayer(playerid);
            SetPlayerVirtualWorld(playerid,Hinfo[h][world]);
            SetPlayerInterior(playerid,Hinfo[h][interior]);
            format(str,sizeof(str),"~g~Welcome To ~p~%s",Hinfo[h][housename]);
            GameTextForPlayer(playerid,str,5000,3);
            SetPVarInt(playerid,"isinhouse",1);
            SetPVarInt(playerid,"cpcheck",1);
        }
    }
    if(GetPVarInt(playerid,"cpcheck")==0)
    {
        return SendClientMessage(playerid,0xff0000FF,"You Are Not at a house");
    }
    DeletePVar(playerid,"cpcheck");
    return 1;
}

COMMAND:exit(playerid,params[])
{
    if(GetPVarInt(playerid,"isinhouse")==0)return SendClientMessage(playerid,0xff0000FF,"ERROR: You are not in a house");

    for(new h; h <= MAX_HOUSES;h++)
    {
        if(IsPlayerInDynamicCP(playerid,CPID[h]))
        {
            SetPVarInt(playerid,"cpfix",GetTickCount() + 5000);//to stop enter/exit cps from showing text on enter/exit.
            SetPlayerPos(playerid,Hinfo[h][cpx],Hinfo[h][cpy],Hinfo[h][cpz]);
            SetPlayerFacingAngle(playerid,Hinfo[h][exitang]);
            SetCameraBehindPlayer(playerid);
            SetPlayerVirtualWorld(playerid,0);
            SetPlayerInterior(playerid,0);
            DeletePVar(playerid,"isinhouse");
        }
    }
    return 1;
}
Reply
#2

return 0; ? maybe
Reply
#3

That wont work m8 ty tho, anyone?
Reply
#4

pawn Код:
if(IsPlayerInDynamicCP(playerid,CPID[h]))
        {
            SetPVarInt(playerid,"cpfix",GetTickCount() + 5000);
            SetPlayerPos(playerid,Hinfo[h][entposx],Hinfo[h][entposy],Hinfo[h][entposz]);
            SetPlayerFacingAngle(playerid,Hinfo[h][enterang]);
            SetCameraBehindPlayer(playerid);
            SetPlayerVirtualWorld(playerid,Hinfo[h][world]);
            SetPlayerInterior(playerid,Hinfo[h][interior]);
            format(str,sizeof(str),"~g~Welcome To ~p~%s",Hinfo[h][housename]);
            GameTextForPlayer(playerid,str,5000,3);
            SetPVarInt(playerid,"isinhouse",1);
            SetPVarInt(playerid,"cpcheck",1);
        }
else SendClientMessage(playerid, RED,"You are not near the house");
Basically you should send it a message, try that
Reply
#5

EDIT: Thats not the problem the problem is its returning "unknown command" after the first time /enter is typed in.

So the command works once then returns unknown command.

Also i think your code would sendclientmessage as many times as MAX_HOUSES is defined.
Reply
#6

I had the same problem, I thought I fixed it this way:

pawn Код:
new h = -1;
for(h; h < MAX_HOUSES; h++)
{
        if(IsPlayerInDynamicCP(playerid,CPID[h])) break;
}

if(h == -1) return SendClientMessage(playerid, -1, "You're not near a house!");
else
{
  //Code if he is in a CP
}
May look a bit unorganized, but first get the house ID by doing a loop, when he's in the dynamic CP break that loop so you'll get result of 'h' being the house ID, work forward from that point.
Reply
#7

I'll give it a try but i don't think it will work because the actual command is returning "unknown command" ater its entered for the first time.
I dont think it has anything to do with ids or looping. will edit this post if it works (fingers cossed).

EDIT: warning- expession has no effect. On this line,
pawn Код:
for(h; h <= MAX_HOUSES; h++)
I might try dcmd to see if that works i don't think i should be getting unknown command message if the command exists
Reply
#8

Quote:
Originally Posted by iggy1
Посмотреть сообщение
I'll give it a try but i don't think it will work because the actual command is returning "unknown command" ater its entered for the first time.
I dont think it has anything to do with ids or looping. will edit this post if it works (fingers cossed).

EDIT: warning- expession has no effect. On this line,
pawn Код:
for(h; h <= MAX_HOUSES; h++)
I might try dcmd to see if that works i don't think i should be getting unknown command message if the command exists
Basically a command doesn't exists, it's something that checks a type of code and if the code matches the "command", it'll execute that.

Try:
pawn Код:
new h = -1;
for(new H; H < MAX_HOUSES; H++)
{
        if(IsPlayerInDynamicCP(playerid,CPID[H]))
        {
             h = H;
             break;
        }
}

if(h == -1) return SendClientMessage(playerid, -1, "You're not near a house!");
else
{
  //Code if he is in a CP
}
Reply
#9

Hmm thanks mate it works but had to edit a tiny bit for some reaon you could /type enter from anywhere and it would set co-ords to 0.0,0.0,0.0. Was strange so i added IsPlayerInRangeOf point and it works a treat much,much appreciated working fine.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)