03.11.2011, 20:41
(
Последний раз редактировалось Mauzen; 16.11.2011 в 16:49.
)
Hi,
I was inactive for a while, and didnt release something for an even longer time. But as I noticed some of the new 0.3d features are really handy, I decided to play a bit with them. The result is this include. It combines the new sprite textdraws with an old idea I had to control something with your mouse.
Again I paid much attention to the ability of customization and generalization. This is not a ready-to-use include, but a functional library that adds scripting functions to your script.
What is it?
This include provides a "map dialog". A map dialog is a set of textdraws showing the whole SA map, and some optional info textdraws (controls and position). You can create map dialogs, show and hide them for a player (only one player/dialog) and catch different events. If a map dialog is shown to a player, he can scroll through the map using either the directional keys, or his mouse. You can also zoom in and out, jump to your player position, select a point (more about that later) or - of course exit it.
Update for 0.3d: If you just wanna have a map to get the position the player clicks at, use OnPlayerClickMap from 0.3d, so you just have to use this include if you want to use it for more than just that now.
How to control?
Default keys are:
RMB + mouse / movement keys: scrolling
KEY_FIRE: Select the current position
KEY_YES: Zoom in
KEY_CTRL_BACK: Zoom out
KEY_SPRINT: jump to the player's position
KEY_SECONDARY_ATTACK: exit
Scripting functions
I will only list the functions here. You can read how to use them in the code documentation.
What to use this for?
There are a bunch of things you can do with this. The most common function would be to replace the map-teleport-trick (allow player teleport on SA map, catch the teleport event, process the location). This works, but I never really liked it, with the MapDialogs you can do it the more native way, without a detour.
Other uses could be easy position spotting, e.g. for placing pickups or cars.
It would take too long to analyse every single possible use, just ask your imagination!
How to use this in your script?
I dont want to tell too much in the section. Basically, include it, and add at least the OnMapDialogResponse callback always returning 1, or your players will get stuck in the dialogs. When setting the player's position in one of the callbacks, dont use SetPlayerPos, as the position is locked and so it wont work. Use MapDialogSetPlayerPos(MapDialog:dialog, Float: x, Float:y, Float:z) instead.
There are also some defines that you can change as you like, should also be quite self-explaining.
I dont think the scripting part needs big explanation, however, Ill add a short example code in the download section.
Known bugs:
Depending on how many people are interested in this include I might release some updated versions, so tell me if you find this include useful! I already got a set of ideas, but am not sure if they are useful or not. (e.g. MapIcons, Playermarkers like on the SA map.)
Changelog
0.1b: Removed zone detection due to copyright issues.
Your permissions, Credits
The same thing as for all my scripts.
You are allowed to use this include for your server.
You may modify it as much as you like for private use.
You are not allowed to re-release or sell the original or an edited version without my permission.
If you use this include, or parts of it for your own script, please dont forget to give me some credits in any way.
Links/Download
MapDialog include V0.1b, pastebin (4.11.2011) (ONLY WORKING WITH 0.3D)
Usage examples, pastebin (3.11.2011)
Some screenshots
As always feel free to give some feedback, bug reports, or suggestions
Have fun!
I was inactive for a while, and didnt release something for an even longer time. But as I noticed some of the new 0.3d features are really handy, I decided to play a bit with them. The result is this include. It combines the new sprite textdraws with an old idea I had to control something with your mouse.
Again I paid much attention to the ability of customization and generalization. This is not a ready-to-use include, but a functional library that adds scripting functions to your script.
What is it?
This include provides a "map dialog". A map dialog is a set of textdraws showing the whole SA map, and some optional info textdraws (controls and position). You can create map dialogs, show and hide them for a player (only one player/dialog) and catch different events. If a map dialog is shown to a player, he can scroll through the map using either the directional keys, or his mouse. You can also zoom in and out, jump to your player position, select a point (more about that later) or - of course exit it.
Update for 0.3d: If you just wanna have a map to get the position the player clicks at, use OnPlayerClickMap from 0.3d, so you just have to use this include if you want to use it for more than just that now.
How to control?
Default keys are:
RMB + mouse / movement keys: scrolling
KEY_FIRE: Select the current position
KEY_YES: Zoom in
KEY_CTRL_BACK: Zoom out
KEY_SPRINT: jump to the player's position
KEY_SECONDARY_ATTACK: exit
Scripting functions
I will only list the functions here. You can read how to use them in the code documentation.
pawn Код:
MapDialog:CreateMapDialog(playerid, usecallback, showposition, showhelp, msg=0);
DestroyMapDialog(MapDialog:dialog);
MapDialogScrollTo2D(MapDialog:dialog, Float:x, Float:y, Float:zoom, bool:init=false);
SetMapDialogVisible(MapDialog:dialog, visible);
GetMapDialogOwner(MapDialog:dialog);
GetZoneNameAt(Float:x, Float:y, name[], size=sizeof(name));
MapDialogSetPlayerPos(MapDialog:dialog, Float:x, Float:y, Float:z);
// Callbacks:
OnMapDialogResponse(MapDialog:dialog, msg, Float:x, Float:y, response);
OnMapDialogNavigation(MapDialog:dialog, msg, Float:oldx, Float:oldy, Float:oldzoom,
Float:newx, Float:newy, Float:newzoom);
There are a bunch of things you can do with this. The most common function would be to replace the map-teleport-trick (allow player teleport on SA map, catch the teleport event, process the location). This works, but I never really liked it, with the MapDialogs you can do it the more native way, without a detour.
Other uses could be easy position spotting, e.g. for placing pickups or cars.
It would take too long to analyse every single possible use, just ask your imagination!
How to use this in your script?
I dont want to tell too much in the section. Basically, include it, and add at least the OnMapDialogResponse callback always returning 1, or your players will get stuck in the dialogs. When setting the player's position in one of the callbacks, dont use SetPlayerPos, as the position is locked and so it wont work. Use MapDialogSetPlayerPos(MapDialog:dialog, Float: x, Float:y, Float:z) instead.
There are also some defines that you can change as you like, should also be quite self-explaining.
I dont think the scripting part needs big explanation, however, Ill add a short example code in the download section.
Known bugs:
- Sometimes parts of, or the whole map is flickering or lagging. This is probably caused by the way I "stream" the textdraws. However, I couldnt find the reason for it yet.
- Mouse movement speed might dither. This is caused by the way I detect the movements and can only be reduced by lengthening the update interval.
- (Not really a bug) A lot of sections in the code are deactivated. This is because I was planning some things that I did not fully implement yet. They might be used in possible future versions.
Depending on how many people are interested in this include I might release some updated versions, so tell me if you find this include useful! I already got a set of ideas, but am not sure if they are useful or not. (e.g. MapIcons, Playermarkers like on the SA map.)
Changelog
0.1b: Removed zone detection due to copyright issues.
Your permissions, Credits
The same thing as for all my scripts.
You are allowed to use this include for your server.
You may modify it as much as you like for private use.
You are not allowed to re-release or sell the original or an edited version without my permission.
If you use this include, or parts of it for your own script, please dont forget to give me some credits in any way.
Links/Download
MapDialog include V0.1b, pastebin (4.11.2011) (ONLY WORKING WITH 0.3D)
Usage examples, pastebin (3.11.2011)
Some screenshots
As always feel free to give some feedback, bug reports, or suggestions
Have fun!