Advertisement
Guest User

Partner's Advanced Debug.

a guest
Mar 4th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.98 KB | None | 0 0
  1. #include <a_samp>
  2. #include <filemanager>
  3.  
  4. /*** Colors ***/
  5. #define Green 0x33FF33FF
  6. #define Green_dark 0x33BB33FF
  7. #define White 0xFFFFFFFF
  8. #define Gray 0x999999FF
  9.  
  10. #define PwnDir "PowerPawn"
  11. #define PwnFile "PowerPawn/positions.pwn"
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     if(!dir_exists(PwnDir))
  16.     {
  17.         ConsoleWrite("Folder \"PowerPawn\" created");
  18.         dir_create(PwnDir);
  19.     }
  20.     if(!file_exists(PwnFile))
  21.     {
  22.         ConsoleWrite("File\"PowerPawn/positions.pwn\" created");
  23.         file_create(PwnFile);
  24.     }
  25.     return 1;
  26. }
  27.  
  28. public OnPlayerCommandText(playerid, cmdtext[])
  29. {
  30.     new cmd[256], idx;
  31.     cmd = strtok(cmdtext, idx);
  32.     if(strcmp(cmd, "/static", true) == 0)
  33.     {
  34.         if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, White, "You're not admin!");
  35.         new func[256];
  36.         func = strtok(cmdtext, idx);
  37.         if(!strlen(func))
  38.         {
  39.             SendClientMessage(playerid, White, "Usage: /static [function]");
  40.             SendClientMessage(playerid, Gray, "Functions");
  41.             SendClientMessage(playerid, Gray, "Teleport, Class, Vehicle, Object, 3DText, Pickup, Checkpoint");
  42.             return 1;
  43.         }
  44.         if(strcmp(func, "Teleport", true) == 0)
  45.         {
  46.             new comm[256];
  47.             comm = strtok(cmdtext, idx);
  48.             if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static teleport [comment]");
  49.             new str[200];
  50.             new Float:X, Float:Y, Float:Z, Float:A;
  51.             GetPlayerPos(playerid, X, Y, Z);
  52.             GetPlayerFacingAngle(playerid, A);
  53.             format(str, sizeof(str), "SetPlayerPos(playerid, %f, %f, %f), SetPlayerFacingAngle(playerid, %f);", X, Y, Z, A);
  54.             Save(str, comm);
  55.             SendClientMessage(playerid, Green_dark, "Teleport added to file.");
  56.             return 1;
  57.         }
  58.         if(strcmp(func, "Class", true) == 0)
  59.         {
  60.             new comm[256];
  61.             comm = strtok(cmdtext, idx);
  62.             if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static class [comment]");
  63.             new str[200];
  64.             new Float:X, Float:Y, Float:Z, Float:A;
  65.             GetPlayerPos(playerid, X, Y, Z);
  66.             GetPlayerFacingAngle(playerid, A);
  67.             format(str, sizeof(str), "AddPlayerClass(%i, %f, %f, %f, %f, 0, 0, 0, 0, 0, 0);", GetPlayerSkin(playerid), X, Y, Z, A);
  68.             Save(str, comm);
  69.             SendClientMessage(playerid, Green_dark, "Class added to file.");
  70.             return 1;
  71.         }
  72.         if(strcmp(func, "Vehicle", true) == 0)
  73.         {
  74.             new c1[256], c2[256], comm[256];
  75.             c1 = strtok(cmdtext, idx);
  76.             c2 = strtok(cmdtext, idx);
  77.             comm = strtok(cmdtext, idx);
  78.             if(!IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, White, "You need to be in vehicle!");
  79.             if(!strlen(c1) || !strlen(c2) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static vehicle [color1] [color2] [comment]");
  80.             new str[200];
  81.             new car = GetPlayerVehicleID(playerid);
  82.             new Float:X, Float:Y, Float:Z, Float:A;
  83.             GetVehiclePos(car, X, Y, Z);
  84.             GetVehicleZAngle(car, A);
  85.             format(str, sizeof(str), "AddStaticVehicle(%i, %f, %f, %f, %f, %i, %i);", GetVehicleModel(car), X, Y, Z, A, strval(c1), strval(c2));
  86.             Save(str, comm);
  87.             SendClientMessage(playerid, Green_dark, "Vehicle added to file.");
  88.             return 1;
  89.         }
  90.         if(strcmp(func, "Object", true) == 0)
  91.         {
  92.             new ob[256], comm[256];
  93.             ob = strtok(cmdtext, idx);
  94.             comm = strtok(cmdtext, idx);
  95.             if(!strlen(ob) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static object [objectmodel] [comment]");
  96.             new str[200];
  97.             new Float:X, Float:Y, Float:Z;
  98.             GetPlayerPos(playerid, X, Y, Z);
  99.             format(str, sizeof(str), "CreateObject(%i, %f, %f, %f, 0, 0, 0);", strval(ob), X, Y, Z);
  100.             Save(str, comm);
  101.             SendClientMessage(playerid, Green_dark, "Object added to file.");
  102.             return 1;
  103.         }
  104.         if(strcmp(func, "3DText", true) == 0)
  105.         {
  106.             new comm[256];
  107.             comm = strtok(cmdtext, idx);
  108.             if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static 3dtext [comment]");
  109.             new str[200];
  110.             new Float:X, Float:Y, Float:Z;
  111.             GetPlayerPos(playerid, X, Y, Z);
  112.             format(str, sizeof(str), "Create3DTextLabel(\">>TEXT<<\", 0xFFFFFFFF, %f, %f, %f, 100.0, 0, 0);", X, Y, Z);
  113.             Save(str, comm);
  114.             SendClientMessage(playerid, Green_dark, "3D Text added to file.");
  115.             return 1;
  116.         }
  117.         if(strcmp(func, "pickup", true) == 0)
  118.         {
  119.             new pid[256], pty[256], comm[256];
  120.             pid = strtok(cmdtext, idx);
  121.             pty = strtok(cmdtext, idx);
  122.             comm = strtok(cmdtext, idx);
  123.             if(!strlen(pid) || !strlen(pty) || !strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static pickup [pickupmodel] [pickuptype] [comment]");
  124.             new str[200];
  125.             new Float:X, Float:Y, Float:Z;
  126.             GetPlayerPos(playerid, X, Y, Z);
  127.             format(str, sizeof(str), "CreatePickup(%i, %i, %f, %f, %f, 0);", strval(pid), strval(pty), X, Y, Z);
  128.             Save(str, comm);
  129.             SendClientMessage(playerid, Green_dark, "Pickup added to file.");
  130.             return 1;
  131.         }
  132.         if(strcmp(func, "Checkpoint", true) == 0)
  133.         {
  134.             new comm[256];
  135.             comm = strtok(cmdtext, idx);
  136.             if(!strlen(comm)) return SendClientMessage(playerid, White, "Usage: /static checkpoint [comment]");
  137.             new str[200];
  138.             new Float:X, Float:Y, Float:Z;
  139.             GetPlayerPos(playerid, X, Y, Z);
  140.             format(str, sizeof(str), "SetPlayerCheckpoint(playerid, %f, %f, %f, 5);", X, Y, Z);
  141.             Save(str, comm);
  142.             SendClientMessage(playerid, Green_dark, "Checkpoint added to file.");
  143.             return 1;
  144.         }
  145.         return SendClientMessage(playerid, White, "Wrong function!");
  146.     }
  147.     return 0;
  148. }
  149.  
  150. ConsoleWrite(const string[])
  151. {
  152.     new str[128];
  153.     format(str, sizeof(str), "[PowerPawn::Partner] %s", string);
  154.     print(str);
  155.     return 1;
  156. }
  157.  
  158. Save(const string[], const comment[])
  159. {
  160.     new str[200];
  161.     format(str, sizeof(str), "%s // %s\n", string, comment);
  162.     file_write(PwnFile, str);
  163.     return 1;
  164. }
  165.  
  166. strtok(const string[], &index)
  167. {
  168.     new length = strlen(string);
  169.     while ((index < length) && (string[index] <= ' '))
  170.     {
  171.         index++;
  172.     }
  173.  
  174.     new offset = index;
  175.     new result[20];
  176.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  177.     {
  178.         result[index - offset] = string[index];
  179.         index++;
  180.     }
  181.     result[index - offset] = EOS;
  182.     return result;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement