IsPlayerInRangeOfPoint not working correctly
#1

I want to make an /ad command that allows you to make an advertisement only when you are at the ad center.However it`s not working. I know there is one extra closing bracket.
Here`s the code:
Код:
if(strcmp(cmd, "/advertise", true) == 0 || strcmp(cmd, "/ad", true) == 0) 
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "Nu esti logat!");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ad)vertise [advert text]");
            return 1;
        }
        if(PermisAnunt[playerid] == 1) 
        {
            IfIsPlayerInRangeOfPoint(7,-25.1326,-139.0670,1003.5469,0,0,0,0,0,0,0);
			{
            new payout = idx * 5;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "* Acest anunt costa $%d, bani de care nu dispuneti.", payout);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "PUBLICITATE: %s,  Contact: %d",  result,PlayerInfo[playerid][pPnumber],playerid);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Ai platit $%d~n~~w~Mesajul contine: %d Caractere", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 5);
            PermisAnunt[playerid] = 0; 
            SetTimerEx("Anunt", 60000, 0, "d", playerid); 
            }
            }
            else
			{
			    SendClientMessage(playerid, COLOR_GREY,"Nu esti la centrul de publicitate!");
			}
        }
		else
		{
		    SendClientMessage(playerid, COLOR_GREY, "Trebuie sa astepti 1 minut dupa fiecare anunt");
		}
    }
    return 1;
}
Reply
#2

Код:
if(strcmp(cmd, "/advertise", true) == 0 || strcmp(cmd, "/ad", true) == 0) 
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "Nu esti logat!");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ad)vertise [advert text]");
            return 1;
        }
        if(PermisAnunt[playerid] == 1) 
        {
            IfIsPlayerInRangeOfPoint(playerid,7,-25.1326,-139.0670,1003.5469);
			{
            new payout = idx * 5;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "* Acest anunt costa $%d, bani de care nu dispuneti.", payout);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "PUBLICITATE: %s,  Contact: %d",  result,PlayerInfo[playerid][pPnumber],playerid);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Ai platit $%d~n~~w~Mesajul contine: %d Caractere", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 5);
            PermisAnunt[playerid] = 0; 
            SetTimerEx("Anunt", 60000, 0, "d", playerid); 
            }
            }
            else
			{
			    SendClientMessage(playerid, COLOR_GREY,"Nu esti la centrul de publicitate!");
			}
        }
		else
		{
		    SendClientMessage(playerid, COLOR_GREY, "Trebuie sa astepti 1 minut dupa fiecare anunt");
		}
    }
    return 1;
}
Reply
#3

There is still one extra closing bracket.
Reply
#4

Код:
if(strcmp(cmd, "/advertise", true) == 0 || strcmp(cmd, "/ad", true) == 0) 
{
    if(IsPlayerConnected(playerid))
    {
        if(gPlayerLogged[playerid] == 0)
        {
            SendClientMessage(playerid, COLOR_GREY, "Nu esti logat!");
            return 1;
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
            idx++;
        }
        new offset = idx;
        new result[64];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
            result[idx - offset] = cmdtext[idx];
            idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
            SendClientMessage(playerid, COLOR_GRAD2, "USAGE: (/ad)vertise [advert text]");
            return 1;
        }
        if(PermisAnunt[playerid] == 1) 
        {
            if(IsPlayerInRangeOfPoint(playerid,7,-25.1326,-139.0670,1003.5469));
			{
            new payout = idx * 5;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "* Acest anunt costa $%d, bani de care nu dispuneti.", payout);
                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "PUBLICITATE: %s,  Contact: %d",  result,PlayerInfo[playerid][pPnumber],playerid);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Ai platit $%d~n~~w~Mesajul contine: %d Caractere", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 5);
            PermisAnunt[playerid] = 0; 
            SetTimerEx("Anunt", 60000, 0, "d", playerid); 
            }
            }
            else
			{
			    SendClientMessage(playerid, COLOR_GREY,"Nu esti la centrul de publicitate!");
			}
        }
		else
		{
		    SendClientMessage(playerid, COLOR_GREY, "Trebuie sa astepti 1 minut dupa fiecare anunt");
		}
    }
    return 1;
}
Reply
#5

pawn Код:
IfIsPlayerInRangeOfPoint(7,-25.1326,-139.0670,1003.5469,0,0,0,0,0,0,0);
What's that?

1) Using "IfIsPlayerInRangeOfPoint" is incorrect. The statement is "if" with lower-case and not "If" as you used. Also it's a statement that means you should use the condition inside parentheses and without a semicolon at the end (otherwise it'll give about empty statement):
pawn Код:
if (IsPlayerInRangeOfPoint(/* ARGUMENTS */))
{
    // code.. if the player is in range
}
The arguments are also wrong. IsPlayerInRangeOfPoint has 5 parameters (playerid, range, x, y, z) and you used 11 arguments (assuming you just copied the arguments of AddPlayerClass after /save -ing). So extracting the x, y, z arguments:
pawn Код:
if (IsPlayerInRangeOfPoint(playerid, 5.0, -25.1326, -139.0670, 1003.5469))
{
    // code.. if the player is in range
}
I used 5.0 as range, change to whatever you prefer.
Reply
#6

Quote:

if(IsPlayerInRangeOfPoint(playerid,7,-25.1326,-139.0670,1003.5469));

Without that " ; " but i got it. Thanks to both of you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)