Készítõ: Fl0rian
A kis include lényege hogy egy változóba menthetjük a checkpoint id-jét és így nem kell változókkal szórakoznunk. (id-t rendel egy cp-hez)
Az include használatához szükséges a YSI.
Használat:
new Checkpoint;
public OnPlayerSpawn( playerid ) { Checkpoint = fSetPlayerCheckpoint( playerid, 0, 0, 3, 3.0 ); }
public fOnPlayerEnterCheckpoint( playerid, cpid ) { if( cpid == Checkpoint ) { printf( \"Belementek.\" ); } return 1; }
#define _inc_y_hooks
#tryinclude < YSI/y_hooks >
forward fOnPlayerEnterCheckpoint( playerid, cpid );
#define INVALID_CPID -1
#define MAX_CPS 100
new CheckPoints[MAX_PLAYERS][MAX_CPS];
hook OnPlayerEnterCheckpoint( playerid ) {
new ret;
new elozo;
for( new i = 0; i < MAX_CPS; i++ ) {
if( CheckPoints[playerid] == 1 && i > elozo ) { elozo = i; ret = i; }
}
CallLocalFunction( \"fOnPlayerEnterCheckpoint\", \"ii\", playerid, ret );
return 1;
}
stock GetFreeCheckPointID( playerid ) {
for( new i; i < MAX_CPS; i++ ) {
if( CheckPoints[playerid] == 0 ) return i;
}
return INVALID_CPID;
}
stock fSetPlayerCheckpoint( playerid, Float:x, Float:y, Float:z, Float:size ) {
if( GetFreeCheckPointID(playerid) == INVALID_CPID ) {
return 1;
}
new cpid = GetFreeCheckPointID(playerid);
SetPlayerCheckpoint( playerid, x, y, z, size );
CheckPoints[playerid][cpid] = 1;
return cpid;
}