All pastes #800452 Raw Edit

Checkpoints System

public cpp v1 · immutable
#800452 ·published 2007-11-28 13:36 UTC
rendered paste body
#include <a_samp>#define CP_BANK  0#define CP_PIRATE  1new playerCheckpoint[MAX_PLAYERS];forward getCheckpointType(playerID);forward isPlayerInArea(playerID, Float:data[4]);forward checkpointUpdate();#define MAX_POINTS 2new Float:checkCoords[MAX_POINTS][4] = {{-36.5483,-57.9948, -17.2655,-49.2967},     //BANK{1894.6128,1445.3431, 2084.9739,1637.8186} //PIRATE};new Float:checkpoints[MAX_POINTS][3] = {{-22.2549,-55.6575,1003.5469},{2000.3132,1538.6012,13.5859}};new checkpointType[MAX_POINTS] = { CP_BANK, CP_PIRATE};main(){	return 1;}public OnGameModeInit(){	SetTimer("checkpointUpdate", 1100, 1);	return 1;}public getCheckpointType(playerID) { return checkpointType[playerCheckpoint[playerID]];}public isPlayerInArea(playerID, Float:data[4]){ new Float:X, Float:Y, Float:Z; GetPlayerPos(playerID, X, Y, Z); if(X >= data[0] && X <= data[2] && Y >= data[1] && Y <= data[3]) {  return 1; } return 0;}public checkpointUpdate(){ for(new i=0; i<MAX_PLAYERS; i++) {     if(IsPlayerConnected(i)) {         for(new j=0; j < MAX_POINTS; j++) {             if(isPlayerInArea(i, checkCoords[j])) {                 if(playerCheckpoint[i]!=j) {                     DisablePlayerCheckpoint(i);                     SetPlayerCheckpoint(i, checkpoints[j][0],checkpoints[j][1],checkpoints[j][2],2);                     playerCheckpoint[i] = j;     }             } else {              if(playerCheckpoint[i]==j) {                  DisablePlayerCheckpoint(i);                  playerCheckpoint[i] = 999;               }             }         }  } }}public OnPlayerEnterCheckpoint(playerid){	switch(getCheckpointType(playerid))	{		case CP_BANK: {			SendClientMessage(playerid, 0xFFFF00AA, "You are at an ATM. To store money use '/bank amount', to withdraw");			SendClientMessage(playerid, 0xFFFF00AA, "money use '/withdraw amount', and '/balance' to see your balance.");		}		case CP_PIRATE: {			SendClientMessage(playerid, 0xFFFF00AA, "You can hold the pirate ship area to gain money.");		}	}}public OnPlayerConnect(playerid){	playerCheckpoint[playerid] = 999;	return 1;}