OnPlayerKey
#2

You're using "new a" which is always set to 0.
Which means you have to be close to the ATM that's occupying index 0.

You need to loop through your ATMs and check if the player is close to one of them.
For optimization, you should create a global variable which stores the number of ATMs (So you don't have to loop using MAX_ATM)

PHP Code:
#define MAX_ATM        51 
#define ATM_OBJECT    2942 
enum aInfo 

    
aID
    
Float:aPosX
    
Float:aPosY
    
Float:aPosZ
    
Float:aAngle
    
aInt
    
aVW
    
boolAtmExist

new 
AtmInfo[MAX_ATM][aInfo], 
Text3D:AtmLabel[MAX_ATM], 
AtmObject[MAX_ATM], 
Iteratori_ATM<MAX_ATM>,
Atm_Count;
// Whenever you add an ATM
Atm_Count++;
// OnPlayerKeyStateChange
printf("Passed key"); 
new 
0
for (; 
Atm_Counta++)
{
    if (
IsPlayerInRangeOfPoint(playerid2.0AtmInfo[a][aPosX], AtmInfo[a][aPosY], AtmInfo[a][aPosZ]))
        break;
}
if (
!= Atm_Count// if a didn't reach Atm_Count, then the player is near an ATM

    
printf("First passed"); 
    if(
PlayerInfo[playerid][AtmCard] != 1
    {
        
ERROR(playerid"You need to purchase Atm Card"); 
        return 
1
    }
    
SPD(playeridDIALOG_BANKDIALOG_STYLE_LIST"Bank""Withdraw money\nPut in bank""Select""Leave"); 
    
printf("Dialog shown"); 
    return 
1

Also, there are two things you should note:

PHP Code:
Text3D:AtmLabel[MAX_ATM]
AtmObject[MAX_ATM
You can just have those two inside of the enum.

And that's not how you're supposed to check for keys.
Carefully read this: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply


Messages In This Thread
OnPlayerKey - by Micko123 - 29.12.2016, 06:17
Re: OnPlayerKey - by Stinged - 29.12.2016, 06:32
Re: OnPlayerKey - by Micko123 - 29.12.2016, 06:34
Re: OnPlayerKey - by RayBiH - 29.12.2016, 07:11
Re: OnPlayerKey - by Micko123 - 29.12.2016, 07:22
Re: OnPlayerKey - by RayBiH - 29.12.2016, 08:24
Re: OnPlayerKey - by Stinged - 29.12.2016, 09:58

Forum Jump:


Users browsing this thread: 1 Guest(s)