Guest User

Untitled

a guest
Dec 15th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Double-O-Files>
  3. #include <dutils>
  4. #define Dialog_Main 117
  5. #define Dialog_Edit 217
  6.  
  7. enum DLx
  8. {
  9. Txt[30]
  10. };
  11. new DLv[][DLx] =
  12. {
  13. {"Name"},
  14. {"Skype"},
  15. {"City"},
  16. {"Age"},
  17. {"Facebook"},
  18. {"Forum"},
  19. {"Cellphone"}
  20. };
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24. if(!DOF2_FileExists(pFile(playerid)))
  25. {
  26. DOF2_CreateFile(pFile(playerid));
  27. for(new i; i<sizeof(DLv); i++)
  28. {
  29. DOF2_SetString(pFile(playerid), DLv[i][Txt], "Null.");
  30. }
  31. DOF2_SaveFile();
  32. }
  33. for(new i; i<sizeof(DLv); i++)
  34. {
  35. SetPVarString(playerid, DLv[i][Txt], DOF2_GetString(pFile(playerid), DLv[i][Txt]));
  36. }
  37. return 1;
  38. }
  39. public OnPlayerCommandText(playerid, cmdtext[])
  40. {
  41. new cmd[256];
  42. new tmp[256];
  43. new idx;
  44. cmd = strtok(cmdtext, idx);
  45. if(!strcmp(cmd, "/Details", true))
  46. {
  47. tmp = strtok(cmdtext, idx);
  48. new id;
  49. id = strval(tmp);
  50. if(!strlen(tmp) || id == playerid)
  51. {
  52. id = playerid;
  53. }
  54. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player ID");
  55. new DStr[1024];
  56. new title[70];
  57. if(GetPVarInt(playerid, "HaveCar") != -1)
  58. {
  59. new str[256];
  60. GetPVarString(id, "CarModel", str, 256);
  61. if(GetPVarInt(playerid, "SpecialCar") == 1)
  62. {
  63. format(DStr, sizeof(DStr), "{00FFFF}Vehicle: %s [[ID: %d]] [[ {FF00FF} Special Car {00FFFF} ]]",str ,GetPVarInt(id, "HaveCar"));
  64. }
  65. else
  66. {
  67. format(DStr, sizeof(DStr), "{00FFFF}Vehicle: %s [[ID: %d]]", str, GetPVarInt(playerid, "HaveCar"));
  68. }
  69. }
  70. if(GetPVarInt(playerid, "HaveCar") == -1)
  71. {
  72. format(DStr, sizeof(DStr), "");
  73. }
  74. for(new i; i < sizeof(DLv); i++)
  75. {
  76.  
  77. new sxp[100];
  78. GetPVarString(id, DLv[i][Txt], sxp, 100);
  79. format(DStr, sizeof(DStr), "%s\n{FFFFFF} [[ %d ]] {00FF00}%s: {FFFFFF}%s", DStr, i, DLv[i][Txt], sxp);
  80. }
  81. format(title, sizeof(title), "{00FF00}Details Of: {FFFFFF}%s", GetName(id));
  82. if(!strlen(tmp) || id == playerid)
  83. {
  84. ShowPlayerDialog(playerid, Dialog_Main, DIALOG_STYLE_INPUT, title, DStr, "Edit", "Exit");
  85. SetPVarInt(playerid, "PTE", playerid);
  86. }
  87. else
  88. {
  89. ShowPlayerDialog(playerid, Dialog_Main, DIALOG_STYLE_MSGBOX, title, DStr, "OK", "");
  90. SetPVarInt(playerid, "PTE", id);
  91. }
  92. return 1;
  93. }
  94. return 0;
  95. }
  96. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  97. {
  98. if(dialogid == Dialog_Main && response)
  99. {
  100. SetPVarInt(playerid, "DTE", strval(inputtext));
  101. new Str[100];
  102. format(Str, sizeof(Str), "{FFFFFF} [[ %d ]] {00FF00}%s:", strval(inputtext), DLv[strval(inputtext)][Txt]);
  103. ShowPlayerDialog(playerid, Dialog_Edit, DIALOG_STYLE_INPUT, "{FF0000}Details {FFFFFF}Edit Mode", Str, "OK", "Cancel");
  104. }
  105. if(dialogid == Dialog_Edit && response && GetPVarInt(playerid, "PTE") == playerid)
  106. {
  107. SetPVarString(playerid, DLv[GetPVarInt(playerid, "DTE")][Txt], inputtext);
  108. DOF2_SetString(pFile(playerid), DLv[GetPVarInt(playerid, "DTE")][Txt], inputtext);
  109. DOF2_SaveFile();
  110. OnPlayerCommandText(playerid, "/Details");
  111. }
  112. return 0;
  113. }
  114. stock GetName(playerid)
  115. {
  116. new str[24];
  117. GetPlayerName(playerid, str, 24);
  118. return str;
  119. }
  120. stock pFile(playerid)
  121. {
  122. new str[100];
  123. format(str, sizeof(str), "ProDucK/%s.ini", GetName(playerid));
  124. return str;
  125. }
Add Comment
Please, Sign In to add comment