Checkpoint after connect
#1

hi,

on my server checkpoints are very important so id be very happy if you could help me.
The problem is that if a checkpoint has been created before a new player joins, this new player cant see the checkpoint that has been created before he joined. But the players that had already been in the server before the checkpoint was created are bale to see it.
So my question is: How would i do it like also players can see checkpoints tht had been created before their join?

I manage my checkpoints as follow...
pawn Код:
SetCheckpointForAll(cp1,681.3374,-463.3429,22.5705,2.0);

DisableCheckpointForAll();

stock SetCheckpointForAll(id, Float:cx, Float:cy, Float:cz, Float:csize)

{

    for(new i; i != MAX_PLAYERS; i++)

    {

        SetPlayerCheckpoint(i, cx, cy, cz, csize);
        CheckPoint[i] = id;


    }

}



stock DisableCheckpointForAll()

{

    for(new i; i != MAX_PLAYERS; i++)

    {

        DisablePlayerCheckpoint(i);
        CheckPoint[i] = -1;


    }

}
regards...
Reply
#2

Quote:

for(new i; i != MAX_PLAYERS; i++)

This would flood your server, it will make an endless loop..

Try:
Quote:

for(new i; i < MAX_PLAYERS; i++)

Reply
#3

thx for ur answer.
mhh i used this for a long time and nothing has ever been wrong with this stock?
any idea how to solve my problem above?
Reply
#4

pls may someone help me?
Reply
#5

OnPlayerConnect
SetCheckPointForPlayer();// be sure to set it to the current checkpoint
then after that your script will do the rest
Reply
#6

mhh,
could u explain some more pls?
Reply
#7

More or less fangoth1 meant that

And this wont flood anything if MAX_PLAYERS is bigger than -1 (which it always is) and an integer
pawn Код:
for(new i; i != MAX_PLAYERS; i++)
We just save the data of the global checkpoint (only one can exist - so its not hard)
pawn Код:
stock CP_ID = -1, Float:CP_Data[4];
pawn Код:
stock SetCheckpointForAll(id, Float:cx, Float:cy, Float:cz, Float:csize)
{
    if(id > -1)
    {
        if(CP_ID != -1)
            DisableCheckpointForAll();
        for(new i; i != MAX_PLAYERS; i++)
            if(SetPlayerCheckpoint(i, cx, cy, cz, csize))
                CheckPoint[i] = id;
        CP_Data[3] = csize;
        CP_Data[0] = cx;
        CP_Data[1] = cy;
        CP_Data[2] = cz;
        CP_ID = id;
        return true;
    }
    return false;
}
pawn Код:
stock DisableCheckpointForAll()
{
    if(CP_ID != -1)
    {
        for(new i; i != MAX_PLAYERS; i++)
            if(DisablePlayerCheckpoint(i))
                CheckPoint[i] = -1;
        CP_ID = -1;
        return true;
    }
    return false;
}
pawn Код:
public OnPlayerConnect(playerid)
{
    if(CP_ID != -1)
        Checkpoint[playerid] = CP_ID,
        SetPlayerCheckpoint(playerid, CP_Data[0], CP_Data[1], CP_Data[2], CP_Data[3]);
}
Reply
#8

thx for ur answer once again

//edit found the error

thank you very much!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)