OKStyle

Textures Ingame Editor

Oct 15th, 2011
759
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. // Textures Ingame Editor by O.K.Style
  3. new Text:TDS[1024];
  4. public OnPlayerCommandText(playerid, cmdtext[])
  5. {
  6.     new cmd[256], idx;
  7.     cmd = strtok(cmdtext, idx);
  8.  
  9.     if(strcmp(cmd, "/txd", true) == 0)
  10.     {
  11.         SetPVarInt(playerid, "Editing", 1);
  12.         new tmp[30], tmp1[30];
  13.         tmp = strtok(cmdtext, idx);
  14.         tmp1 = strtok(cmdtext, idx);
  15.         SetPVarInt(playerid, "TDID", strval(tmp));
  16.         SetPVarString(playerid, "TDNAME", tmp1);
  17.         SetPVarFloat(playerid, "X", 1.0);
  18.         SetPVarFloat(playerid, "Y", 1.0);
  19.         SetPVarFloat(playerid, "W", 30.0);
  20.         SetPVarFloat(playerid, "H", 30.0);
  21.         TDS[strval(tmp)] = TextDrawCreate(GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), tmp1);
  22.         TextDrawFont(TDS[strval(tmp)], 4);
  23.         TextDrawLetterSize(TDS[strval(tmp)], GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  24.         TextDrawShowForPlayer(playerid, TDS[strval(tmp)]);
  25.         return 1;
  26.     }
  27.     if(strcmp(cmd, "/mode", true) == 0)
  28.     {
  29.         new tmp[30];
  30.         tmp = strtok(cmdtext, idx);
  31.         SetPVarInt(playerid, "Mode", strval(tmp));
  32.         return 1;
  33.     }
  34.     if(strcmp(cmdtext, "/tdpos", true) == 0)
  35.     {
  36.         new string[128];
  37.         format(string, sizeof(string), "X: %.4f Y: %.4f WIDTH: %.4f HEIGHT: %.4f", GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  38.         SendClientMessage(playerid, 0xFFFFFFFF, string);
  39.         return 1;
  40.     }
  41.     return 0;
  42. }
  43. public OnPlayerUpdate(playerid)
  44. {
  45.     if(GetPVarInt(playerid, "Editing") == 0) return 1;
  46.     new Keys, ud, lr;
  47.     GetPlayerKeys(playerid, Keys, ud, lr);
  48.  
  49.     if(ud > 0)
  50.     {
  51.         new tdid = GetPVarInt(playerid, "TDID");
  52.         TextDrawHideForPlayer(playerid, TDS[tdid]);
  53.         TextDrawDestroy(TDS[tdid]);
  54.  
  55.         new tdname[30];
  56.         GetPVarString(playerid, "TDNAME", tdname, sizeof(tdname));
  57.  
  58.         if(GetPVarInt(playerid, "Mode") == 0) SetPVarFloat(playerid, "Y", GetPVarFloat(playerid, "Y") + 1.0);
  59.         else if(GetPVarInt(playerid, "Mode") == 1) SetPVarFloat(playerid, "H", GetPVarFloat(playerid, "H") + 1.0);
  60.  
  61.         TDS[tdid] = TextDrawCreate(GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), tdname);
  62.         TextDrawFont(TDS[tdid], 4);
  63.         TextDrawTextSize(TDS[tdid], GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  64.         TextDrawShowForPlayer(playerid, TDS[tdid]);
  65.     }
  66.     else if(ud < 0)
  67.     {
  68.         new tdid = GetPVarInt(playerid, "TDID");
  69.         TextDrawHideForPlayer(playerid, TDS[tdid]);
  70.         TextDrawDestroy(TDS[tdid]);
  71.  
  72.         new tdname[30];
  73.         GetPVarString(playerid, "TDNAME", tdname, sizeof(tdname));
  74.  
  75.         if(GetPVarInt(playerid, "Mode") == 0) SetPVarFloat(playerid, "Y", GetPVarFloat(playerid, "Y") - 1.0);
  76.         else if(GetPVarInt(playerid, "Mode") == 1) SetPVarFloat(playerid, "H", GetPVarFloat(playerid, "H") - 1.0);
  77.  
  78.         TDS[tdid] = TextDrawCreate(GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), tdname);
  79.         TextDrawFont(TDS[tdid], 4);
  80.         TextDrawTextSize(TDS[tdid], GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  81.         TextDrawShowForPlayer(playerid, TDS[tdid]);
  82.     }
  83.     else if(lr > 0)
  84.     {
  85.         new tdid = GetPVarInt(playerid, "TDID");
  86.         TextDrawHideForPlayer(playerid, TDS[tdid]);
  87.         TextDrawDestroy(TDS[tdid]);
  88.  
  89.         new tdname[30];
  90.         GetPVarString(playerid, "TDNAME", tdname, sizeof(tdname));
  91.  
  92.         if(GetPVarInt(playerid, "Mode") == 0) SetPVarFloat(playerid, "X", GetPVarFloat(playerid, "X") + 1.0);
  93.         else if(GetPVarInt(playerid, "Mode") == 1) SetPVarFloat(playerid, "W", GetPVarFloat(playerid, "W") + 1.0);
  94.  
  95.         TDS[tdid] = TextDrawCreate(GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), tdname);
  96.         TextDrawFont(TDS[tdid], 4);
  97.         TextDrawTextSize(TDS[tdid], GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  98.         TextDrawShowForPlayer(playerid, TDS[tdid]);
  99.     }
  100.     else if(lr < 0)
  101.     {
  102.         new tdid = GetPVarInt(playerid, "TDID");
  103.         TextDrawHideForPlayer(playerid, TDS[tdid]);
  104.         TextDrawDestroy(TDS[tdid]);
  105.        
  106.         new tdname[30];
  107.         GetPVarString(playerid, "TDNAME", tdname, sizeof(tdname));
  108.        
  109.         if(GetPVarInt(playerid, "Mode") == 0) SetPVarFloat(playerid, "X", GetPVarFloat(playerid, "X") - 1.0);
  110.         else if(GetPVarInt(playerid, "Mode") == 1) SetPVarFloat(playerid, "W", GetPVarFloat(playerid, "W") - 1.0);
  111.  
  112.         TDS[tdid] = TextDrawCreate(GetPVarFloat(playerid, "X"), GetPVarFloat(playerid, "Y"), tdname);
  113.         TextDrawFont(TDS[tdid], 4);
  114.         TextDrawTextSize(TDS[tdid], GetPVarFloat(playerid, "W"), GetPVarFloat(playerid, "H"));
  115.         TextDrawShowForPlayer(playerid, TDS[tdid]);
  116.     }
  117.     return 1;
  118. }
  119. stock strtok(const string[], &index)
  120. {
  121.     new length = strlen(string);
  122.     while ((index < length) && (string[index] <= ' ')) index++;
  123.     new offset = index, result[20];
  124.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  125.     {
  126.         result[index - offset] = string[index];
  127.         index++;
  128.     }
  129.     result[index - offset] = EOS;
  130.     return result;
  131. }
RAW Paste Data