stock AddDynamicSphereArea(Float:x, Float:y, Float:z, Float:size, AName[], worldid = -1, interiorid = -1, playerid = -1) stock AddDynamicCubeArea(Float:minx, Float:miny, Float:minz, Float:maxx, Float:maxy, Float:maxz, AName[], worldid = -1, interiorid = -1, playerid = -1) stock RemoveDynamicArea(areaindex)
stock AddDynamicCP(Float:x, Float:y, Float:z, Float:size, CName[], worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0) stock RemoveDynamicCheckPoint(cpindex)
#include <dynamicarea>
public OnGameModeInit()
{
AddDynamicSphereArea(1000.0, 1000.0, 1000.0, 4.0, "TestArea");
}
OnArea:TestArea(playerid, areaid, areaindex)
{
SendClientMessage(playerid, "You entered the TestArea");
return 1;
}
ExitArea:TestArea(playerid, areaid, areaindex)
{
SendClientMessage(playerid, "You left the TestArea");
return 1;
}
#include <dynamiccp>
public OnGameModeInit()
{
AddDynamicCP(1000.0, 1000.0, 1000.0, 2.0, "TestCP")
}
OnCheckPoint:TestCP(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP");
return 1;
}
ExitCheckPoint:TestCP(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP");
return 1;
}
AddDynamicSphereArea(2000.0, 1000.0, 1000.0, 4.0, "TestArea");
AddDynamicSphereArea(3000.0, 1000.0, 1000.0, 4.0, "TestArea");
AddDynamicSphereArea(4000.0, 1000.0, 1000.0, 4.0, "TestArea");
|
From what I see, hard work, and for that, first of all, congrats. But, I probably didn't get this much since you didn't explain much. On your note that it reduces the 'hassle' of a lot of code under one call back, I find (personal opinion) it quite easier to group all checkpoint checks under one callback rather than two for each. So can you explain a bit more about this?
|
#include <dynamiccp>
public OnGameModeInit()
{
AddDynamicCP(1000.0, 1000.0, 1000.0, 2.0, "TestCP1")
AddDynamicCP(1000.0, 1000.0, 1000.0, 2.0, "TestCP2")
AddDynamicCP(1000.0, 1000.0, 1000.0, 2.0, "TestCP3")
AddDynamicCP(1000.0, 1000.0, 1000.0, 2.0, "TestCP4")
}
OnCheckPoint:TestCP1(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP1");
return 1;
}
ExitCheckPoint:TestCP1(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP1");
return 1;
}
OnCheckPoint:TestCP2(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP2");
return 1;
}
ExitCheckPoint:TestCP2(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP2");
return 1;
}
OnCheckPoint:TestCP3(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP3");
return 1;
}
ExitCheckPoint:TestCP3(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP3");
return 1;
}
OnCheckPoint:TestCP4(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP4");
return 1;
}
ExitCheckPoint:TestCP4(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP4");
return 1;
}
|
Why not just index the array by CP IP/area ID, instead of looping through? That is VERY slow!
|
It would require some checking however in case a dynamic area/cp was created independently. Another issue is how large to index the array 1000, 10000? I'm guessing that would be up to the end user but there is still the risk of OOB errors possibly if too many areas are created which I doubt would happen anyways.
OnCheckPoint:TestCP1(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You entered the TestCP1");
return 1;
}
ExitCheckPoint:TestCP1(playerid, cpid, cpindex)
{
SendClientMessage(playerid, "You left the TestCP1");
return 1;
}
OnCheckPoint:TestCP1(playerid, cpid, cpindex,state)
{
if(state == STATE_ENTER) SendClientMessage(playerid, "You entered the TestCP1");
else if(state == STATE_EXIT) SendClientMessage(playerid, "You left the TestCP1");
return 1;
}