Payphone script
#1

Im tryin to make add payphones to my script this is what i have so far .. i have trouble its just telling me when im go to the point i specified as a payphone i recieve the send error "you are not at a working payphone"
so im not sure why ists not recognizing that im inrange of payphone
pawn Код:
//------------------------------PAYPHONES------------------------------------------------//
new Float:pay_phone[2][3] = {

    {1807.4861,-1599.31,13.5469}, // payphone 1
    {1710.9800,-1604.9263,13.5469}, // payphone 2


};

stock NearestPayphone(playerid)
{

    for(new i = 0; i < sizeof(pay_phone); i ++)
    {

        if(IsPlayerInRangeOfPoint(playerid,25.0,pay_phone[i][0],pay_phone[i][1],pay_phone[i][2]))
        {

            return i;

        }

    }
    return -1;

}

COMMAND:payphone(playerid,params[])
{

    new pphone = NearestPayphone(playerid);
    if(pphone > 0)
    {
        new idx = 0;
        new tmp[64];
        tmp = strtok(params,idx);
        if(!strlen(tmp)) { SendClientMessageA(playerid,COLOR_LIGHTRED,"USAGE: /payphone [phone number]"); return 1; }
        new number = strval(tmp);
        if(number > 0)
        {

            BeginCall(playerid,number);
            return 1;

        }
        else
        {

            SendErrorMsg(playerid,"Invalid phone number.");
            return 1;

        }
    }
    else
    {

        SendErrorMsg(playerid,"You are not near a working Payphone"); // gives me this error when im
        return 1;

    }

}
**any help would be nice im kinda new at this have dove head first...
Reply
#2

hory shet

Put your code inbetween [.pawn] and [./pawn] please. (without the dots)
Reply
#3

yea my bad i forgot
Reply
#4

If it gives you "i dont have cell or am not in a house " message then the error must probably be in the BeginCall function.
Reply
#5

What's the problem?
Reply
#6

sry let me explain i made changes before i posted the code ingame im getting"You are not near a working Payphone" when i try to do /payphone at the first point i made.
Reply
#7

pawn Код:
forward bool:NearestPayphone(playerid); // usually placed on top of script
pawn Код:
stock bool: NearestPayphone( playerid )
{
    new
        bool:in_range
    ;
    for(new i; i != sizeof(pay_phone); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid,25.0,pay_phone[i][0],pay_phone[i][1],pay_phone[i][2]))
        {
            in_range = true;
            break;
        }
    }
    return in_range;
}
this?
Reply
#8

What is the issue ?
Reply
#9

so something like this im not sure how to apply that change to command is that correct way?

pawn Код:
forward bool:IsPlayerInRangeOfPayPhone(playerid);

stock bool:IsPlayerInRangeOfPayPhone(playerid)
{
    new
        bool:in_range
    ;
    for(new i; i != sizeof(pay_phone); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid,25.0,pay_phone[i][0],pay_phone[i][1],pay_phone[i][2]))
        {
            in_range = true;
            break;
        }
    }
    return in_range;
}

COMMAND:payphone(playerid,params[])
{

   
    if(IsPlayerInRangeOfPayPhone(playerid))
    {
        new idx = 0;
        new tmp[64];
        tmp = strtok(params,idx);
        if(!strlen(tmp)) { SendClientMessageA(playerid,COLOR_LIGHTRED,"USAGE: /payphone [phone number]"); return 1; }
        new number = strval(tmp);
        if(number > 0)
        {

            BeginCall(playerid,number);
            return 1;

        }
        else
        {

            SendErrorMsg(playerid,"Invalid phone number.");
            return 1;

        }
    }
    else
    {

        SendErrorMsg(playerid,"You are not near a working Payphone"); // gives me this error when im
        return 1;

    }

}
and im not sure if i still need this i assume i do to define the payphone points
pawn Код:
new Float:pay_phone[2][3] = {

    {1807.4861,-1599.31,13.5469}, // payphone 1
    {1710.9800,-1604.9263,13.5469}, // payphone 2


};
Reply
#10

Try and change
Quote:

if(pphone > 0)

to
Quote:

if(pphone != -1)

I guess you are standing at your first payphone (1807.4861,-1599.31,13.5469) ?
If yes then that is why it says that as it returns 0 and not > 0 (1 or above)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)