Advertisement
AshBFunky

Scripters Tools

Dec 10th, 2011
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.67 KB | None | 0 0
  1. /*
  2.     Scripters Tools: by funky1234 (Ash)
  3. */
  4.  
  5. #include <a_samp>
  6.  
  7. #define ADMIN_ONLY //Comment this out or remove it if you wish to allow all player to use these commands
  8.  
  9. #define PICKUP_FILE "script_lines/pickups.txt" //The location of your pickups file
  10. #define MAPICON_FILE "script_lines/mapicons.txt" //The location of your map icons file
  11. #define COORDS_FILE "script_lines/coords.txt" //The location of your coords file
  12. #define VEHICLE_FILE "script_lines/vehs.txt" //The location of your vehicle file
  13. #define TEXTLABEL_FILE "script_lines/textlabels.txt" //The location of your 3D Text Label file.
  14. #define CP_FILE "script_lines/checkpoints.txt" //The location of your checkpoint saving file.
  15.  
  16. #define DEFAULT_CP_SIZE 5.0 //Your default checkpoint size that is use in the /makecp command.
  17.  
  18. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  19. #define COLOUR 0xFF00FFFF
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("Line Maker Loaded");
  24. }
  25.  
  26. public OnPlayerCommandText(playerid, cmdtext[])
  27. {
  28.     dcmd(makepickup, 10, cmdtext);
  29.     dcmd(makemapicon, 11, cmdtext);
  30.     dcmd(makepos, 7, cmdtext);
  31.     dcmd(makevehicle, 11, cmdtext);
  32.     dcmd(maketextlabel, 13, cmdtext);
  33.     dcmd(makecp, 6, cmdtext);
  34.     return 0;
  35. }
  36.  
  37. dcmd_makepickup(playerid, params[])
  38. {
  39.     #if defined ADMIN_ONLY
  40.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin Required");
  41.     #endif
  42.     new idx, Float:x, Float:y, Float:z;
  43.     GetPlayerPos(playerid, x, y, z);
  44.     FindSpace(params, idx);
  45.     if(idx == strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /makepickup [modelid] [comment]");
  46.     new orig[64];
  47.     format(orig, sizeof(orig), "%s", params); //All will become clear, read on ;)
  48.     strdel(orig, idx, strlen(orig));
  49.     strdel(params, 0, idx);
  50.     new string[128];
  51.     format(string, sizeof(string), "CreatePickup(%i, 0, %f, %f, %f, 0); //%s", strval(orig), x, y, z, params);
  52.     WriteData(PICKUP_FILE, string);
  53.     format(string, sizeof(string), "Pickup line made: %s", string);
  54.     SendClientMessage(playerid, COLOUR, string);
  55.     return 1;
  56. }
  57.  
  58. dcmd_makemapicon(playerid, params[])
  59. {
  60.     #if defined ADMIN_ONLY
  61.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin Required");
  62.     #endif
  63.     new idx, Float:x, Float:y, Float:z;
  64.     GetPlayerPos(playerid, x, y, z);
  65.     FindSpace(params, idx);
  66.     if(idx == strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /makemapicon [mapiconid] [comment]");
  67.     new orig[64];
  68.     format(orig, sizeof(orig), "%s", params); //And again...
  69.     strdel(orig, idx, strlen(orig));
  70.     strdel(params, 0, idx);
  71.     new string[128];
  72.     format(string, sizeof(string), "SetPlayerMapIcon(playerid, 0, %f, %f, %f, %i, 0, MAPICON_LOCAL); //%s", x, y, z, strval(orig), params);
  73.     WriteData(MAPICON_FILE, string);
  74.     format(string, sizeof(string), "Mapicon line made: %s", string);
  75.     SendClientMessage(playerid, COLOUR, string);
  76.     return 1;
  77. }
  78.  
  79. dcmd_makepos(playerid, params[])
  80. {
  81.     #if defined ADMIN_ONLY
  82.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin Required");
  83.     #endif
  84.     if(!strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /makepos [comment]");
  85.     new Float:x, Float:y, Float:z, Float:fa;
  86.     GetPlayerPos(playerid, x, y, z);
  87.     GetPlayerFacingAngle(playerid, fa);
  88.     new string[128];
  89.     format(string, sizeof(string), "%f, %f, %f, %f //%s", x, y, z, fa, params);
  90.     WriteData(COORDS_FILE, string);
  91.     format(string, sizeof(string), "(Raw) Position Line Made: %s", string);
  92.     SendClientMessage(playerid, COLOUR, string);
  93.     return 1;
  94. }
  95.  
  96. dcmd_makevehicle(playerid, params[])
  97. {
  98.     #if defined ADMIN_ONLY
  99.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin required");
  100.     #endif
  101.     if(!strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage /makevehicle [model id] [comment]");
  102.     new Float:x, Float:y, Float:z, Float:af, string[128], idx;
  103.     FindSpace(params, idx);
  104.     if(idx == strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /makevehicle [model id] [comment]");
  105.     GetPlayerPos(playerid, x, y, z);
  106.     GetPlayerFacingAngle(playerid, af);
  107.     new orig[64];
  108.     format(orig, 64, params);
  109.     strdel(orig, idx, strlen(params));
  110.     strdel(params, 0, idx);
  111.     if(!IsValidVehicleModel(strval(orig))) return SendClientMessage(playerid, COLOUR, "Invalid Vehicle Model");
  112.     format(string, sizeof(string), "CreateVehicle(%i, %f, %f, %f, %f, -1, -1, -1); //%s", strval(orig), x, y, z, af, params);
  113.     WriteData(VEHICLE_FILE, string);
  114.     format(string, sizeof(string), "Vehicle Line Made: %s", string);
  115.     SendClientMessage(playerid, COLOUR, string);
  116.     return 1;
  117. }
  118.  
  119. dcmd_maketextlabel(playerid, params[])
  120. {
  121.     #if defined ADMIN_ONLY
  122.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin required");
  123.     #endif
  124.     if(!strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /maketextlabel [text] [comment]");
  125.     new Float:x, Float:y, Float:z, string[128], idx;
  126.     FindSpace(params, idx);
  127.     if(idx == strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /maketextlabel [text] [comment]");
  128.     GetPlayerPos(playerid, x, y, z);
  129.     new orig[128];
  130.     format(orig, 128, params);
  131.     strdel(orig, idx, strlen(params));
  132.     strdel(params, 0, idx);
  133.     format(string, sizeof(string), "Create3DTextLabel(\"%s\", COLOUR, %f, %f, %f, 20.0, 0, 0); //%s", orig, x, y, z, params);
  134.     WriteData(TEXTLABEL_FILE, string);
  135.     format(string, sizeof(string), "Text Label Line Made: %s", string);
  136.     SendClientMessage(playerid, COLOUR, string);
  137.     return 1;
  138. }
  139.  
  140. dcmd_makecp(playerid, params[])
  141. {
  142.     #if defined ADMIN_ONLY
  143.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR, "Admin Required");
  144.     #endif
  145.     new idx, Float:x, Float:y, Float:z;
  146.     GetPlayerPos(playerid, x, y, z);
  147.     FindSpace(params, idx);
  148.     if(idx == strlen(params)) return SendClientMessage(playerid, COLOUR, "Usage: /makecp [comment]");
  149.     strdel(params, 0, idx);
  150.     new string[128];
  151.     format(string, sizeof(string), "SetPlayerCheckpoint(playerid, %f, %f, %f, %f); // %s", x, y, z, DEFAULT_CP_SIZE, params);
  152.     WriteData(CP_FILE, string);
  153.     format(string, sizeof(string), "Checkpoint line made: %s", string);
  154.     SendClientMessage(playerid, COLOUR, string);
  155.     return 1;
  156. }
  157.  
  158. stock WriteData(file[], data[])
  159. {
  160.     new str[256];
  161.     format(str, sizeof(str), "%s\r\n", data);
  162.     new File:f = fopen(file, io_append);
  163.     fwrite(f, str);
  164.     fclose(f);
  165. }
  166.  
  167. stock FindSpace(str[], &idx)
  168. {
  169.     new len = strlen(str);
  170.     for(new i; i < len; i++)
  171.     {
  172.         idx++;
  173.         if(str[i] == ' ')
  174.         {
  175.             return idx;
  176.         }
  177.     }
  178.     return len;
  179. }
  180.  
  181. stock IsValidVehicleModel(vid)
  182. {
  183.     if(vid > 399 && vid < 612)
  184.     {
  185.         return 1;
  186.     }
  187.     return 0;
  188. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement