[Tutorial] [TUT]Basic Icon streamer!
#1

[TUT]Creating Simple Icon Streamers!
The fun defines .
pawn Код:
#define MAX_MARKERS 1000 //Max amount of markers (Increasing causes the file to be larger decreasing does the opposite).

enum Info
{
  Float:x, //XPos
  Float:y, //YPos
  Float:z, //ZPos
  markertype, //Marker type
  color, //Color of the marker
  Float:Dist
};

new MarkerInfo[MAX_MARKERS][Info];
new MarkerID = -1;
new PlayerMarkers[MAX_PLAYERS][MAX_MARKERS];
new MarkerUsed[MAX_MARKERS];
new IconID[MAX_PLAYERS][MAX_MARKERS];
new SlotsUsed[MAX_PLAYERS][100];
So, now that we have all those out of the way, lets start with our function SetPlayerMapIconEx.

pawn Код:
stock SetPlayerMapIconEx(Float:X, Float:Y, Float:Z, Markertype, Color, Float:dist = 100.0)
{
  MarkerID ++; //Marker ID added
  MarkerUsed[MarkerID] = 1; //Enabled = 1 disabled = 0
  MarkerInfo[MarkerID][markertype] = Markertype; //Marker type check https://sampwiki.blast.hk/wiki/SetPlayerMapIcon for them
  MarkerInfo[MarkerID][x] = X; //X of the icon
  MarkerInfo[MarkerID][y] = Y; //Y of the icon
  MarkerInfo[MarkerID][z] = Z; //Z of the icon
  MarkerInfo[MarkerID][color] = Color; //Color of the icon.
  MarkerInfo[MarkerID][Dist] = dist;
}
Time to stream!

Firstly we need a stream timer, put it somewhere like OnGameModeInit().
pawn Код:
SetTimer("Stream", 500, true); //You can change it to less time or more time per go.
Now the actual stream function.

pawn Код:
forward Stream(); //Forward all timers
public Stream()
{
    for(new i; i<MAX_PLAYERS; i++)//Goes through all players
    {
      if(IsPlayerConnected(i)) //All online players
      {
        for(new S; S<MarkerID+1; S++) //All active Markers
        {
          if(MarkerUsed[S] == 1) //Checks if the Marker is enabled
          {
                    if(IsPlayerInRangeOfPoint(i, MarkerInfo[S][Dist], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z]) && PlayerMarkers[i][S] == 0)//Is the player close enough to the Marker and the player does not already have it streamed
                    {
                        for(new K; K<100; K++)//Loops
                        {
                          if(SlotsUsed[i][K] == 0)//Through all the 100 avalible icon slots
                          {
                            SlotsUsed[i][K]++; //Sets the Icon slot to used
                            IconID[i][S] = K; //Sets the iconid
                            break; //Breaks out of the variable
                          }
                        }
                      SetPlayerMapIcon(i, IconID[i][S], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z], MarkerInfo[S][markertype], MarkerInfo[S][color]);//Create the Marker
              PlayerMarkers[i][S] = 1; //Shows the object streamed for the player
                        continue; //Pulls out of the loop alliteration.
                    }
                }
                if(!IsPlayerInRangeOfPoint(i, MarkerInfo[S][Dist], MarkerInfo[S][x], MarkerInfo[S][y], MarkerInfo[S][z]) && PlayerMarkers[i][S] == 1) //If the player falls out of that distance the marker is destroyed
                {
                  SlotsUsed[i][IconID[i][S]] = 0; //Sets the Icon slot to used
                PlayerMarkers[i][S] = 0; //Sets the player marker to 0 so it's not using it
                  RemovePlayerMapIcon(i, IconID[i][S]); //Deletes the map Icon
                  continue;//Pulls out of the loop alliteration.
                }
            }
        }
    }
    return 1;
}
Extra functions:
pawn Код:
stock RemoveMapIconEx(IconId) //Destroys the Map Icon
{
    MarkerUsed[IconId] = 0;
    for(new i; i<MAX_PLAYERS; i++)
    {
      if(PlayerMarkers[i][ObjectId] == 1)
      {
        PlayerMarkers[i][ObjectId] = 0;
        DestroyPlayerObject(i, IconID[i][ObjecId]);
        SlotsUsed[i][IconID[i][IconId]] = 0
      }
   }
}


stock SetObjectDistance(ObjectId, Float:dist) //Sets the view distance of a Map Icon
{
    MarkerInfo[MarkerID][Dist] = dist;
}
Here is some test icons in south LV, they are house ones that can be used with my other tutorial for making simple houses .

pawn Код:
SetPlayerMapIconEx(2317.130615, 692.398498, 11.460937, 31, 0, 25);
  SetPlayerMapIconEx(2346.872802, 692.999267, 11.460937, 31, 0, 25);
  SetPlayerMapIconEx(2396.482666, 691.487060, 11.453125, 31, 0, 25);
  SetPlayerMapIconEx(2398.476074, 735.344665, 11.460937, 31, 0, 25);
A big thanks to HydraX for testing the script .

If you want the version with the proper indentation http://www.datafilehost.com/download-58b293cd.html
Reply
#2

pro
Reply
#3

This worked for me and him and I'm sure it will work for you..
Reply
#4

Excellent.
Reply
#5

Quote:
Originally Posted by HydraX
This worked for me and him and I'm sure it will work for you..
Thx for testing .

Quote:
Originally Posted by The HungryPinkPig ©
pro
:P

Quote:
Originally Posted by Compton's Eazy E
Excellent.
Thanks
Reply
#6

You make these tutorials so well.
Reply
#7

Quote:
Originally Posted by V1ceC1ty
You make these tutorials so well.
They are pretty easy because most streamers are the exact same . Also, check out my new Checkpoint streamer tutorial.
Reply
#8

You're helpfull! Maybe some nubs will learn this and make their own streamer(s)!

Good job!
Reply
#9

cool ! Releasing Tutorials one on one
Reply
#10

Quote:
Originally Posted by _Saif_
cool ! Releasing Tutorials one on one
:P

Quote:
Originally Posted by [03
Garsino ]
You're helpfull! Maybe some nubs will learn this and make their own streamer(s)!

Good job!
Yeah, and stop asking us for them .
Reply
#11

Is this copied from here: https://sampwiki.blast.hk/wiki/Icon_Streamer
Or did you write it also in the wiki?
Reply
#12

Quote:
Originally Posted by » RэРиR «
Is this copied from here: https://sampwiki.blast.hk/wiki/Icon_Streamer
Or did you write it also in the wiki?
I think he wrote it since wiki registration is opened again.
Reply
#13

This is thing i was searching 15 Years xD :P Nicely done, awesome TUT.
Reply
#14

Quote:
Originally Posted by » RэРиR «
Is this copied from here: https://sampwiki.blast.hk/wiki/Icon_Streamer
Or did you write it also in the wiki?
No, V1cecity ripped my tutorial and posted it there. I later edited it down the bottom reference to this topic but V1ceCity deleted it, I'll see if I can get it removed.
Reply
#15

How can i make the icons Smaller?
Reply
#16

Great, thanks for the tutorial :P
Reply
#17

Link is broken. Can you please post a new one?
Reply
#18

Nice !
Reply
#19

Delete my message, fixed the errors.
Reply
#20

You should explain a bit more..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)