SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/01/2020, 10:18 PM   #1
TokicMajstor
Huge Clucker
 
TokicMajstor's Avatar
 
Join Date: Oct 2018
Location: Bosnia And Herzegovina
Posts: 215
Reputation: 10
Post MapTD - GTA SA Map on a TextDraw

MapTD - GTA SA Map on a TextDraw


This include will make a GTA SA default map on a TextDraw and you can show it to any player using ShowMapForPlayer or hide by using HideMapForPlayer.

This include also contains creating/destroying global/player icons on that map.
In order for this include to work you need to add "#include <TDMap>" on the top of your GameMode/FilterScript somewhere below "#include <a_samp>". Besides adding MapTD.inc to your pawno>includes folder you also need to add folder YSI to the same place (unless you already have YSI) [YSI is included in the download archive].

Updated v1.1 16/1/2019:
-If you try to make Icon/PlayerIcon with IconID that has already been used you will only get an error in the console saying that you first need to destroy the previous icon assigned to that IconID.
-Added IsMapShownForPlayer.
-Added hooks (YSI - y_hooks) for Loading Global TextDraws (Map, Map outline), you don`t need to add LoadMapTD to your OnGameModeInit/OnFilterScriptInit anymore. Since hooks are added this include now requires another include called "y_hooks.inc" from YSI includes pack (this is contained together with the include inside the archive).
-Added default limits for Icons/PlayerIcons (both are limited to 100), if you want to edit limits then just define MAX_ICONS or MAX_PLAYER_ICONS inside your GameMode/FilterScript.
-Added compatibility for FilterScripts, if you are using this include inside a FilterScript then add this to your code:
"#define FS_MapTD 1".


Features:

Code:

-ShowMapForPlayer(playerid)
| Used to show the map on a TextDraw for a specified player.
| Return values:
| returns 1 : if the function was successful
| returns 0 : if playerid was not found
| Parameters:
| playerid : map will be shown for player with this ID

-HideMapForPlayer(playerid)
| Used to hide the map on a TextDraw for a specified player.
| Return values:
| returns 1 : if the function was successful
| returns 0 : if playerid was not found
| Parameters:
| playerid : map will be hidden for player with this ID

-CreateIcon(IconID,type,Float:x,Float:y)	
| Used to create a global icon on the map.
| Return values:
| returns IconID : if the icon was created successfully
| returns -1 : if the icon type or icon ID is wrong
| Parameters:
| IconID : the unique ID of the icon also returned by this function
| type : SAMP map icon type (these types are not available: 0,1,3)
| Float:x : the X position of the icon
| Float:y : the Y position of the icon

-CreatePlayerIcon(playerid,IconID,type,Float:x,Float:y) 
| Used to create a player icon on the map for specified player.
| Return values:
| returns IconID : if the icon was created successfully
| returns -1 : if playerid was not found, the icon type or icon ID is wrong
| Parameters:
| playerid : ID of the player who will see the icon
| IconID : the unique ID of the player icon also returned by this function
| type : SAMP map icon type (these types are not available: 0,1,3)
| Float:x : the X position of the icon
| Float:y : the Y position of the icon

-DestroyIcon(IconID)
| Used to destroy global icon on the map.
| Return values:
| returns 1 : if the icon was destroyed successfully
| returns 0 : if the icon ID was wrong
| Parameters:
| IconID : the unique ID of the icon returned by CreateIcon

-DestroyPlayerIcon(playerid,IconID)
| Used to destroy player icon on the map.
| Return values:
| returns 1 : if the icon was destroyed successfully
| returns 0 : if the icon ID was wrong
| Parameters:
| playerid : ID of the player whose icon will be destroyed
| IconID : the unique ID of the icon returned by CreateIcon

-IsMapShownForPlayer(playerid)
| Used to find out is player looking at the map currently.
| Return values:
| returns 1 : if player is looking at the map
| returns 0 : if player is not looking at the map or playerid is wrong
| Parameters:
| playerid : ID of the player



Pictures:






Download:

Direct Link: MapTD.rar [Included YSI for hooks]

Mediafire: https://www.mediafire.com/file/bnhvp...MapTD.rar/file [Included YSI for hooks]




Note: if you have any problems with TextDraws not showing you may need TextDraw streamer.
Special Thanks to Y _ Less for making YSI.
__________________

My work:
-MapTD - GTA SA Map on a TextDraw

https://forum.sa-mp.com/showthread.php?t=671806

Last edited by TokicMajstor; 16/01/2020 at 06:41 PM. Reason: Update
TokicMajstor is offline   Reply With Quote
Old 13/01/2020, 12:21 AM   #2
AlieN_
Gangsta
 
AlieN_'s Avatar
 
Join Date: Aug 2011
Posts: 584
Reputation: 335
Default Re: MapTD - GTA SA Map on a TextDraw

Nice one, good job!
AlieN_ is offline   Reply With Quote
Old 13/01/2020, 12:10 PM   #3
TokicMajstor
Huge Clucker
 
TokicMajstor's Avatar
 
Join Date: Oct 2018
Location: Bosnia And Herzegovina
Posts: 215
Reputation: 10
Default Re: MapTD - GTA SA Map on a TextDraw

Quote:
Originally Posted by AlieN_ View Post
Nice one, good job!
Thank you


If you have any suggestions or you found a bug reply below
__________________

My work:
-MapTD - GTA SA Map on a TextDraw

https://forum.sa-mp.com/showthread.php?t=671806
TokicMajstor is offline   Reply With Quote
Old 16/01/2020, 11:57 AM   #4
CantBeJohn
Big Clucker
 
CantBeJohn's Avatar
 
Join Date: Oct 2016
Posts: 112
Reputation: 15
Default Re: MapTD - GTA SA Map on a TextDraw

Right away you should definitely hook "LoadMapTD" under OnGamemodeInit automatically so people don't have to manually do it themselves. (hooking tutorial here: https://forum.sa-mp.com/showthread.php?t=574534)

Also use "#if !defined" so players can simply define MAX_ICONS and MAX_PLAYER_ICONS within their own script rather than specifically going into the include to redefine every single time but leave the current defaults if they choose not to redefine it.

Here's how you'd do it:

PHP Code:
#if !defined MAX_ICONS
    #define MAX_ICONS 100
#endif 
I haven't looked into anything else but yeah, I also recommend you create a repo for this include. It's 2020 afterall, this should all be standard with any library.
CantBeJohn is offline   Reply With Quote
Old 16/01/2020, 06:37 PM   #5
TokicMajstor
Huge Clucker
 
TokicMajstor's Avatar
 
Join Date: Oct 2018
Location: Bosnia And Herzegovina
Posts: 215
Reputation: 10
Default Re: MapTD - GTA SA Map on a TextDraw

Quote:
Originally Posted by CantBeJohn View Post
Right away you should definitely hook "LoadMapTD" under OnGamemodeInit automatically so people don't have to manually do it themselves. (hooking tutorial here: https://forum.sa-mp.com/showthread.php?t=574534)

Also use "#if !defined" so players can simply define MAX_ICONS and MAX_PLAYER_ICONS within their own script rather than specifically going into the include to redefine every single time but leave the current defaults if they choose not to redefine it.

Here's how you'd do it:

PHP Code:
#if !defined MAX_ICONS
    #define MAX_ICONS 100
#endif 
I haven't looked into anything else but yeah, I also recommend you create a repo for this include. It's 2020 afterall, this should all be standard with any library.
Thank you for really nice ideas, I know how to make this but I just didn`t (for some reason) get the idea to make that.


