0 Members and 1 Guest are viewing this topic.
This custom snippet, will count the number of checkpoints created in the Server. You can also set its type to make it execute something based on its type instead of its ID
function iCreateCheckpoint( player, world, isSphere, pos, argb, radius ) // create a cp, its same as default one, just add an 'i' in start {CreateCheckpoint(player, world, isSphere, pos, argb, radius);CheckpointCount++;cpType[CheckpointCount] = null;print("Checkpoint Created, Count: "+CheckpointCount+"");}function iDeleteCheckpoint( checkpoint ) // delete a cp{cpType[checkpoint.ID] = null;checkpoint.Remove();CheckpointCount--;print(" Checkpoint Removed, Count : "+CheckpointCount+" ");}function SetCheckpointType( checkpoint, type ) { // sets cp typelocal cp = FindCheckpoint(checkpoint);if(cp) {cpType[cp.ID] = type;print("Checkpoint ID :"+cp.ID+" type set to "+type+" "); }}
CheckpointCount <- -1; cpType <- array(2000,null);
// OnScriptLoadiCreateCheckpoint( null, 0, true, Vector(90.697, 278.878, 21.7719), ARGB(255, 255, 255, 255), 2.2); // golf cpiCreateCheckpoint( null, 0, true, Vector(87.4472, -1453.78, 10.5655), ARGB(255, 255, 255, 255), 2.2); // pole cpSetCheckpointType( 0, "golf" ); // sets typeSetCheckpointType( 1, "pole" ); // same// OnCheckpointEnteredfunction onCheckpointEntered( player, checkpoint ){if (cpType[checkpoint.ID] == "golf") {Message("[#ffffff] Golf Club ");}else if(cpType[checkpoint.ID] == "pole") {Message("[#ffff11] Pole Club ");} }
~ There is another alternative to count the checkpoints as well, but i lost that snippet.~ The checkpoint count will only increase or decrease upon using these custom functions and not for default ones, same goes for the checkpoint type thing~ You can add more classes to execute checkpoint functions based on other things than ID, i.e pos, color etc