SA-MP Forums Archive
isplayerinrangepoint Problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: isplayerinrangepoint Problem (/showthread.php?tid=569886)



isplayerinrangepoint Problem - StarPeens - 03.04.2015

i just trying do it:
pawn Код:
else if(newkeys == KEY_FIRE){
         if(IsPlayerInRangeOfPoint(playerid, 2.4, -1343.5695,-210.2208,14.1484))
        {
        new str[86];
       format(str, sizeof(str), "Weapons","AK47\n\nM4");
       ShowPlayerDialog(playerid, DialogBoxEx, DIALOG_STYLE_MSGBOX, "Weapons", str, "Ok", "Ok");
       }
       return 1;
       }
but when i go to this location, and press key fire, not show. what is wrong or what are left?


Re: isplayerinrangepoint Problem - CalvinC - 03.04.2015

Код:
else if(newkeys == KEY_FIRE)
Quote:
Originally Posted by Wiki
How NOT to check for a key

Let's presume that you want to detect when a player presses their FIRE button, the obvious code would be:
if (newkeys == KEY_FIRE)
This code may even work in your testing, but it is wrong and your testing is insufficient. Try crouching and pressing fire - your code will instantly stop working. Why? Because "newkeys" is no longer the same as "KEY_FIRE", it is the same as "KEY_FIRE" COMBINED WITH "KEY_CROUCH".
Use
Код:
if(newkeys & KEY_FIRE)
I don't think the else is necessary either.


Re: isplayerinrangepoint Problem - StarPeens - 03.04.2015

Not work yet


Re: isplayerinrangepoint Problem - CalvinC - 03.04.2015

Show the full OnPlayerKeyStateChange.


Re: isplayerinrangepoint Problem - StarPeens - 03.04.2015

pawn Код:
if(newkeys & KEY_FIRE){
         if(IsPlayerInRangeOfPoint(playerid, 2.4, -1343.5695,-210.2208,14.1484))
        {
        new str[86];
       format(str, sizeof(str), "Weapons","AK47\n\nM4");
       ShowPlayerDialog(playerid, DialogBoxEx, DIALOG_STYLE_MSGBOX, "Weapons", str, "Ok", "Ok");
       }
       return 1;
       }
Dialog called:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    if(dialogid == DialogBoxEx)
    {
   if(response)
    {
    if(listitem == 0)
    {
    GiveItem[playerid][MED_KIT] = 1;
    }
    if(listitem == 1)
    {
    GiveItem[playerid][binoculars] = 1;
    }
    if(listitem == 2)
        {
    GiveItem[playerid][bandage] = 1;
    }
    if(listitem == 3)
    {
    GiveItem[playerid][AK47] = 1;
    }
    if(listitem == 4)
    {
    GiveItem[playerid][M4A1] = 1;
    }
    if(listitem == 5)
    {
    GiveItem[playerid][MAP] = 1;
    }
    if(listitem == 6)
    {
    GiveItem[playerid][FULL_BOTTLE] = 1;
   }
  }
 }



Re: isplayerinrangepoint Problem - CalvinC - 03.04.2015

Is that everything you have under OnPlayerKeyStateChange?


Re: isplayerinrangepoint Problem - StarPeens - 03.04.2015

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
Is that everything you have under OnPlayerKeyStateChange?
this dialog that does not appear yes.


Re: isplayerinrangepoint Problem - CalvinC - 03.04.2015

I'm not only talking about the dialog, show the full OnPlayerKeyStateChange code.


Re: isplayerinrangepoint Problem - StarPeens - 03.04.2015

Fixed ty