proking

Fun With SetObjectMaterialText

Jul 9th, 2012
3,989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.94 KB | None | 0 0
  1. #define FILTERSCRIPT
  2.  
  3. #include <a_samp>
  4.  
  5. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  6. new myzobject;
  7.  
  8. #if !defined isnull
  9.     #define isnull(%1) \
  10.                 ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
  11. #endif
  12.  
  13. #define COLOR_RED 0xAA3333AA
  14.  
  15.  
  16. #if defined FILTERSCRIPT
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.     print("\n--------------------------------------");
  21.     print(" Text New SetObjectMaterialText Feature");
  22.     print("--------------------------------------\n");
  23.     return 1;
  24. }
  25.  
  26. public OnFilterScriptExit()
  27. {
  28.     return 1;
  29. }
  30.  
  31. #endif
  32. //------------------------------------------------------------------------------------------------------
  33. public OnPlayerCommandText(playerid, cmdtext[])
  34. {
  35.     dcmd(createtext,10,cmdtext);
  36.     dcmd(editobj,7,cmdtext);
  37.     dcmd(deleteobject,12,cmdtext);
  38.     return 0;
  39. }
  40. //------------------------------------------------------------------------------------------------------
  41. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  42. {
  43.     if(dialogid == 1)
  44.     {
  45.         if(response)
  46.         {
  47.             if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter the ID");
  48.             myzobject = strval(inputtext);
  49.             if(IsValidObject(myzobject)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Object");
  50.             ShowPlayerDialog(playerid,2, DIALOG_STYLE_INPUT, "Enter Text", "Enter Text\nFor Colour use:\n {FF0000}{ FF0000 } -  Red\n{00FF00}{ 00FF00 } -  Green\n{FF9933}{ FF9933 } - Orange\n{00FF33}{ 00FF33 } - Lime Green\n{33FFFF}{ 33FFFF } - Cyan\n{FF66CC}{ FF66CC }Pink\n", "Enter", "Cancel");
  51.  
  52.         }
  53.     }     // Add the rest of your dialogs here
  54.     if(dialogid == 2)
  55.     {
  56.         if(response)
  57.         {
  58.                 new Float:X, Float:Y, Float:Z, Float:A;
  59.                 GetPlayerFacingAngle(playerid, A);
  60.                 GetPlayerPos(playerid, X, Y, Z);
  61.                 if(!strlen(inputtext)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter the some text");
  62.                 new myrobject = CreateObject(myzobject,  X+3, Y, Z+1, 0.0, 0.0, A, 300.0); //create the object
  63.                 SetObjectMaterialText(myrobject, inputtext, 0, OBJECT_MATERIAL_SIZE_256x128,\
  64.                 "Arial", 28, 0, COLOR_RED, 0xFF000000, OBJECT_MATERIAL_TEXT_ALIGN_CENTER);
  65.                 new result[128];
  66.                 format(result,sizeof(result), "The Object is been created with ID %d", myrobject);  //-> The number is 42.
  67.                 SendClientMessage(playerid, COLOR_RED, result);
  68.         }
  69.     }
  70.     return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.).
  71. }
  72.  
  73.  
  74. //------------------------------------------------------------------------------------------------------
  75.  
  76. dcmd_createtext(playerid,params[]){
  77.     #pragma unused params
  78.     ShowPlayerDialog(playerid,1, DIALOG_STYLE_INPUT, "Texture", "Enter Object ID\nDon't know Object id?\nUse Following\n19353", "Enter", "Cancel");
  79.     return 1;
  80. }
  81.  
  82. dcmd_editobj(playerid,params[]){
  83.     if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Object");
  84.     new obje = strval(params);
  85.     EditObject(playerid, obje);
  86.     new result[128];
  87.     format(result,sizeof(result), "SERVER: You now edit the object with ID %d", obje);  //-> The number is 42.
  88.     SendClientMessage(playerid, COLOR_RED, result);
  89.     return 1;
  90. }
  91.  
  92. dcmd_deleteobject(playerid,params[]){
  93.     if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must enter Object ID");
  94.     new obj = strval(params);
  95.     DestroyObject(obj);
  96.     new result[128];
  97.     format(result,sizeof(result), "SERVER: You deleted object the with ID %d", obj);  //-> The number is 42.
  98.     SendClientMessage(playerid, COLOR_RED, result);
  99.     return 1;
  100. }
  101. //------------------------------------------------------------------------------------------------------
  102. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  103. {
  104.     new Float:oldX, Float:oldY, Float:oldZ,
  105.         Float:oldRotX, Float:oldRotY, Float:oldRotZ;
  106.     GetObjectPos(objectid, oldX, oldY, oldZ);
  107.     GetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
  108.     if(!playerobject) // If this is a global object, move it for other players
  109.     {
  110.         if(!IsValidObject(objectid)) return;
  111.         MoveObject(objectid, fX, fY, fZ, 10.0, fRotX, fRotY, fRotZ);
  112.     }
  113.  
  114.     if(response == EDIT_RESPONSE_FINAL)
  115.     {
  116.         // The player clicked on the save icon
  117.         // Do anything here to save the updated object position (and rotation)
  118.     }
  119.  
  120.     if(response == EDIT_RESPONSE_CANCEL)
  121.     {
  122.         //The player cancelled, so put the object back to it's old position
  123.         if(!playerobject) //Object is not a playerobject
  124.         {
  125.             SetObjectPos(objectid, oldX, oldY, oldZ);
  126.             SetObjectRot(objectid, oldRotX, oldRotY, oldRotZ);
  127.         }
  128.         else
  129.         {
  130.             SetPlayerObjectPos(playerid, objectid, oldX, oldY, oldZ);
  131.             SetPlayerObjectRot(playerid, objectid, oldRotX, oldRotY, oldRotZ);
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment