14.10.2011, 03:08
I have no idea how to make Includes and i want to conver this script into an include. Post it here if you could...
forward OnPlayerEnterCheckPointEx(playerid, checkpoint);
forward mcpCheck();
enum mcpParamsEx
{
bool:mcpCreated,
Float:mcpX,
Float:mcpY,
Float:mcpZ,
};
new mcpParams[30][mcpParamsEx],
mcpId = -1,
mcpUsed,
bool:mcpShown[MAX_PLAYERS][30],
bool:mcpEntered[MAX_PLAYERS][30];
stock CreateCheckpoint(Float, Float:y, Float:z)
{
mcpId = -1;
for (new mcpi = 0; mcpi < 30; mcpi++)
{
if(mcpParams[mcpi][mcpX] == 0)
{
mcpId = mcpi;
break;
}
}
if(mcpId == -1) return -1;
mcpParams[mcpId][mcpCreated] = true;
mcpParams[mcpId][mcpX] = x;
mcpParams[mcpId][mcpY] = y;
mcpParams[mcpId][mcpZ] = z;
if(mcpUsed == 0)
{
SetTimer("mcpCheck",150,true);
mcpUsed = 1;
}
return mcpId;
}
stock ShowPlayerCheckpoint(playerid, mcpid, bool:visable = true)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpId][mcpCreated] == false) return 0;
if(visable == true) SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff0000AA, MAPICON_GLOBAL_CHECKPOINT);
else SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff000000, MAPICON_GLOBAL_CHECKPOINT);
mcpShown[playerid][mcpid] = true;
return 1;
}
stock HidePlayerCheckpoint(playerid, mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpShown[playerid][mcpid] == false) return 0;
if(mcpParams[mcpId][mcpCreated] == 0) return 0;
RemovePlayerMapIcon(playerid, mcpid);
mcpShown[playerid][mcpid] = false;
return 1;
}
stock RemoveCheckpoint(mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpid][mcpCreated] == 0) return 0;
for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
{
if(!IsPlayerConnected(mcpi)) continue;
mcpShown[mcpi][mcpid] = false;
RemovePlayerMapIcon(mcpi, mcpid);
}
mcpParams[mcpid][mcpCreated] = 0;
return 1;
}
stock IsCreated(mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpy][mcpCreated] == true) return 1;
return 0;
}
public mcpCheck() //mcpi = Players || mcpy = checkpoints
{
for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
{
if(!IsPlayerConnected(mcpi)) continue;
for (new mcpy = 0; mcpy < 30; mcpy++)
{
if(mcpShown[mcpi][mcpy] == false) continue;
if(mcpParams[mcpy][mcpCreated] == false) continue;
if(IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == false)
{
mcpEntered[mcpi][mcpy] = true;
CallLocalFunction("OnPlayerEnterCheckPointEx", "ii", mcpi, mcpy);
continue;
}
else if(!IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == true) mcpEntered[mcpi][mcpy] = false;
}
}
}
forward OnPlayerEnterCheckPointEx(playerid, checkpoint);
forward mcpCheck();
enum mcpParamsEx
{
bool:mcpCreated,
Float:mcpX,
Float:mcpY,
Float:mcpZ,
};
new mcpParams[30][mcpParamsEx],
mcpId = -1,
mcpUsed,
bool:mcpShown[MAX_PLAYERS][30],
bool:mcpEntered[MAX_PLAYERS][30];
stock CreateCheckpoint(Float, Float:y, Float:z)
{
mcpId = -1;
for (new mcpi = 0; mcpi < 30; mcpi++)
{
if(mcpParams[mcpi][mcpX] == 0)
{
mcpId = mcpi;
break;
}
}
if(mcpId == -1) return -1;
mcpParams[mcpId][mcpCreated] = true;
mcpParams[mcpId][mcpX] = x;
mcpParams[mcpId][mcpY] = y;
mcpParams[mcpId][mcpZ] = z;
if(mcpUsed == 0)
{
SetTimer("mcpCheck",150,true);
mcpUsed = 1;
}
return mcpId;
}
stock ShowPlayerCheckpoint(playerid, mcpid, bool:visable = true)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpId][mcpCreated] == false) return 0;
if(visable == true) SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff0000AA, MAPICON_GLOBAL_CHECKPOINT);
else SetPlayerMapIcon(playerid, mcpid, mcpParams[mcpid][mcpX], mcpParams[mcpid][mcpY], mcpParams[mcpid][mcpZ], 0, 0xff000000, MAPICON_GLOBAL_CHECKPOINT);
mcpShown[playerid][mcpid] = true;
return 1;
}
stock HidePlayerCheckpoint(playerid, mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpShown[playerid][mcpid] == false) return 0;
if(mcpParams[mcpId][mcpCreated] == 0) return 0;
RemovePlayerMapIcon(playerid, mcpid);
mcpShown[playerid][mcpid] = false;
return 1;
}
stock RemoveCheckpoint(mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpid][mcpCreated] == 0) return 0;
for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
{
if(!IsPlayerConnected(mcpi)) continue;
mcpShown[mcpi][mcpid] = false;
RemovePlayerMapIcon(mcpi, mcpid);
}
mcpParams[mcpid][mcpCreated] = 0;
return 1;
}
stock IsCreated(mcpid)
{
if(0 > mcpid > 29) return 0;
if(mcpParams[mcpy][mcpCreated] == true) return 1;
return 0;
}
public mcpCheck() //mcpi = Players || mcpy = checkpoints
{
for (new mcpSlots = GetMaxPlayers(), mcpi; mcpi < mcpSlots; mcpi++)
{
if(!IsPlayerConnected(mcpi)) continue;
for (new mcpy = 0; mcpy < 30; mcpy++)
{
if(mcpShown[mcpi][mcpy] == false) continue;
if(mcpParams[mcpy][mcpCreated] == false) continue;
if(IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == false)
{
mcpEntered[mcpi][mcpy] = true;
CallLocalFunction("OnPlayerEnterCheckPointEx", "ii", mcpi, mcpy);
continue;
}
else if(!IsPlayerInRangeOfPoint(mcpi, 1.0, mcpParams[mcpy][mcpX], mcpParams[mcpy][mcpY], mcpParams[mcpy][mcpZ]) && mcpEntered[mcpi][mcpy] == true) mcpEntered[mcpi][mcpy] = false;
}
}
}