Checkpoint Timer
#1

Ok this may be a hard question to ask on the forum and just tell me if something that can't be answered here.


Ok I have a checkpoint mapped. How would I make it so when I enter that checkpoint another checkpoint I map shows up and a timer starts and I have X amount of time to get to the other checkpoint?


E.g. I enter checkpoint 1 and checkpoint 2 shows up on radar and timer shows up with 150 seconds time to get to checkpoint 2?
Reply
#2

Heres a really simple peice of code
pawn Код:
//put this at the top
new player cprun = 0, cprunTimer;

//put this wherever you want to start your checkpoint task
SetPlayerCheckpoint(playerid, x,y,z,size);

public OnPlayerEnterCheckpoint(playerid)
{
  if(cprun==0)
    {
      DisablePlayerCheckpoint(playerid);
        //this is the second checkpoint
        SetPlayerCheckpoint(playerid, x,y,z,size);
        //set timer for 20 seconds
        cprunTimer = SetTimerEx("Failcprun", 20000, 0, "d", playerid);
        cprun = 1;
    }else if(cprun==1)
    {
      KillTimer(cprunTimer);
        SendClientMessage(playerid, 0xAAAAAAAA, "you finished the Checkpoint Run");
    }
}

public Failcprun(playerid)
{
  SendClientMessage(playerid, 0xAAAAAAAA, "you failed the Checkpoint Run");
  DisablePlayerCheckpoint(playerid);
}
Reply
#3

I tried that code and all I did was edit the coordinates and I get these errors:

C:\Users\*********\scripts\Gamemodes\*********.pwn (44 : warning 202: number of arguments does not match definition
C:\Users\*********\scripts\Gamemodes\*********.pwn (464) : error 001: expected token: ";", but found "-identifier-"
C:\Users\*********\scripts\Gamemodes\*********.pwn (467) : error 021: symbol already defined: "SetPlayerCheckpoint"
C:\Users\*********\scripts\Gamemodes\*********.pwn (471) : error 017: undefined symbol "cprun"
C:\Users\*********\scripts\Gamemodes\*********.pwn (477) : error 017: undefined symbol "cprunTimer"
C:\Users\*********\scripts\Gamemodes\*********.pwn (47 : error 017: undefined symbol "cprun"
C:\Users\*********\scripts\Gamemodes\*********.pwn (47 : warning 215: expression has no effect
C:\Users\*********\scripts\Gamemodes\*********.pwn (479) : error 017: undefined symbol "cprun"
C:\Users\*********\scripts\Gamemodes\*********.pwn (481) : error 017: undefined symbol "cprunTimer"
C:\Users\*********\scripts\Gamemodes\*********.pwn (486) : warning 235: public function lacks forward declaration (symbol "Failcprun")
C:\Users\Johnny\Desktop\scripts\Gamemodes\trucking .pwn(493) : warning 203: symbol is never used: "player"

How would I fix that?
Reply
#4

Turns out I forgot to define cprun and cpruntimer but even after defining them I still get:

Код:
.pwn(470) : error 021: symbol already defined: "SetPlayerCheckpoint"
.pwn(474) : error 029: invalid expression, assumed zero
.pwn(474) : warning 215: expression has no effect
.pwn(474) : error 001: expected token: ";", but found ")"
.pwn(474) : error 029: invalid expression, assumed zero
.pwn(474) : fatal error 107: too many error messages on one line
Reply
#5

//put this wherever you want to start your checkpoint task
SetPlayerCheckpoint(playerid, x,y,z,size);

You can't just put that anywhere, it has to go inside another function.

What is line 474?
Reply
#6

Line 474 = "if(cprun==0)"
Reply
#7

That doesn't make sense. Post the code where you have put this.
Oh and make sure cprun is a global variable.
Reply
#8

Quote:
Originally Posted by mansonh
SetPlayerCheckpoint(playerid, x,y,z,size);
I believe you need to put that on

pawn Код:
public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}
Reply
#9

He can't put it on gamemode init, because there is no playerid in gamemodeinit.
He could put it in playerspawn or if he had a command like /cpgame.

But the error he has now is something odd, will have to see how he is using the code to fix it.
Reply
#10

ohh well yea ur right :/ jesussave... show us the whole code and point out the lines with the problems.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)