So I released an update, and it is already available for download.

Update notes:

Code:
-If you try to make Icon/PlayerIcon with IconID that has already been used you will only get an error in the console saying that you first need to destroy the previous icon assigned to that IconID.
-Added IsMapShownForPlayer.
-Added hooks (YSI - y_hooks) for Loading Global TextDraws (Map, Map outline), you don`t need to add LoadMapTD to your OnGameModeInit/OnFilterScriptInit anymore. Since hooks are added this include now requires another include called "y_hooks.inc" from YSI includes pack (this is contained together with the include inside the archive).
-Added default limits for Icons/PlayerIcons (both are limited to 100), if you want to edit limits then just define MAX_ICONS or MAX_PLAYER_ICONS inside your GameMode/FilterScript.
-Added compatibility for FilterScripts, if you are using this include inside a FilterScript then add this to your code:
"#define FS_MapTD 1".
__________________

My work:
-MapTD - GTA SA Map on a TextDraw

https://forum.sa-mp.com/showthread.php?t=671806
TokicMajstor is offline   Reply With Quote
Old 17/01/2020, 07:03 PM   #6
l0gic
Big Clucker
 
Join Date: Aug 2019
Posts: 81
Reputation: 13
Default Re: MapTD - GTA SA Map on a TextDraw

I would suggest using github for projects like that, makes everything more understandable and easier.
__________________
Coding experience with: PAWN, Java, Python, Javascript, PHP and SQL for about 6 years.
l0gic 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] Making a Health/armour textdraw! (Global textdraw) -Rebel Son- Tutorials 22 21/02/2020 01:27 AM
Clickable textdraw opens wrong textdraw BizzyD Scripting Help 4 26/05/2016 07:34 PM
Moving a textdraw on the y-axis doesn't work. (TextDraw Editor) AndySedeyn Scripting Help 1 14/06/2014 02:50 PM
[FilterScript] [FS] TextDraw editor 0.6 - Multiple textdraw support, for proffesional textdraws Zamaroht Filterscripts 369 20/01/2013 02:46 PM
[Tutorial] --: Creating Textdraw's In The Easiest Way :-- [Helpful for textdraw creators] Nirzor Tutorials 15 04/10/2012 12:32 PM


All times are GMT. The time now is 02:16 AM.


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