_DucK_196_

Untitled

Oct 4th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 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. SetPVarInt(playerid, "EMode", 1);
  49. if(!strcmp(tmp, "edit", true))
  50. {
  51. SetPVarInt(playerid, "EMode", 1);
  52. }
  53. new id;
  54. id = strval(tmp);
  55. if(!strlen(tmp) || id == playerid)
  56. {
  57. id = playerid;
  58. }
  59. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player ID");
  60. new DStr[1024];
  61. new title[70];
  62. if(GetPVarInt(id, "HaveCar") != -1)
  63. {
  64. new str[256];
  65. GetPVarString(id, "CarModel", str, 256);
  66. if(GetPVarInt(id, "SpecialCar") == 1)
  67. {
  68. format(DStr, sizeof(DStr), "{00FFFF}Vehicle: %s [[ID: %d]] [[ {FF00FF} Special Car {00FFFF} ]]",str ,GetPVarInt(id, "HaveCar"));
  69. }
  70. else
  71. {
  72. format(DStr, sizeof(DStr), "{00FFFF}Vehicle: %s [[ID: %d]]", str, GetPVarInt(id, "HaveCar"));
  73. }
  74. }
  75. if(GetPVarInt(id, "HaveCar") == -1)
  76. {
  77. format(DStr, sizeof(DStr), "{00FFFF}Vehicle: None");
  78. }
  79. for(new i; i < sizeof(DLv); i++)
  80. {
  81. new sxp[100];
  82. GetPVarString(id, DLv[i][Txt], sxp, 100);
  83. format(DStr, sizeof(DStr), "%s\n{FFFFFF} [[ %d ]] {00FF00}%s: {FFFFFF}%s", DStr, i, DLv[i][Txt], sxp);
  84. }
  85. format(title, sizeof(title), "{00FF00}Details Of: {FFFFFF}%s", GetName(id));
  86. if(!strlen(tmp) && GetPVarInt(playerid, "EMode") == 0 || id == playerid && GetPVarInt(playerid, "EMode") == 0)
  87. {
  88. ShowPlayerDialog(playerid, Dialog_Main, DIALOG_STYLE_INPUT, title, DStr, "Edit", "Exit");
  89. SetPVarInt(playerid, "PTE", playerid);
  90. }
  91. else
  92. {
  93. ShowPlayerDialog(playerid, Dialog_Main, DIALOG_STYLE_MSGBOX, title, DStr, "OK", "");
  94. SetPVarInt(playerid, "PTE", id);
  95. }
  96. return 1;
  97. }
  98. return 0;
  99. }
  100. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  101. {
  102. if(dialogid == Dialog_Main && response && GetPVarInt(playerid, "PTE") == playerid && GetPVarInt(playerid, "EMode") == 1)
  103. {
  104. SetPVarInt(playerid, "DTE", strval(inputtext));
  105. new Str[100];
  106. format(Str, sizeof(Str), "{FFFFFF} [[ %d ]] {00FF00}%s:", strval(inputtext), DLv[strval(inputtext)][Txt]);
  107. ShowPlayerDialog(playerid, Dialog_Edit, DIALOG_STYLE_INPUT, "{FF0000}Details {FFFFFF}Edit Mode", Str, "OK", "Cancel");
  108. }
  109. if(dialogid == Dialog_Edit && response && GetPVarInt(playerid, "PTE") == playerid && GetPVarInt(playerid, "EMode") == 1)
  110. {
  111. SetPVarString(playerid, DLv[GetPVarInt(playerid, "DTE")][Txt], inputtext);
  112. DOF2_SetString(pFile(playerid), DLv[GetPVarInt(playerid, "DTE")][Txt], inputtext);
  113. DOF2_SaveFile();
  114. SetPVarInt(playerid, "EMode", 0);
  115. OnPlayerCommandText(playerid, "/Details");
  116. }
  117. return 0;
  118. }
  119. stock GetName(playerid)
  120. {
  121. new str[24];
  122. GetPlayerName(playerid, str, 24);
  123. return str;
  124. }
  125. stock pFile(playerid)
  126. {
  127. new str[100];
  128. format(str, sizeof(str), "ProDucK/%s.ini", GetName(playerid));
  129. return str;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment