SA-MP Forums Archive
OnPlaerEnterCheckpoint - 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)
+--- Thread: OnPlaerEnterCheckpoint (/showthread.php?tid=496447)



OnPlaerEnterCheckpoint - AnonScripter - 22.02.2014

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
    return 1;
}
 
public OnPlayerEnterCheckpoint(playerid)
{
    CreateVehicle(520, 1982.6150, -221.0145, -0.2432, 82.2873, -1, -1, 60000);
    DisablePlayerCheckpoint(playerid);
    return 1;
}
How to know what checkpoint is this player entered ?? or how to know what checkpointid he entered if we have more than 1 checkpoint?


Re: OnPlaerEnterCheckpoint - Kyance - 22.02.2014

Get the streamer plugin ( https://sampforum.blast.hk/showthread.php?tid=102865 ) to create multiple checkpoints, then follow tutorials

Here's a small example xd

pawn Код:
forward OnPlayerEnterDynamicCP(playerid, checkpointid);
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CP[CAPZONE])
    {
        if(UnderAttack[CAPZONE] == 0)
        {
            if(tCP[CAPZONE] != gTeam[playerid])
            {
                CountVar[playerid][CAPZONE] = 25;
                ActiveCAPZONE(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[MTCHILLIAD])
    {
        if(UnderAttack[MTCHILLIAD] == 0)
        {
            if(tCP[MTCHILLIAD] != gTeam[playerid])
            {
                CountVar[playerid][MTCHILLIAD] = 25;
                ActiveMTCHILLIAD(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[LVAIRPORT])
    {
        if(UnderAttack[LVAIRPORT] == 0)
        {
            if(tCP[LVAIRPORT] != gTeam[playerid])
            {
                CountVar[playerid][LVAIRPORT] = 25;
                ActiveLVAIRPORT(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[DAAIRPORT])
    {
        if(UnderAttack[DAAIRPORT] == 0)
        {
            if(tCP[DAAIRPORT] != gTeam[playerid])
            {
                CountVar[playerid][DAAIRPORT] = 25;
                ActiveDAAIRPORT(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[ELQUEBRADOS])
    {
        if(UnderAttack[ELQUEBRADOS] == 0)
        {
            if(tCP[ELQUEBRADOS] != gTeam[playerid])
            {
                CountVar[playerid][ELQUEBRADOS] = 25;
                ActiveELQUEBRADOS(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[BLACKFIELDCHAPEL])
    {
        if(UnderAttack[BLACKFIELDCHAPEL] == 0)
        {
            if(tCP[BLACKFIELDCHAPEL] != gTeam[playerid])
            {
                CountVar[playerid][BLACKFIELDCHAPEL] = 25;
                ActiveBLACKFIELDCHAPEL(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    if(checkpointid == CP[ISLAND])
    {
        if(UnderAttack[ISLAND] == 0)
        {
            if(tCP[ISLAND] != gTeam[playerid])
            {
                CountVar[playerid][ISLAND] = 25;
                ActiveISLAND(playerid);
                Capturing{ playerid } = true;

            } else return SendClientMessage(playerid, COLOR_RED,"[NOTE] - This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid, 2);
    }
    return 1;
}

forward OnPlayerLeaveDynamicCP(playerid, checkpointid);
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    if(checkpointid == CP[CAPZONE] && Captured[playerid][CAPZONE] == 0 && IsPlayerCapturing[playerid][CAPZONE] == 1 && !IsPlayerInDynamicCP(playerid, CP[CAPZONE]))
    {
        LeavingCAPZONE(playerid);
        KillTimer(timer[playerid][CAPZONE]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[MTCHILLIAD] && Captured[playerid][MTCHILLIAD] == 0 && IsPlayerCapturing[playerid][MTCHILLIAD] == 1 && !IsPlayerInDynamicCP(playerid, CP[MTCHILLIAD]))
    {
        LeavingMTCHILLIAD(playerid);
        KillTimer(timer[playerid][MTCHILLIAD]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[LVAIRPORT] && Captured[playerid][LVAIRPORT] == 0 && IsPlayerCapturing[playerid][LVAIRPORT] == 1 && !IsPlayerInDynamicCP(playerid, CP[LVAIRPORT]))
    {
        LeavingLVAIRPORT(playerid);
        KillTimer(timer[playerid][LVAIRPORT]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[DAAIRPORT] && Captured[playerid][DAAIRPORT] == 0 && IsPlayerCapturing[playerid][DAAIRPORT] == 1 && !IsPlayerInDynamicCP(playerid, CP[DAAIRPORT]))
    {
        LeavingDAAIRPORT(playerid);
        KillTimer(timer[playerid][DAAIRPORT]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[ELQUEBRADOS] && Captured[playerid][ELQUEBRADOS] == 0 && IsPlayerCapturing[playerid][ELQUEBRADOS] == 1 && !IsPlayerInDynamicCP(playerid, CP[ELQUEBRADOS]))
    {
        LeavingELQUEBRADOS(playerid);
        KillTimer(timer[playerid][ELQUEBRADOS]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[BLACKFIELDCHAPEL] && Captured[playerid][BLACKFIELDCHAPEL] == 0 && IsPlayerCapturing[playerid][BLACKFIELDCHAPEL] == 1 && !IsPlayerInDynamicCP(playerid, CP[BLACKFIELDCHAPEL]))
    {
        LeavingBLACKFIELDCHAPEL(playerid);
        KillTimer(timer[playerid][BLACKFIELDCHAPEL]);
        Capturing{ playerid } = false;
    }
    if(checkpointid == CP[ISLAND] && Captured[playerid][ISLAND] == 0 && IsPlayerCapturing[playerid][ISLAND] == 1 && !IsPlayerInDynamicCP(playerid, CP[ISLAND]))
    {
        LeavingISLAND(playerid);
        KillTimer(timer[playerid][ISLAND]);
        Capturing{ playerid } = false;
    }
}
etc..
If you still didn't understand it, check some tutorials ( Checkpoint tutorials itself, or a capture zone tutorial.. )


Re: OnPlaerEnterCheckpoint - LocMax - 22.02.2014

Well I think you can only create one checkpoint at time, am I correct?

and as post above me said, use streamer to create multiple checkpoints at time so you will be able to use IDs on them and detect which one of them player entered


Re: OnPlaerEnterCheckpoint - AnonScripter - 22.02.2014

i know how to use streamer, but i want to know how default checkpoint works


Re: OnPlaerEnterCheckpoint - LocMax - 22.02.2014

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
i know how to use streamer, but i want to know how default checkpoint works
You can create one checkpoint at time by the default ones.
Example: if you create this one:
Код:
SetPlayerCheckpoint(playerid, 1982.6150, -220.6680, -0.2432, 3.0);
That will be the only one available for the time until you destroy it.

Код:
CreateVehicle(520, 1982.6150, -221.0145, -0.2432, 82.2873, -1, -1, 60000);
DisablePlayerCheckpoint(playerid);
Then you can create another one


Re: OnPlaerEnterCheckpoint - Kyance - 22.02.2014

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
i know how to use streamer, but i want to know how default checkpoint works
The default checkpoint only lets you do one as far as i know.
Eh:
https://sampwiki.blast.hk/wiki/Function:SetPlayerCheckpoint
https://sampwiki.blast.hk/wiki/IsPlayerInCheckpoint
https://sampwiki.blast.hk/wiki/OnPlayerEnterCheckpoint

xd


Re: OnPlaerEnterCheckpoint - AnonScripter - 22.02.2014

thanks all