30.03.2014, 12:54
Hi.
This is very limiting code, as you'll have to declare (AREAS) * 2 arrays of 2 cells for all the areas in your mode, MANUALLY, write the code for each manually.. why not teach new people a better way?
I've just added some code, and copied some of yours. Sorry, lazy me
This is very limiting code, as you'll have to declare (AREAS) * 2 arrays of 2 cells for all the areas in your mode, MANUALLY, write the code for each manually.. why not teach new people a better way?
pawn Code:
static mapZones[MAX_GANGZONES] = {-1, ...},
mainTimer;
new Float: gZones[][4] =
{
{-838.9635, 1163.5237, 569.5944, 2742.9941}
// {minX, minY, maxX, maxY}
};
forward public MainTimer();
public OnGameModeInit()
{
for(new i = 0; i < sizeof(gZones); i++)
mapZones[i] = GangZoneCreate(gZones[i][0], gZones[i][1], gZones[i][2], gZones[i][3]);
mainTimer = SetTimer("MainTimer", 1000, true);
return 1;
}
public OnPlayerDisconnect(playerid)
{
for(new i = 0; i < sizeof(gZones); i++)
GangZoneHideForPlayer(playerid, mapZones[i]);
return 1;
}
public OnPlayerConnect(playerid)
{
for(new i = 0; i < sizeof(gZones); i++)
GangZoneShowForPlayer(playerid, MapZone, 0xBBBBBB88);
// Again, per zone colors can be added in the array too!
return 1;
}
public MainTimer()
{
new Float:HP; // player health
for(new i= 0; i < MAX_PLAYERS; i++) // loops through players
{
if(IsPlayerConnected(i)) //You can add more exceptions here, where you don't want boundaries e.g. dms, duels, etc.
{
for(new j = 0; j < sizeof(gZones); j++)
{
if(IsPlayerInArea(i, gZones[j][0], gZones[j][1], gZones[j][2], gZones[j][3] ) != 1) // check if the player is not in the area/zone.
{
GetPlayerHealth(i, HP); // gets player health
SetPlayerHealth(i, HP-5); // reduces -5%, every 1 second.
GameTextForPlayer(i, "~r~Stay inside boundaries~n~or you will be killed!", 3000, 3); // Shows a game text for the player who got out of the boundaries, 3000 = 3 seconds, 3 = font style.
}
}
}
}
}