Little problem with SendClientMessage
#1

I have the /opengate command which basically moves my custom placed gates.
If the player is NOT in range of the gates (12.0 radius), he gets a client message.
However, the player gets the client message EVEN if he is in the radius and the gate opens.
Who can spot the error for me? :/

pawn Код:
if(!strcmp(cmdtext,"/opengate",true))
    {
        if(gTeam[playerid] == NATIONALGUARD && IsPlayerInRangeOfPoint(playerid, 12.0, 96.76334, 1919.52905, 18.88980))
        {
            MoveObject(area51door1,96.76334, 1919.52905, 15.29157,2.0);
            MoveObject(area51door2,96.73065, 1920.58228, 15.29157,2.0);
            MoveObject(area51door3,96.75900, 1921.33777, 15.29157,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
        }
        if(gTeam[playerid] == NATIONALGUARD && IsPlayerInRangeOfPoint(playerid, 12.0, 286.17056, 1949.13794, 19.27510))
        {
            MoveObject(area51slot1,286.17056, 1949.13794, 13.25867,1.5)
            MoveObject(area51slot2,286.16769, 1963.24854, 13.27771,1.5);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
        }
        if(gTeam[playerid] == NATIONALGUARD && IsPlayerInRangeOfPoint(playerid, 12.0, 344.67886, 1798.26257, 20.32330))
        {
            MoveObject(area51gate,344.67886, 1798.26257, 13.73979,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
        }
        else SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
        return 1;
    }
Reply
#2

Check your team(gTeam[playerid] == NATIONALGUARD)
Reply
#3

Quote:
Originally Posted by DiGiTaL_AnGeL
Посмотреть сообщение
Check your team(gTeam[playerid] == NATIONALGUARD)
Nothing wrong with that.
Reply
#4

pawn Код:
if(!strcmp(cmdtext,"/opengate",true))
{
    if(gTeam[playerid] == NATIONALGUARD) {
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 96.76334, 1919.52905, 18.88980))
        {
            MoveObject(area51door1,96.76334, 1919.52905, 15.29157,2.0);
            MoveObject(area51door2,96.73065, 1920.58228, 15.29157,2.0);
            MoveObject(area51door3,96.75900, 1921.33777, 15.29157,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 286.17056, 1949.13794, 19.27510))
        {
            MoveObject(area51slot1,286.17056, 1949.13794, 13.25867,1.5);
            MoveObject(area51slot2,286.16769, 1963.24854, 13.27771,1.5);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 344.67886, 1798.26257, 20.32330))
        {
            MoveObject(area51gate,344.67886, 1798.26257, 13.73979,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by needhack
Посмотреть сообщение
Nothing wrong with that.
I said check if your team is the one you've checked.
Reply
#6

try this

pawn Код:
if(!strcmp(cmdtext,"/opengate",true))
{
    if(gTeam[playerid] == NATIONALGUARD)
    {
        if(IsPlayerInRangeOfPoint(playerid, 12, 96.76334, 1919.52905, 18.88980)) return SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
        {
            MoveObject(area51door1,96.76334, 1919.52905, 15.29157,2.0);
            MoveObject(area51door2,96.73065, 1920.58228, 15.29157,2.0);
            MoveObject(area51door3,96.75900, 1921.33777, 15.29157,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12, 286.17056, 1949.13794, 19.27510)) return SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
        {
            MoveObject(area51slot1,286.17056, 1949.13794, 13.25867,1.5);
            MoveObject(area51slot2,286.16769, 1963.24854, 13.27771,1.5);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12, 344.67886, 1798.26257, 20.32330)) return SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
        {
            MoveObject(area51gate,344.67886, 1798.26257, 13.73979,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by pds2012
Посмотреть сообщение
try this
...
The code that I posted will fix his problem, what you posted will only give the error when in range of the gates (Which is the opposite of what should be done).
Reply
#8

Catalyst's fix works.
Thanks!
Reply
#9

So what is the problem now?
It doesn't give me the "You are not close to any usable gates" message anymore.

pawn Код:
if(!strcmp(cmdtext,"/opengate",true))
{
    if(gTeam[playerid] == NATIONALGUARD) {
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 96.76334, 1919.52905, 18.88980))
        {
            MoveObject(area51door1,96.76334, 1919.52905, 15.29157,2.0);
            MoveObject(area51door2,96.73065, 1920.58228, 15.29157,2.0);
            MoveObject(area51door3,96.75900, 1921.33777, 15.29157,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 286.17056, 1949.13794, 19.27510))
        {
            MoveObject(area51slot1,286.17056, 1949.13794, 13.25867,1.5);
            MoveObject(area51slot2,286.16769, 1963.24854, 13.27771,1.5);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        if(IsPlayerInRangeOfPoint(playerid, 12.0, 344.67886, 1798.26257, 20.32330))
        {
            MoveObject(area51gate,344.67886, 1798.26257, 13.73979,2.0);
            SendClientMessage(playerid, COLOR_GREEN, "Gate has been opened. Do not forget to close it.");
            return 1;
        }
        SendClientMessage(playerid, COLOR_RED, "You are not close to any usable gate.");
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)