Alejandro_Kardona

DYNAMIC SAMP ATTACHOBJECTTOVEHICLE | SILVERGAMINGYT

Nov 21st, 2016
2,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 23.32 KB | None | 0 0
  1. /*
  2. ////////////////////////////////////////////////////////////////////////////////
  3.  
  4. CREADOR ALEJANDRO KARDONA
  5.  
  6. - Commands:
  7.  
  8. Type /Editar to edit a model and create a edition id.
  9. Type /Edicion to switch between editions.
  10. Type /X /Y or /Z to adjust the linear offsets.
  11. Type /RX /RY or /RZ to adjust the rotational offsets.
  12. Type /Freeze and /Unfreeze to freeze and unfreeze yourself.
  13. Type /Parar to stop an edition id and destroy the object.
  14. Type /Guardarobjeto to save the object offsets to the file "editions.pwn".
  15. Type /Ediciones to switch between editions seeing the objects with a indication arrow.
  16. Type /Materiales to see a list of materials available.
  17. Type /Material [model/txd name/texture name] to set a specific material. The material only will be set when you choise the trhee params!
  18.  
  19.  
  20. ////////////////////////////////////////////////////////////////////////////////////
  21. */
  22.  
  23. #include "a_samp"
  24.  
  25. #define CBLUE                ( 0x4E76B1FF )
  26. #define CRED                 ( 0xF40B74FF )
  27. #define MAX_OBJECTS_PER_EDIT (     10      )
  28.  
  29. forward GetKeys(playerid);
  30.  
  31. enum playerSets
  32. {
  33.     Float:OffSetX[MAX_OBJECTS_PER_EDIT],
  34.     Float:OffSetY[MAX_OBJECTS_PER_EDIT],
  35.     Float:OffSetZ[MAX_OBJECTS_PER_EDIT],
  36.     Float:OffSetRX[MAX_OBJECTS_PER_EDIT],
  37.     Float:OffSetRY[MAX_OBJECTS_PER_EDIT],
  38.     Float:OffSetRZ[MAX_OBJECTS_PER_EDIT],
  39.     ObjectID[MAX_OBJECTS_PER_EDIT],
  40.     Arrow,
  41.     EditionID,
  42.     ViewingID,
  43.     EditStatus[MAX_OBJECTS_PER_EDIT],
  44.     LeftRight,
  45.     VehicleID,
  46.     ObjectModel[MAX_OBJECTS_PER_EDIT],
  47.     TimerID
  48. }
  49.  
  50. new PlayerData[MAX_PLAYERS][playerSets];
  51.  
  52. const FloatX =  1;
  53. const FloatY =  2;
  54. const FloatZ =  3;
  55. const FloatRX = 4;
  56. const FloatRY = 5;
  57. const FloatRZ = 6;
  58.  
  59. public OnPlayerConnect(playerid)
  60. {
  61.     PlayerData[playerid][TimerID] = -1;
  62.     PlayerData[playerid][Arrow] = -1;
  63.     for(new i = 0; i < MAX_OBJECTS_PER_EDIT; i++) PlayerData[playerid][ObjectID][i] = -1;
  64.     return 1;
  65. }
  66.  
  67. public OnPlayerCommandText(playerid, cmdtext[])
  68. {
  69.     new cmd[128], tmp[128], idx;
  70.     cmd = strtok(cmdtext, idx);
  71.    
  72.     if(!strcmp("/editar", cmd, true))
  73.     {
  74.         tmp = strtok(cmdtext, idx);
  75.        
  76.         if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) No estas en un vehiculo. -|");
  77.  
  78.         if(!strlen(tmp)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Usa: /editar [objectid] -|");
  79.  
  80.         new i, bool:OtherObject;
  81.        
  82.         for(i = 0; i < MAX_OBJECTS_PER_EDIT; i++)
  83.         {
  84.             if(PlayerData[playerid][ObjectID][i] == -1) break;
  85.             OtherObject = true;
  86.             if(i == (MAX_OBJECTS_PER_EDIT - 1)) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Está editando el máximo de objetos definidos. -|");
  87.         }
  88.        
  89.         new Obj = CreateObject(strval(tmp), 0.0, 0.0, -10.0, 0.0, 0.0, 0.0),
  90.         vId = GetPlayerVehicleID(playerid), str[148];
  91.        
  92.         if(OtherObject)
  93.         {
  94.             PlayerData[playerid][ObjectModel][i] = strval(tmp);
  95.             PlayerData[playerid][EditionID] = i;
  96.             PlayerData[playerid][ObjectID][i] = Obj;
  97.             format(str, sizeof str, "|-  Editing the object {F40B74}%d{4E76B1}, edition id {F40B74}%d{4E76B1}. Use KEY_LEFT, KEY_RIGHT and KEY_FIRE to adjust the offset's -|", strval(tmp), i);
  98.             SendClientMessage(playerid, CBLUE, str);
  99.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
  100.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
  101.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/EDITION{4E76B1} to switch between objects editions -|");
  102.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
  103.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/STOP{4E76B1} to stop some edition. -|");
  104.             SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
  105.             ShowPlayerDialog(playerid, 0, DIALOG_STYLE_MSGBOX, "Information", "Do you wish create a object in the same position of the last?", "Yes", "No");
  106.             return true;
  107.         }
  108.         PlayerData[playerid][VehicleID] = vId;
  109.         PlayerData[playerid][ObjectModel][i] = strval(tmp);
  110.         PlayerData[playerid][EditionID] = i;
  111.         PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]]  = 0.0;
  112.         PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]]  = 0.0;
  113.         PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]]  = 0.0;
  114.         PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = 0.0;
  115.         PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = 0.0;
  116.         PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = 0.0;
  117.         PlayerData[playerid][ObjectID][i] = Obj;
  118.         PlayerData[playerid][TimerID] = SetTimerEx("GetKeys", 30, true, "i", playerid);
  119.         format(str, sizeof str, "|-  Editing the object {F40B74}%d{4E76B1}, edition id {F40B74}%d{4E76B1}. Use KEY_LEFT, KEY_RIGHT and KEY_FIRE to adjust the offset's -|", strval(tmp), i);
  120.         SendClientMessage(playerid, CBLUE, str);
  121.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/X /Y or /Z{4E76B1} to adjust the linear offsets -|");
  122.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/RX /RY or /RZ{4E76B1} to adjust the rotational offsets -|");
  123.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/EDITION and /EDITIONS{4E76B1} to switch between objects editions -|");
  124.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/FREEZE{4E76B1} and {F40B74}/UNFREEZE{4E76B1} to freeze and unfreeze yourself -|");
  125.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/STOP{4E76B1} to stop some edition. -|");
  126.         SendClientMessage(playerid, CBLUE, "|- Usa {F40B74}/SAVEOBJ{4E76B1} to save the object to file \"editions.pwn\". -|");
  127.         return true;
  128.     }
  129.     if(!strcmp("/edicion", cmd, true))
  130.     {
  131.         tmp = strtok(cmdtext, idx);
  132.  
  133.         if(!strlen(tmp) || strval(tmp) > MAX_OBJECTS_PER_EDIT || strval(tmp) < 0) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Use: /edicion [valid edition id] -|");
  134.  
  135.         if(!IsValidObject(PlayerData[playerid][ObjectID][strval(tmp)])) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) No está editando un archivo adjunto objeto en esta edición de id. -|");
  136.  
  137.         PlayerData[playerid][EditionID] = strval(tmp);
  138.         format(tmp, sizeof tmp, "|- Edition changed for id [%d]. -|", strval(tmp));
  139.         return SendClientMessage(playerid, CBLUE, tmp);
  140.     }
  141.     if(!strcmp("/ediciones", cmd, true))
  142.     {
  143.         for(new i = 0; i < MAX_OBJECTS_PER_EDIT; i++)
  144.         {
  145.             if(IsValidObject(PlayerData[playerid][ObjectID][i]))
  146.             {
  147.                 new str[128];
  148.                
  149.                 PlayerData[playerid][Arrow] = CreateObject(19133, 0.0, 0.0, -10.0, 0.0, 0.0, 0.0);
  150.                 AttachObjectToVehicle(PlayerData[playerid][Arrow], PlayerData[playerid][VehicleID], PlayerData[playerid][OffSetX][i], PlayerData[playerid][OffSetY][i], PlayerData[playerid][OffSetZ][i] + 1.3, 0.0, 0.0, 0.0);
  151.                 format(str, sizeof str, "{0090ff}Edition id: {7ce01a}[%d]\n\n{0090ff}Object Model: {7ce01a}%d", i, PlayerData[playerid][ObjectModel][i]);
  152.                 PlayerData[playerid][EditionID] = i;
  153.                 PlayerData[playerid][ViewingID] = i;
  154.                 ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Editions Viewer", str, "Seleccionar", "Avanzado");
  155.                 return true;
  156.             }
  157.         }
  158.         return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) No tienes ediciones para ver.");
  159.     }
  160.     if(!strcmp("/parar", cmd, true))
  161.     {
  162.         tmp = strtok(cmdtext, idx);
  163.  
  164.         if(!strlen(tmp) || strval(tmp) > MAX_OBJECTS_PER_EDIT || strval(tmp) < 0) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) Use: /stop [valid edition id] -|");
  165.  
  166.         if(!IsValidObject(PlayerData[playerid][ObjectID][strval(tmp)])) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment in this edition id. -|");
  167.        
  168.         DestroyObject(PlayerData[playerid][ObjectID][strval(tmp)]);
  169.         PlayerData[playerid][ObjectID][strval(tmp)] = -1;
  170.  
  171.         new j = -1;
  172.        
  173.         for(new i = (MAX_OBJECTS_PER_EDIT - 1); i >= 0; i--)
  174.         {
  175.             if(IsValidObject(PlayerData[playerid][ObjectID][i]))
  176.             {
  177.                 PlayerData[playerid][EditionID] = i;
  178.                 j = i;
  179.                 break;
  180.             }
  181.         }
  182.         if(j != -1) format(tmp, sizeof tmp, "|- Edition [%d] stoped, now you're editing the edition: [%d]. -|", strval(tmp), j);
  183.         else
  184.         {
  185.             format(tmp, sizeof tmp, "|- Edition [%d] stoped, now you do not have no one edition. -|", strval(tmp));
  186.             KillTimer(PlayerData[playerid][TimerID]);
  187.             PlayerData[playerid][TimerID] = -1;
  188.             PlayerData[playerid][EditionID] = -1;
  189.         }
  190.         return SendClientMessage(playerid, CBLUE, tmp);
  191.     }
  192.     if(!strcmp("/pause", cmd, true))
  193.     {
  194.         if(PlayerData[playerid][TimerID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  195.        
  196.         KillTimer(PlayerData[playerid][TimerID]);
  197.         PlayerData[playerid][TimerID] = -1;
  198.         SendClientMessage(playerid, CBLUE, "Edition paused.");
  199.         TogglePlayerControllable(playerid, true);
  200.         return 1;
  201.     }
  202.     if(!strcmp("/back", cmd, true))
  203.     {
  204.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  205.        
  206.         else if(PlayerData[playerid][TimerID] != -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You was not paused the edition. -|");
  207.        
  208.         PlayerData[playerid][TimerID] = SetTimerEx("GetKeys", 30, true, "i", playerid);
  209.         SendClientMessage(playerid, CBLUE, "Back to editing");
  210.         return 1;
  211.     }
  212.     if(!strcmp("/guardarobjeto", cmd, true))
  213.     {      
  214.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  215.  
  216.         new File: file = fopen("editions.pwn", io_append);
  217.  
  218.         new str[256];
  219.        
  220.         for(new i = 0; i < MAX_OBJECTS_PER_EDIT; i++)
  221.         {
  222.             if(IsValidObject(PlayerData[playerid][ObjectID][i]))
  223.             {
  224.                 format
  225.                 (
  226.                     str,
  227.                     256,
  228.                     "AttachObjectToVehicle(objectid, vehicleid, %f, %f, %f, %f, %f, %f); //Object Model: %d | %s\r\n",
  229.                     PlayerData[playerid][OffSetX][i],
  230.                     PlayerData[playerid][OffSetY][i],
  231.                     PlayerData[playerid][OffSetZ][i],
  232.                     PlayerData[playerid][OffSetRX][i],
  233.                     PlayerData[playerid][OffSetRY][i],
  234.                     PlayerData[playerid][OffSetRZ][i],
  235.                     PlayerData[playerid][ObjectModel][i],
  236.                     cmdtext[8]
  237.                 );
  238.                 fwrite(file, str);
  239.             }
  240.         }
  241.         fclose(file);
  242.         return SendClientMessage(playerid, CBLUE, "|- Edition saved to file \"editions.pwn\". -|");
  243.     }  
  244.     if(!strcmp("/x", cmd, true))
  245.     {
  246.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  247.        
  248.         PlayerData[playerid][EditStatus] = FloatX;
  249.         return SendClientMessage(playerid, CBLUE, "|- Editing Float X. -|");
  250.     }
  251.     if(!strcmp("/y", cmd, true))
  252.     {
  253.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  254.        
  255.         PlayerData[playerid][EditStatus] = FloatY;
  256.         return SendClientMessage(playerid, CBLUE, "|- Editing Float Y. -|");
  257.     }
  258.     if(!strcmp("/z", cmd, true))
  259.     {
  260.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  261.        
  262.         PlayerData[playerid][EditStatus] = FloatZ;
  263.         return SendClientMessage(playerid, CBLUE, "|- Editing Float Z. -|");
  264.     }
  265.     if(!strcmp("/rx", cmd, true))
  266.     {
  267.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  268.        
  269.         PlayerData[playerid][EditStatus] = FloatRX;
  270.         return SendClientMessage(playerid, CBLUE, "|- Editing Float RX. -|");
  271.     }
  272.     if(!strcmp("/ry", cmd, true))
  273.     {
  274.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  275.        
  276.         PlayerData[playerid][EditStatus] = FloatRY;
  277.         return SendClientMessage(playerid, CBLUE, "|- Editing Float RY. -|");
  278.     }
  279.     if(!strcmp("/rz", cmd, true))
  280.     {
  281.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  282.        
  283.         PlayerData[playerid][EditStatus] = FloatRZ;
  284.         return SendClientMessage(playerid, CBLUE, "|- Editing Float RZ. -|");
  285.     }
  286.    
  287.     if(!strcmp("/freeze", cmd, true))
  288.     {
  289.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  290.        
  291.         TogglePlayerControllable(playerid, false);
  292.         SendClientMessage(playerid, CBLUE, "|- You're freezed, use /unfreeze to unfreeze yourself. -|");
  293.         return 1;
  294.     }
  295.     if(!strcmp("/unfreeze", cmd, true))
  296.     {
  297.         if(PlayerData[playerid][EditionID] == -1) return SendClientMessage(playerid, CBLUE, "|- ((ERROR)) You're not editing an object attachment. -|");
  298.        
  299.         TogglePlayerControllable(playerid, true);
  300.         SendClientMessage(playerid, CBLUE, "|- You're unfreezed. -|");
  301.         return 1;
  302.     }
  303.     return 0;
  304. }
  305.  
  306. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  307. {
  308.     switch(dialogid)
  309.     {
  310.         case 0:
  311.         {
  312.             if(response)
  313.             {
  314.                 PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID] - 1];
  315.                 PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID] - 1];
  316.                 PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID] - 1];
  317.                 PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID] - 1];
  318.                 PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID] - 1];
  319.                 PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID] - 1];
  320.                 return 1;
  321.             }
  322.         }
  323.         case 1:
  324.         {
  325.             if(response)
  326.             {
  327.                 new str[64];
  328.                 format(str, sizeof str, "|- Edition changed for id [%d]. -|", PlayerData[playerid][EditionID]);
  329.                 SendClientMessage(playerid, CBLUE, str);
  330.                 DestroyObject(PlayerData[playerid][Arrow]);
  331.                 PlayerData[playerid][Arrow] = -1;
  332.                 return 1;
  333.             }
  334.             else
  335.             {
  336.                 new str[128], HighID;
  337.                 for(new i = 0; i < MAX_OBJECTS_PER_EDIT; i++) if(IsValidObject(PlayerData[playerid][ObjectID][i])) HighID++;
  338.  
  339.                 new NextView = GetAValidObject(playerid, PlayerData[playerid][ViewingID]);
  340.                    
  341.                 if(NextView != -1)
  342.                 {
  343.                     PlayerData[playerid][EditionID] = NextView;
  344.                     PlayerData[playerid][ViewingID] = GetAValidObject(playerid, NextView + 1);
  345.                     if(GetAValidObject(playerid, NextView + 1) == -1) PlayerData[playerid][ViewingID] = 0;
  346.                     AttachObjectToVehicle(PlayerData[playerid][Arrow], PlayerData[playerid][VehicleID], PlayerData[playerid][OffSetX][NextView], PlayerData[playerid][OffSetY][NextView], PlayerData[playerid][OffSetZ][NextView] + 1.3, 0.0, 0.0, 0.0);
  347.                     format(str, sizeof str, "{0090ff}Edition id: {7ce01a}[%d]\n\n{0090ff}Object Model: {7ce01a}%d", NextView, PlayerData[playerid][ObjectModel][NextView]);
  348.                     ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Editions Viewer", str, "Select", "Advance");
  349.                     return 1;
  350.                 }
  351.             }
  352.         }
  353.     }
  354.     return 1;
  355. }
  356.  
  357. public OnFilterScriptInit()
  358. {
  359.     for(new i = 0, j = GetMaxPlayers(); i < j; ++i)
  360.     {
  361.         PlayerData[i][TimerID] = -1;
  362.         PlayerData[i][Arrow] = -1;
  363.         for(new k = 0; k < MAX_OBJECTS_PER_EDIT; k++) PlayerData[i][ObjectID][k] =  -1;
  364.     }
  365.     return true;
  366. }
  367.  
  368. public OnFilterScriptExit()
  369. {
  370.     for(new i = 0, j = GetMaxPlayers(); i < j; ++i)
  371.     {
  372.         for(new k = 0; k < MAX_OBJECTS_PER_EDIT; k++) DestroyObject(PlayerData[i][ObjectID][k]);
  373.         if(PlayerData[i][Arrow] != -1) DestroyObject(PlayerData[i][Arrow]);
  374.     }
  375.     return 1;
  376. }
  377.  
  378. public GetKeys(playerid)
  379. {
  380.     new Keys, ud, gametext[36], Float: toAdd;
  381.    
  382.     GetPlayerKeys(playerid,Keys,ud,PlayerData[playerid][LeftRight]);
  383.     switch(Keys)
  384.     {
  385.         case KEY_FIRE:   toAdd = 0.000500;     
  386.         default:         toAdd = 0.005000;
  387.     }  
  388.     if(PlayerData[playerid][LeftRight] == 128)
  389.     {
  390.         switch(PlayerData[playerid][EditStatus])
  391.         {
  392.             case FloatX:
  393.             {
  394.                 PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]], toAdd);
  395.                 format(gametext, 36, "offsetx: ~w~%f", PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]]);
  396.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  397.             }
  398.             case FloatY:
  399.             {
  400.                 PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]], toAdd);
  401.                 format(gametext, 36, "offsety: ~w~%f", PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]]);
  402.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  403.             }
  404.             case FloatZ:
  405.             {
  406.                 PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]], toAdd);
  407.                 format(gametext, 36, "offsetz: ~w~%f", PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]]);
  408.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  409.             }
  410.             case FloatRX:
  411.             {
  412.                 if(Keys == 0) PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  413.                 else PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRX], floatadd(toAdd,0.100000));
  414.                 format(gametext, 36, "offsetrx: ~w~%f", PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]]);
  415.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  416.             }
  417.             case FloatRY:
  418.             {
  419.                 if(Keys == 0) PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  420.                 else PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]], floatadd(toAdd,0.100000));
  421.                 format(gametext, 36, "offsetry: ~w~%f", PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]]);
  422.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  423.             }
  424.             case FloatRZ:
  425.             {
  426.                 if(Keys == 0) PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  427.                 else PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = floatadd(PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]], floatadd(toAdd,0.100000));
  428.                 format(gametext, 36, "offsetrz: ~w~%f", PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]]);
  429.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  430.             }
  431.         }
  432.     }
  433.     else if(PlayerData[playerid][LeftRight] == -128)
  434.     {
  435.         switch(PlayerData[playerid][EditStatus])
  436.         {
  437.             case FloatX:
  438.             {
  439.                 PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]], toAdd);
  440.                 format(gametext, 36, "offsetx: ~w~%f", PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]]);
  441.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  442.             }
  443.             case FloatY:
  444.             {
  445.                 PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]], toAdd);
  446.                 format(gametext, 36, "offsety: ~w~%f", PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]]);
  447.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  448.             }
  449.             case FloatZ:
  450.             {
  451.                 PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]], toAdd);
  452.                 format(gametext, 36, "offsetz: ~w~%f", PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]]);
  453.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  454.             }
  455.             case FloatRX:
  456.             {
  457.                 if(Keys == 0) PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  458.                 else PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]], floatadd(toAdd,0.100000));
  459.                 format(gametext, 36, "offsetrx: ~w~%f", PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]]);
  460.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  461.             }
  462.             case FloatRY:
  463.             {
  464.                 if(Keys == 0) PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  465.                 else PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]], floatadd(toAdd,0.100000));
  466.                 format(gametext, 36, "offsetry: ~w~%f", PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]]);
  467.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  468.             }
  469.             case FloatRZ:
  470.             {
  471.                 if(Keys == 0) PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]], floatadd(toAdd, 1.000000));
  472.                 else PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]] = floatsub(PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]], floatadd(toAdd,0.100000));
  473.                 format(gametext, 36, "offsetrz: ~w~%f", PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]]);
  474.                 GameTextForPlayer(playerid, gametext, 1000, 3);
  475.             }
  476.         }
  477.     }
  478.     AttachObjectToVehicle(PlayerData[playerid][ObjectID][PlayerData[playerid][EditionID]], PlayerData[playerid][VehicleID], PlayerData[playerid][OffSetX][PlayerData[playerid][EditionID]], PlayerData[playerid][OffSetY][PlayerData[playerid][EditionID]], PlayerData[playerid][OffSetZ][PlayerData[playerid][EditionID]], PlayerData[playerid][OffSetRX][PlayerData[playerid][EditionID]], PlayerData[playerid][OffSetRY][PlayerData[playerid][EditionID]], PlayerData[playerid][OffSetRZ][PlayerData[playerid][EditionID]]);
  479.     return true;
  480. }
  481.  
  482.  
  483. strtok(const string[], &index)
  484. {
  485.     new length = strlen(string);
  486.     while ((index < length) && (string[index] <= ' '))
  487.     {
  488.         index++;
  489.     }
  490.  
  491.     new offset = index;
  492.     new result[20];
  493.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  494.     {
  495.         result[index - offset] = string[index];
  496.         index++;
  497.     }
  498.     result[index - offset] = EOS;
  499.     return result;
  500. }
  501.  
  502. GetAValidObject(playerid, index)
  503. {
  504.     if(index > MAX_OBJECTS_PER_EDIT) return -1;
  505.     for(new i = index; i < MAX_OBJECTS_PER_EDIT; i++) if(IsValidObject(PlayerData[playerid][ObjectID][i])) return i;
  506.     return -1;
  507. }
Advertisement
Add Comment
Please, Sign In to add comment