How to set up a checkpoint?
#1

How to set up a checkpoint to trigger an event?
For example, players came to a red circle, the server will give him some money
Sorry for my bad English.
Reply
#2

Код:
OnPlayerEnterCheckpoint(playerid, checkpointid)
?
Reply
#3

Yes!Thank you!
Quote:
Originally Posted by Knekt
Посмотреть сообщение
Код:
OnPlayerEnterCheckpoint(playerid, checkpointid)
?
Reply
#4

pawn Код:
OnPlayerEnterCheckpoint(playerid, checkpointid)
{
      GivePlayerMoney(playerid, AMOUNT OF MONEY HERE!);
      return 1;
}
pawn Код:
OnGameModeInit
}
    SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
     return 1;
}
Reply
#5

Thank you!
Can you add a timer? Players must wait for 20 seconds at a checkpoint in order to get money.
Quote:
Originally Posted by Knekt
Посмотреть сообщение
Код:
OnPlayerEnterCheckpoint(playerid, checkpointid)
?
Quote:
Originally Posted by Mriss
Посмотреть сообщение
pawn Код:
OnPlayerEnterCheckpoint(playerid, checkpointid)
{
      GivePlayerMoney(playerid, AMOUNT OF MONEY HERE!);
      return 1;
}
pawn Код:
OnGameModeInit
}
    SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
     return 1;
}
Reply
#6

First add this:

Код:
OnGameModeInit
{
       new checkpoint[MAX_PLAYERS];
       new Timer;
       SetPlayerCheckpoint(playerid, Float:x, Float:y, Float:z, Float:size);
       return 1;
}
timer is new timer variable which will determine how much time we need to wait in checkpoint.

checkpoint will determine max cps we can use.

next

Код:
public OnPlayerEnterCheckpoint(playerid) // If the player enters a particluar checkpoint
{
    Timer = SetTimerEx("GiveStats", 20000, false, "i", playerid); 
    checkpoint[playerid] = 1; 
    return 1;
}
if you want player to fail if he leaves checkpoint, then add this:

Код:
public OnPlayerLeaveCheckpoint(playerid)
{
    if(checkpoint[playerid] == 1)
    {
        KillTimer(Timer);
        checkpoint[playerid] = 0;
    }
    return 1;
}
so, if player succeds:

Код:
forward GiveStats(playerid);
public GiveStats(playerid)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+10 ); //"10" is number of score player will receive, feel free to change it
GivePlayerMoney(playerid,9999); //"9999" is money player will receive
SendClientMessage(playerid, 0x0000FF ,"You've capture the zone and received 9999 $ and10 score");
Hope I helped you.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)