Checkpoint / Area sub-streamer for incognito's streamer plugin -
Pottus - 18.03.2013
Checkpoint / Area Sub-Streamer
These includes help organize your checkpoints and areas into macro functions which avoids the hassle of having a lot of code in OnPlayerEnterDynamicCP(), OnPlayerLeaveDynamicCP(), OnPlayerEnterDynamicArea() and OnPlayerLeaveDynamicArea(). There is a trade off with this you will lose a bit of efficiency since the sub-streamer needs to search through the array to look up which CP/Area has been triggered.
Usage:
Areas
Code:
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)
Checkpoints
Code:
stock AddDynamicCP(Float:x, Float:y, Float:z, Float:size, CName[], worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 100.0)
stock RemoveDynamicCheckPoint(cpindex)
Example Areas
Code:
#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;
}
Example Checkpoints
Code:
#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;
}
Additional Notes
areaid = Area ID in the streamer
areaindex = Area index in the sub-streamer
cpid = Checkpoint ID in the streamer
cpindex = Checkpoint Index in the substreamer
You can use multiple macro references to call a single macro.
Code:
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");
Download:
http://www.mediafire.com/?luan2tbehkxwnpe
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
vyper - 19.03.2013
I didn't checked this but from the information you wrote, it seems pretty cool
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
new121 - 20.03.2013
I havn't tested this yet, but this is a really great idea. From the sounds of this though the more checkpoints and areas you use the slower it will be is that correct?
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
RajatPawar - 20.03.2013
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?
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Pottus - 20.03.2013
Quote:
Originally Posted by Rajat_Pawar
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?
|
It goes like this....
Code:
#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;
}
In this manner if your using includes in your gamemode there is no need for hooking or tossing everything in one place you can initialize a checkpoint / area anywhere and have the macro called anywhere.
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Toxik - 19.03.2014
not work...
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Pottus - 21.03.2014
Quote:
Originally Posted by ******
Why not just index the array by CP IP/area ID, instead of looping through? That is VERY slow!
|
Good idea, I wrote this over a year ago so I know better these days
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.
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Gigi-The-Beast - 21.03.2014
Why don't you combine callbacks as one and add a parameter to see if player entered or leaved area/checkpoint?
It is better to have one callback per area/checkpoint, like commands or dynamic dialogs.
From
Code:
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;
}
to
Code:
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;
}
Or if you won't, it is better to change the names, like:
OnCheckPoint and OffCheckPoint
or
EnterCheckPoint and ExitCheckPoint
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Niko_boy - 21.03.2014
Much usefull. i always get trouble when checking such stuff, by trouble i mean some extra lines and never thought of spliting the things.
Also, how about gang zone too ? i mean like they do require somewhat calculation to check if player has entered certain gangzone "ID", can be a good addon to this include aswell ? (like: On Enter/Leave GangZone(playerid, gangzone_id_returned_from_CreateGangZone)
btw it would be good if you add a pastebin link , maybe.
Re: Checkpoint / Area sub-streamer for incognito's streamer plugin -
Pottus - 21.03.2014
You'd have to write your own gangzone streamer rectangular areas could work as a controller for 3D layered gangzones.