Checkpoint Help

Started by Alecu Madalin, Aug 22, 2019, 02:21 PM

Previous topic - Next topic

Alecu Madalin

function onScriptLoad ()
{
banca1 <- CreateCheckpoint( null, 0, false, Vector(-937.681, -351.388, 17.8038), ARGB(100, 255, 000, 000), 2);
banca2 <- CreateCheckpoint( null, 0, false, Vector(-938.624, -351.724, 7.22692), ARGB(100, 255, 000, 000), 2);
}

function onCheckpointEntered( player, checkpoint )
{
banca1 = player.Pos = Vector(-938.624, -351.724, 7.22692)
banca2 = player.Pos = Vector(-937.681, -351.388, 17.8038)
}

I have no idea how to make a checkpoint teleport and my code is very very wrong

 :edit:
As always my friend Mursaleen helped me out with the script

//Bank Checkpoint by Mursaleen
//Mursaleen#0305
//Rewritten by me
function onScriptLoad () {
    CreateCheckpoint(null,1,true,Vector(-938.722,-351.345,17.2),ARGB(100,255,0,0),2)
    CreateCheckpoint(null,1,true,Vector(-938.342,-351.895,7.22),ARGB(100,255,0,0),2)
}

function onCheckpointEntered (player,cp) {
    if (cp.ID == 0) {
    player.Pos = Vector(-936.309, -353.718, 7.22692)
    player.Angle = -1.50737
    player.PlaySound(48)
    }
    if (cp.ID == 1) {
        player.Pos = Vector(-934.265, -351.009, 17.8038)
        player.Angle = -0.0258584
        player.PlaySound(48)
    }
}

thumbsup and respect to mursaleen


Mursaleen5544

function onScriptLoad()
{
  banca1 <- CreateCheckpoint( null, 0, true, Vector( -937.681, -351.388, 17.8038 ), RGB(100, 255, 000), 2);
banca2 <- CreateCheckpoint( null, 0, true, Vector( -938.624, -351.724, 7.22692 ), RGB(100, 255, 000), 2);
}

 function onCheckpointEntered( player, cp )
{
 if ( cp.ID == 0 )
{
                player.Pos = Vector(-938.342,-351.895,7.22);
}
else if ( cp.ID == 1 )
{
              player.Pos = Vector(-938.722,-351.345,17.2);
}
}

MatheuS

function onCheckpointEntered( player, checkpoint )
{
if( checkpoint == banca1 ) player.Pos = Vector(-938.624, -351.724, 7.22692)
else if( checkpoint == banca2 ) player.Pos = Vector(-937.681, -351.388, 17.8038)
}

 ::)
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Alecu Madalin

Quote from: MatheuS on Aug 22, 2019, 04:20 PMfunction onCheckpointEntered( player, checkpoint )
{
if( checkpoint == banca1 ) player.Pos = Vector(-938.624, -351.724, 7.22692)
else if( checkpoint == banca2 ) player.Pos = Vector(-937.681, -351.388, 17.8038)
}

 ::)

somehow works but in 1 location
i suck at explaining

MatheuS

Quote from: Alecu Madalin on Aug 22, 2019, 05:52 PM
Quote from: MatheuS on Aug 22, 2019, 04:20 PMfunction onCheckpointEntered( player, checkpoint )
{
if( checkpoint == banca1 ) player.Pos = Vector(-938.624, -351.724, 7.22692)
else if( checkpoint == banca2 ) player.Pos = Vector(-937.681, -351.388, 17.8038)
}

 ::)

somehow works but in 1 location
i suck at explaining


try removing the "else" in the second line
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Alecu Madalin

Quote from: MatheuS on Aug 22, 2019, 06:20 PM
Quote from: Alecu Madalin on Aug 22, 2019, 05:52 PM
Quote from: MatheuS on Aug 22, 2019, 04:20 PMfunction onCheckpointEntered( player, checkpoint )
{
if( checkpoint == banca1 ) player.Pos = Vector(-938.624, -351.724, 7.22692)
else if( checkpoint == banca2 ) player.Pos = Vector(-937.681, -351.388, 17.8038)
}

 ::)

somehow works but in 1 location
i suck at explaining


try removing the "else" in the second line

function onCheckpointEntered (player,checkpoint) {
    if (checkpoint == banca1) {
    player.Pos = Vector(-938.624, -351.724, 7.22692)
    }
    if (checkpoint == banca2) {
    player.Pos = Vector(-937.681, -351.388, 17.8038)
    }
}

it should look like this

NicusorN5

NEVER COMPARE INSTANCES (unless the == operator was overloaded). Instead compare fields of the instances, like checkpoint.ID == checkpoint2.ID. I experienced wrong results comparing CPlayer instances.