SA-MP Forums Archive
IsPlayerNearAtm - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsPlayerNearAtm (/showthread.php?tid=153932)



IsPlayerNearAtm - Jonni8 - 11.06.2010

Hi.

I need some help to check if a player is near atm and when the player is it returns true so i can use it in an function:
pawn Код:
if (NearAtm(playerid) == true)
{
  // stuff
}
else
{
  // stuff
}
so i made this:
pawn Код:
stock NearATM(playerid)
{  
    for (new i=0; i<=sizeof(ATM); i++)
    {
        if (IsPlayerInRangeOfPoint(playerid, 4.0, ATMC[i][X], ATMC[i][Y], ATMC[i][Z]))
        {
            return true;
        }
    }
    return -1;
}
But when i use it in a function
pawn Код:
CMD:bankhelp(playerid, params[])
{
    if (NearATM(playerid))
    {
        SendClientMessage(playerid, RED, "----------ATM----------");
        SendClientMessage(playerid, GREEN, "- /bank einzahlen [Summe]");
        SendClientMessage(playerid, GREEN, "- /bank abheben [Summe]");
        SendClientMessage(playerid, RED, "--------------------------");
    }
    else
    {
        SendClientMessage(playerid, RED, "SERVER: Du bist nicht bei einem ATM");
    }  
    return 1;
}
and im not near an atm then the
Quote:

else

is not shown.

What did i do wrong?


Re: IsPlayerNearAtm - Babul - 11.06.2010

try to replace the "return -1;" into a "return 0;"


Re: IsPlayerNearAtm - Jonni8 - 11.06.2010

I still get the message
Quote:

Unknown Command




Re: IsPlayerNearAtm - Jeffry - 11.06.2010

Try:

pawn Код:
CMD:bankhelp(playerid, params[])
{
    if (!NearATM(playerid)) return SendClientMessage(playerid, RED, "SERVER: Du bist nicht bei einem ATM");
    SendClientMessage(playerid, RED, "----------ATM----------");
    SendClientMessage(playerid, GREEN, "- /bank einzahlen [Summe]");
    SendClientMessage(playerid, GREEN, "- /bank abheben [Summe]");
    SendClientMessage(playerid, RED, "--------------------------");
    return 1;
}

And at the "stock" function keep return 0;


Re: IsPlayerNearAtm - Jonni8 - 11.06.2010

still
Quote:

Unknown Command

hm is anything wrong with my stock?



Re: IsPlayerNearAtm - Flo_White - 11.06.2010

well are you actually near an ATM?
Perhaps you added some wrong coords


Re: IsPlayerNearAtm - Jonni8 - 11.06.2010

when im near an atm it works fine but when im not near an atm then it says
Quote:

unknown command

:S
strange


Re: IsPlayerNearAtm - Aleksandar_Zivanovci - 11.06.2010

Код:
stock NearATM(playerid)
{	
	for (new i=0; i<=sizeof(ATM); i++)
	{
		if (IsPlayerInRangeOfPoint(playerid, 4.0, ATMC[i][X], ATMC[i][Y], ATMC[i][Z]))
		{
			return 1;
		}
	}
	return 0;
}
Код:
CMD:bankhelp(playerid, params[])
{
	if (NearATM(playerid))
	{
		SendClientMessage(playerid, RED, "----------ATM----------");
		SendClientMessage(playerid, GREEN, "- /bank einzahlen [Summe]");
		SendClientMessage(playerid, GREEN, "- /bank abheben [Summe]");
		SendClientMessage(playerid, RED, "--------------------------");
        return 1;
	}
	SendClientMessage(playerid, RED, "SERVER: Du bist nicht bei einem ATM");
	return 1;
}
try like this


Re: IsPlayerNearAtm - Jakku - 11.06.2010

pawn Код:
stock NearATM(playerid)
{  
    for (new i=0; i<=sizeof(ATM); i++)
    {
        if (IsPlayerInRangeOfPoint(playerid, 4.0, ATMC[i][X], ATMC[i][Y], ATMC[i][Z]))
        {
            return true;
        }
    }
    return false;
}


CMD:bankhelp(playerid, params[])
{
    if (NearATM(playerid))
    {
        SendClientMessage(playerid, RED, "----------ATM----------");
        SendClientMessage(playerid, GREEN, "- /bank einzahlen [Summe]");
        SendClientMessage(playerid, GREEN, "- /bank abheben [Summe]");
        SendClientMessage(playerid, RED, "--------------------------");
        return 1;
    }
    SendClientMessage(playerid, RED, "SERVER: Du bist nicht bei einem ATM");
    return 1;
}



Re: IsPlayerNearAtm - Jonni8 - 11.06.2010

So well i found out if i put a coordinate into the
pawn Код:
IsPlayerInRangeOfPoint
then it works.
so something is wrong with my array.
:S
here my array:
pawn Код:
enum Objects
{
    mID,
    Float:X,
    Float:Y,
    Float:Z,
    Float:rX,
    Float:rY,
    Float:rZ
};
// --ATM--
new ATM[2];
new ATMC[][Objects] =
{
    {2942, 1496.3527832031, -1749.9055175781, 15.088212013245, 0.000000, 0.000000, 182.3049621582},
    {2942, 1465.7149658203, -1749.8640136719, 15.088212013245, 0.000000, 0.000000, 179.8349609375}
};

    // --ATM--
    ATM[0] = CreateObject(ATMC[0][mID], ATMC[0][X], ATMC[0][Y], ATMC[0][Z], ATMC[0][rX], ATMC[0][rY], ATMC[0][rZ]); //object (kmb_atm1) (2)
    ATM[1] = CreateObject(ATMC[1][mID], ATMC[1][X], ATMC[1][Y], ATMC[1][Z], ATMC[1][rX], ATMC[1][rY], ATMC[1][rZ]); //object (kmb_atm1) (3)
i already tried to change the array so i have only 1 but i cant figuere out how to make one array out of these 2 because i need the
pawn Код:
sizeof(ATM)