IsPlayerInRangeOfPoint
#1

Fixed!
Reply
#2

use a timer and show the dialog to the player
Reply
#3

Quote:
Originally Posted by fordawinzz
Посмотреть сообщение
use a timer and show the dialog to the player
Thanks for your help, but by using a timer on teleport command isn't a little "not sure".
Players teleport to /atm1 and after 2 seconds for example it appears the Dialog. There is a chance players aren't near on the atm. In my opinion, it would more easy on teleport command to input the dialog, but I want it, on the further distance 1.0 between players and atm to apper the Dialog. Does anyone know how or have another good suggestion.
Reply
#4

you want to combine those 2 /atm1 commands to do a differnt thing depending on the player close to the atm?
pawn Код:
CMD:atm1(playerid, params[])
{
    if(IsPlayerInRangeOfPoint(playerid, 1.0, 2166.80, 1905.00, 10.72))
    {
        ShowPlayerDialog(playerid, DIALOG_BANKMAIN, DIALOG_STYLE_LIST, "{FFFF00}Bank Account", "Create Bank Account\nLogin Bank Account", "Select", "Cancel");
    }
    else
    {
        ResetPlayerWeapons(playerid);
        SetPlayerPos(playerid, 2160.1636, 1904.6505, 10.8203);
        SetPlayerFacingAngle(playerid, 273.6398);
        if(IsPlayerInRangeOfPoint(playerid, 1.0, 2166.80, 1905.00, 10.72))
        {
            ShowPlayerDialog(playerid, DIALOG_BANKMAIN, DIALOG_STYLE_LIST, "{FFFF00}Bank Account", "Create Bank Account\nLogin Bank Account", "Select", "Cancel");
        }
    }
    return 1;
}
Reply
#5

I want when a player type /atm1 teleport to the coordinates and if player did 2 steps in front and touch the atm(range distance 1.0) then dialog appears. Is it possible something like that?
Reply
#6

It's possible by creating a timer which calls every second or half second a callback which checks if any player is in this area or not.

First we need the timer in OnGameModeInit or OnFilterScriptInit
pawn Код:
//...
SetTimer("SlowUpdate", 500, true);
//...
then this
pawn Код:
new bool:isInAtm[MAX_PLAYERS];
forward SlowUpdate();
public SlowUpdate()
{
    for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
        if(!IsPlayerConnected(playerid)) continue;
        if(IsPlayerInRangeOfPoint(playerid, 2.0, 2166.80, 1905.00, 10.72))
        {
            if(!isInAtm[playerid])
            {
                isInAtm[playerid] = true;
                ShowPlayerDialog(playerid, DIALOG_BANKMAIN, DIALOG_STYLE_LIST, "{FFFF00}Bank Account", "Create Bank Account\nLogin Bank Account", "Select", "Cancel");
            }
        }
        else if(isInAtm[playerid]) isInAtm[playerid] = false;
    }
}
Reply
#7

Thank you!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)