checkpoint ain't showing with IsPlayerInRangeOfPoint
#1

Hello, I made a checkpoint, under OnPlayerSpawn, I didn't want it to show on map when a player spawns, so I added IsPlayerInRangeOfPoint. But the checkpoint isn't showing, that's the problem.

THIS IS UNDER ONPLAYERSPAWN
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, -1422.1245,-288.1826,14.1484))
    {
        SetPlayerCheckpoint(playerid,-1422.1245,-288.1826,14.1484, 3.1);
    }
    return 1;
Reply
#2

You missed a brace.
pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 3.0, -1422.1245,-288.1826,14.1484))
{
    SetPlayerCheckpoint(playerid,-1422.1245,-288.1826,14.1484, 3.0);
return 1;
}
Reply
#3

Quote:
Originally Posted by ikarus❶❸❸❼
...
Not really no, syntax wise there is no problem with that code.


What is the result that you want to have? Your current code creates a checkpoint if a player spawns near the checkpoint location.
Reply
#4

Quote:
Originally Posted by juice.j
Quote:
Originally Posted by ikarus❶❸❸❼
...
Not really no, syntax wise there is no problem with that code.


What is the result that you want to have? Your current code creates a checkpoint if a player spawns near the checkpoint location.
I tried what ikarus said! But, I want, when a player is near of that point, the checkpoint appears. Everyone spawns somewhere else.
What I need to do?
Reply
#5

As I said, syntax wise, your code is fine - you are not missing a bracket anywhere.

However to get the result you actually want you have to use OnPlayerSpawn is the wrong callback to use (as that only gets triggered when a player spawns).

I am not too sure whether this is the best solution but for instance you might check the current player coordinations with a loop with a timed function.

Код:
forward Inc_CheckPoint();
public Inc_Checkpoint(){
   for(new i=0;i<MAX_PLAYERS;i++){
     if(!IsPlayerConnected(i))
        continue;
     if(IsPlayerInRangeOfPoint(i,){   // intended coordinations
        // your code that shall be executed
     }
}

SetTimer("Inc_CheckPoint",5000,1);
Now this is definitely not a good solution ressource wise and I'd suggest you to come up with a workaround - but to start with and to give you an idea it should do good.

Another problem is, that there can be exceptions and no checkpoints show up if a player quickly runs through the area while the function doesn't trigger in that very moment (in the example above it's called each 5000ms).
Reply
#6

Quote:
Originally Posted by juice.j
As I said, syntax wise, your code is fine - you are not missing a bracket anywhere.

However to get the result you actually want you have to use OnPlayerSpawn is the wrong callback to use (as that only gets triggered when a player spawns).

I am not too sure whether this is the best solution but for instance you might check the current player coordinations with a loop with a timed function.

Код:
forward Inc_CheckPoint();
public Inc_Checkpoint(){
   for(new i=0;i<MAX_PLAYERS;i++){
     if(!IsPlayerConnected(i))
        continue;
     if(IsPlayerInRangeOfPoint(i,){  // intended coordinations
        // your code that shall be executed
     }
}

SetTimer("Inc_CheckPoint",5000,1);
Now this is definitely not a good solution ressource wise and I'd suggest you to come up with a workaround - but to start with and to give you an idea it should do good.
Is this all needed? Seriously, I only want to show checkpoint when a player is in range of that point, why the hell do I need timer? o.O
Reply
#7

Well, how do you want to check and especially - where - whether the player is in that range or not?

You can of course try workarounds and use functions getting called on other events, hence I straightly mentioned that in my post
Reply
#8

Quote:
Originally Posted by juice.j
Well, how do you want to check and especially - where - whether the player is in that range or not?

You can of course try workarounds and use functions getting called on other events, hence I straightly mentioned that in my post
IsPlayerInRangeOfPoint of course, maybe something else that works.
Reply
#9

That's not the problem. Where to put IsPlayerInRangeOfPoint is the question you have to ask yourself.
Reply
#10

IsPlayerInRangeOfPoint doesnt call itself, you need to call it with a timer or another callback.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)