Advertisement
Guest User

Lorenc's Map Icon Creator

a guest
Aug 9th, 2010
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.61 KB | None | 0 0
  1. /*
  2.  *
  3.  *   Map Icon maker by Lorenc.
  4.  *   (c) 2010
  5.  *
  6.  */
  7.  
  8. #include <a_samp>
  9.  
  10. #define COLOR_LIGHT_GREEN 0x00D67EFF
  11. #define DIALOG1 1237
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("\n--------------------------------------");
  16.     print(" Map Icon maker by Lorenc loaded.");
  17.     print("--------------------------------------\n");
  18.     return 1;
  19. }
  20.  
  21.  
  22. public OnPlayerCommandText(playerid, cmdtext[])
  23. {
  24.     if (strcmp("/micon", cmdtext, true, 10) == 0) {
  25.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_LIGHT_GREEN, "~!~ You need to be a rcon admin to use this command.");
  26.         ShowPlayerDialog(playerid,DIALOG1,DIALOG_STYLE_INPUT,"Lorenc's Map Icon Creator - Saving!","The map icon will be saved at this location\nhowever you will need to input a map icon id below:","Accept","Decline");
  27.         return 1;
  28.     }
  29.     return 0;
  30. }
  31.  
  32.  
  33. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  34. {
  35.     if(dialogid == DIALOG1) {
  36.         if(response) {
  37.             if(IsNumeric(inputtext)) {
  38.                 new string[126];
  39.                 new Float:X, Float:Y, Float:Z;
  40.                 GetPlayerPos(playerid, X, Y, Z);
  41.                 SetPlayerMapIcon( playerid, 46, X, Y, Z, strval(inputtext), 0 );
  42.                 new File:pos = fopen("MapIcons.LMIC", io_append);
  43.                 format(string, sizeof string, "SetPlayerMapIcon( playerid, 12, %.2f, %.2f, %.2f, %i, 0); //Created by Lorenc's map icon saver \r\n", X, Y, Z, strval(inputtext));
  44.                 fwrite(pos, string);
  45.                 fclose(pos);
  46.                 SendClientMessage(playerid, COLOR_LIGHT_GREEN, string);
  47.                 SendClientMessage(playerid, COLOR_LIGHT_GREEN, "Map icon has been saved to the file MapIcons.LMIC.");
  48.             }
  49.             else {
  50.                 SendClientMessage(playerid, COLOR_LIGHT_GREEN, "~!~ Numbers Only!");
  51.                 ShowPlayerDialog(playerid,DIALOG1,DIALOG_STYLE_INPUT,"Lorenc's Map Icon Creator - Saving!","The map icon will be saved at this location\nhowever you will need to input a map icon id below:","Accept","Decline");
  52.             }
  53.         }
  54.         else {
  55.             SendClientMessage(playerid, COLOR_LIGHT_GREEN, "~!~ Canceled");
  56.         }
  57.         return 1;
  58.     }
  59.     return 1;
  60. }
  61.  
  62.  
  63. forward fcreate(filename[]);
  64. public fcreate(filename[])
  65. {
  66.     if (fexist(filename)){return false;}
  67.     new File:fhandle = fopen(filename,io_write);
  68.     fclose(fhandle);
  69.     return true;
  70. }
  71.  
  72.  
  73. stock IsNumeric(string[])
  74. {
  75.     for (new i = 0, j = strlen(string); i < j; i++) {
  76.         if (string[i] > '9' || string[i] < '0') return 0;
  77.     }
  78.     return 1;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement