IsPlayerInRangeOfPoint Teleport Help
#1

The code works fine but seems to bug after you do it once works fine the 1st time but the 2nd it dont work and sometimes it just dont work at all can someone look at it and try see problem plz :S


pawn Код:
public OnGameModeInit()
{
    SetTimer("Check", 500, true);
    return 1;
}


forward Check(playerid);
public Check(playerid)
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerInRangeOfPoint(i, 2,2305.9927,-16.2388,26.7496))
        {
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid, 2271.6396,2289.1282,10.8203);
        }
    }
    return 1;
}
Thanks in advanced
Reply
#2

pawn Код:
public OnGameModeInit()
{
    SetTimer("Check", 2500, 1);
    return 1;
}

forward Check();
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 2305.9927, -16.2388, 26.7496))
            {
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2271.6396,2289.1282,10.8203);
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by The_Moddler
Посмотреть сообщение
pawn Код:
public OnGameModeInit()
{
    SetTimer("Check", 2500, 1);
    return 1;
}

forward Check();
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 2305.9927, -16.2388, 26.7496))
            {
                SetPlayerInterior(playerid, 0);
                SetPlayerPos(playerid, 2271.6396,2289.1282,10.8203);
            }
        }
    }
    return 1;
}
can u explain why that 3rd brace and IsPlayerConnected and changing from half a sec to 2 and a half secs fixes it?
Reply
#4

3rd brace is to close IsPlayerConnected.

IsPlayerConnected is to check if the player is connected, and if he is, you check his position, so like that the script will be faster.

I changed it to 2 seconds becouse it's no nesessary to check each 500ms if a player is in an area, if you want change it to 5 secs.
Reply
#5

Its still bugs when another person trys to use the teleport :S

Someone plz help
Reply
#6

pawn Код:
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 2305.9927, -16.2388, 26.7496))
            {
                SetPlayerInterior(i, 0);
                SetPlayerPos(i, 2271.6396,2289.1282,10.8203);
            }
        }
    }
}
change playerid to i
Reply
#7

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
pawn Код:
public Check()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(IsPlayerInRangeOfPoint(i, 2.0, 2305.9927, -16.2388, 26.7496))
            {
                SetPlayerInterior(i, 0);
                SetPlayerPos(i, 2271.6396,2289.1282,10.8203);
            }
        }
    }
}
change playerid to i
LOL I didn't notice that! XD
Reply
#8

You don't really need IsPlayerConnected because IsPlayerInRangeOfPoint has an internal IsPlayerConnected, so it isn't really more effecient and doesn't accomplish anything extra (according to ******'s Code Optimization post). Also, you might want to look into foreach.
Reply
#9

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
You don't really need IsPlayerConnected because IsPlayerInRangeOfPoint has an internal IsPlayerConnected, so it isn't really more effecient and doesn't accomplish anything extra (according to ******'s Code Optimization post). Also, you might want to look into foreach.
Ah, I didn't know that.. can you link where it says that?

Thanks!
Reply
#10

http://forum.sa-mp.com/showthread.ph...ayer+functions

Its under the foreach section. But while there you might as well read the whole thing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)