SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 18/03/2013, 06:12 PM   #1
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,424
Reputation: 1238
Default Checkpoint / Area sub-streamer for incognito's streamer plugin

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
Pottus is offline   Reply With Quote
Old 19/03/2013, 04:22 PM   #2
vyper
Huge Clucker
 
vyper's Avatar
 
Join Date: Jul 2009
Location: Hell. x_x
Posts: 369
Reputation: 68
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

I didn't checked this but from the information you wrote, it seems pretty cool
vyper is offline   Reply With Quote
Old 20/03/2013, 04:37 PM   #3
new121
Huge Clucker
 
Join Date: Feb 2012
Posts: 360
Reputation: 21
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

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?
new121 is offline   Reply With Quote
Old 20/03/2013, 05:06 PM   #4
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,287
Reputation: 311
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

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?
RajatPawar is offline   Reply With Quote
Old 20/03/2013, 06:52 PM   #5
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,424
Reputation: 1238
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

Quote:
Originally Posted by Rajat_Pawar View Post
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.
Pottus is offline   Reply With Quote
Old 19/03/2014, 10:40 PM   #6
Toxik
Banned
 
Join Date: Oct 2013
Location: Croatia
Posts: 546
Reputation: 10
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

not work...
Toxik is offline   Reply With Quote
Old 20/03/2014, 02:17 AM   #7
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,886
Reputation: 3126
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

Why not just index the array by CP IP/area ID, instead of looping through? That is VERY slow!
Y_Less is offline   Reply With Quote
Old 21/03/2014, 12:27 PM   #8
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,424
Reputation: 1238
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

Quote:
Originally Posted by Y_Less View Post
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.
Pottus is offline   Reply With Quote
Old 21/03/2014, 01:14 PM   #9
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,886
Reputation: 3126
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

Yes, that is an issue, but you could combine methods and have an array up to a point and then search beyond that. Or use a different search method.
Y_Less is offline   Reply With Quote
Old 21/03/2014, 02:01 PM   #10
Gigi-The-Beast
Huge Clucker
 
Join Date: Jan 2010
Posts: 286
Reputation: 25
Default Re: Checkpoint / Area sub-streamer for incognito's streamer plugin

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
Gigi-The-Beast is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
0.3 (C) To (E) Incognito Streamer Plugin I3Psychedelic Scripting Help 7 31/12/2012 03:46 AM
Incognito Streamer Checkpoint question grekon Scripting Help 3 04/09/2011 08:34 PM
Incognito's streamer plugin sim_sima Help Archive 7 27/05/2011 10:27 AM
incognito streamer plugin... Whizion Help Archive 4 30/08/2010 01:05 PM


All times are GMT. The time now is 06:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.