SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 04/01/2010, 02:08 AM   #1
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,076
Reputation: 406
Default [TUT]Basic Icon streamer!

[TUT]Creating Simple Icon Streamers!

The fun defines .
pawn Code:
#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 Code:
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 [url=http://wiki.sa-mp.com/wiki/SetPlayerMapIcon]http://wiki.sa-mp.com/wiki/SetPlayerMapIcon[/url] 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 Code:
SetTimer("Stream", 500, true); //You can change it to less time or more time per go.

Now the actual stream function.

pawn Code:
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 Code:
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 Code:
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
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller is offline   Reply With Quote
Old 04/01/2010, 02:25 AM   #2
DiddyBop
Gangsta
 
DiddyBop's Avatar
 
Join Date: Aug 2009
Posts: 705
Reputation: 10
Default Re: [TUT]Basic Icon streamer!

pro
DiddyBop is offline   Reply With Quote
Old 04/01/2010, 02:30 AM   #3
HydraX
Gangsta
 
Join Date: Mar 2009
Location: Don`t stalk me..
Posts: 963
Reputation: 18
Default Re: [TUT]Basic Icon streamer!

This worked for me and him and I'm sure it will work for you..
__________________
kthxbai.
http://pastebin.com/cLxes1HM

West Coast Generation - Alpha [0.3e]
108.213.37.171:7777
HydraX is offline   Reply With Quote
Old 04/01/2010, 02:32 AM   #4
Eazy_Efolife
High-roller
 
Join Date: Aug 2009
Posts: 1,206
Reputation: 9
Default Re: [TUT]Basic Icon streamer!

Excellent.
Eazy_Efolife is offline   Reply With Quote
Old 04/01/2010, 07:12 AM   #5
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,076
Reputation: 406
Default Re: [TUT]Basic Icon streamer!

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
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller is offline   Reply With Quote
Old 04/01/2010, 09:18 AM   #6
V1ceC1ty
High-roller
 
V1ceC1ty's Avatar
 
Join Date: Oct 2008
Location: West Australia
Posts: 1,875
Reputation: 221
Default Re: [TUT]Basic Icon streamer!

You make these tutorials so well.
V1ceC1ty is offline   Reply With Quote
Old 04/01/2010, 09:19 AM   #7
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,076
Reputation: 406
Default Re: [TUT]Basic Icon streamer!

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.
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller is offline   Reply With Quote
Old 04/01/2010, 10:46 AM   #8
[03]Garsino
Guest
 
Posts: n/a
Default Re: [TUT]Basic Icon streamer!

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

Good job!
  Reply With Quote
Old 04/01/2010, 11:00 AM   #9
Deat_Itself
Gangsta
 
Join Date: May 2009
Location: UAE (Abudhabi,Shahama)
Posts: 605
Reputation: 4
Default Re: [TUT]Basic Icon streamer!

cool ! Releasing Tutorials one on one
Deat_Itself is offline   Reply With Quote
Old 04/01/2010, 07:24 PM   #10
[HiC]TheKiller
High-roller
 
Join Date: Mar 2008
Location: New Zealand
Posts: 3,076
Reputation: 406
Default Re: [TUT]Basic Icon streamer!

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 .
__________________
People seem to enjoy negitive repping me for topics that I made in 2009.
Therefore, if you want to view my releases, you can go here.

Skype: TheKiller@dr.com
I do NOT script for cash. Add me on MSN if you need help with small issues.
[HiC]TheKiller 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
[Tutorial] [TUT]Basic Checkpoint Streamer [HiC]TheKiller Tutorials 22 12/11/2013 04:11 PM
[Tutorial] [TUT]Basic Object Streamer [HiC]TheKiller Tutorials 33 19/02/2012 02:25 PM
[FilterScript] [FS] VIcons ~ Easy Icon Streamer - V1.1 V1ceC1ty Filterscripts 19 20/03/2011 11:01 AM
[Include] [INC] Icons++ Icon Streamer lavamike Includes 14 25/03/2010 07:51 PM
Minimap icon streamer? kokkie20 Help Archive 3 07/10/2009 11:50 AM


All times are GMT. The time now is 03:13 AM.


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