Mauzen

MapDialog Usage Examples

Nov 3rd, 2011
641
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.33 KB | None | 0 0
  1. /*
  2.     The following example will create and show a MapDialog when typing the "/telemap" command.
  3.     When selecting a position, the script will teleport you to that position.
  4.     Note that this is just an example, and you will fall through the ground when teleporting to a not yet streamed location. To avoid this, you could e.g. use MapAndreas.
  5. */
  6.  
  7. // General:
  8. #define MAPDIALOG_TELEPORT_TO_TARGET    17
  9.  
  10. public OnMapDialogResponse(MapDialog:dialog, msg, Float:x, Float:y, response)
  11. {
  12.     if (msg == MAPDIALOG_TELEPORT_TO_TARGET)
  13.     {
  14.         if (response == MAPDIALOG_RESPONSE_EXIT) DestroyMapDialog(dialog);
  15.    
  16.         if (response == MAPDIALOG_RESPONSE_CLICK)
  17.         {
  18.                 MapDialogSetPlayerPos(dialog, x, y, 50.0);
  19.             DestroyMapDialog(dialog);
  20.         }
  21.     }
  22.     return 1;
  23. }
  24.  
  25. // In OnPlayerCommandText:
  26. if(strcmp(cmd, "/telemap", true) == 0) {
  27.         new MapDialog:md = CreateMapDialog(playerid, false, true, true, MAPDIALOG_TELEPORT_TO_TARGET);     
  28.         SetMapDialogVisible(md, true);
  29.         return 1;
  30.     }
  31.  
  32.  
  33. // -----------------------------------------------------------
  34. /*
  35.     This callback code will prevent all players from scrolling beyond x>2000, and zooming too near to the map
  36. */
  37.  
  38. public OnMapDialogNavigation(MapDialog:dialog, msg, Float:oldx, Float:oldy, Float:oldzoom,
  39.                                 Float:newx, Float:newy, Float:newzoom)
  40. {
  41.     return (newzoom < 10.0) && (x <= 2000.0);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment