Advertisement
Guest User

Untitled

a guest
Aug 20th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.79 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <ocmd>
  4.  
  5. #define MAX_TELES 50
  6. enum TeleInfo{
  7. TelName[30],
  8. Float:telX,
  9. Float:telY,
  10. Float:telZ,
  11. telInt
  12. }
  13. new Teleport[MAX_TELES][TeleInfo];
  14.  
  15. #define DIALOG_TELE 5314
  16.  
  17. public OnFilterScriptInit()
  18. {
  19. print("\n--------------------------------------");
  20. print(" Teleport Filterscript [DINI]");
  21. print("--------------------------------------\n");
  22. for(new i=0;i<MAX_TELES;i++){LoadTele(i);}
  23. return 1;
  24. }
  25. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  26. {
  27. if(dialogid == DIALOG_TELE)
  28. {
  29. if(response == 0)return 1;
  30. SetPlayerVirtualWorld(playerid,0);
  31. SetPlayerPos(playerid,Teleport[listitem][telX],Teleport[listitem][telY],Teleport[listitem][telZ]);
  32. SetPlayerInterior(playerid,Teleport[listitem][telInt]);
  33. }
  34. return 1;
  35. }
  36.  
  37. ocmd:createteleport(playerid, params[])
  38. {
  39. new telpath[30], name[30], Float:X, Float:Y, Float:Z;
  40. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFFFF00FF, "Dieser Befehl ist nur für Admins!");
  41. if(sscanf(params, "s", name))return SendClientMessage(playerid, 0xFFFF00FF, "Benutzung: /createteleport [Name]");
  42. for(new i=0;i<MAX_TELES;i++)
  43. {
  44. format(telpath, sizeof(telpath), "/Teleport/%d.ini",i);
  45. if(!dini_Exists(telpath))
  46. {
  47. GetPlayerPos(playerid, X, Y, Z);
  48. dini_Create(telpath);
  49. dini_Set(telpath, "Name", name);
  50. dini_FloatSet(telpath, "X", X);
  51. dini_FloatSet(telpath, "Y", Y);
  52. dini_FloatSet(telpath, "Z", Z);
  53. dini_IntSet(telpath, "Int", GetPlayerInterior(playerid));
  54. LoadTele(i);
  55. return 1;
  56. }
  57. }
  58. return 1;
  59. }
  60.  
  61. ocmd:teleport(playerid)
  62. {
  63. new teles[MAX_TELES*30+MAX_TELES*2];
  64. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFFFF00FF, "Dieser Befehl ist nur für Admins!");
  65. for(new i=0;i<MAX_TELES;i++)
  66. {
  67. strcat(teles,Teleport[i][TelName]); strcat(teles,"\n");
  68. }
  69. ShowPlayerDialog(playerid, DIALOG_TELE, DIALOG_STYLE_LIST, "Teleporten", teles, "Porten", "Abbrechen");
  70. return 1;
  71. }
  72.  
  73. ocmd:delteleport(playerid, params[])
  74. {
  75. new telname[30], telpath[30];
  76. if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFFFF00FF, "Dieser Befehl ist nur für Admins!");
  77. if(sscanf(params, "s", telname))return SendClientMessage(playerid, 0xFFFF00FF, "Benutzung: /delteleport [Name]");
  78. for(new i=0;i<MAX_TELES;i++)
  79. {
  80. format(telpath, sizeof(telpath), "/Teleport/%d.ini",i);
  81. if(dini_Exists(telpath))
  82. {
  83. // format(telname, sizeof(telname), "%s", dini_Get(telpath, "Name"));
  84. if(!strcmp(dini_Get(telpath, "Name"), telname, true))
  85. {
  86. dini_Remove(telpath);
  87. }
  88. }
  89. }
  90. return 1;
  91. }
  92.  
  93. stock LoadTele(teleid)
  94. {
  95. new telpath[30], telname[30];
  96. format(telpath, sizeof(telpath), "/Teleport/%d.ini",teleid);
  97. if(dini_Exists(telpath))
  98. {
  99. format(telname, sizeof(telname), "%s", dini_Get(telpath, "Name"));
  100. Teleport[teleid][TelName] = telname;
  101. Teleport[teleid][telX] = dini_Float(telpath, "X");
  102. Teleport[teleid][telY] = dini_Float(telpath, "Y");
  103. Teleport[teleid][telZ] = dini_Float(telpath, "Z");
  104. Teleport[teleid][telInt] = dini_Int(telpath, "Int");
  105. }
  106. }
  107.  
  108. stock sscanf(string[], format[], {Float,_}:...)
  109. {
  110. #if defined isnull
  111. if (isnull(string))
  112. #else
  113. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  114. #endif
  115. {
  116. return format[0];
  117. }
  118. #pragma tabsize 4
  119. new
  120. formatPos = 0,
  121. stringPos = 0,
  122. paramPos = 2,
  123. paramCount = numargs(),
  124. delim = ' ';
  125. while (string[stringPos] && string[stringPos] <= ' ')
  126. {
  127. stringPos++;
  128. }
  129. while (paramPos < paramCount && string[stringPos])
  130. {
  131. switch (format[formatPos++])
  132. {
  133. case '\0':
  134. {
  135. return 0;
  136. }
  137. case 'i', 'd':
  138. {
  139. new
  140. neg = 1,
  141. num = 0,
  142. ch = string[stringPos];
  143. if (ch == '-')
  144. {
  145. neg = -1;
  146. ch = string[++stringPos];
  147. }
  148. do
  149. {
  150. stringPos++;
  151. if ('0' <= ch <= '9')
  152. {
  153. num = (num * 10) + (ch - '0');
  154. }
  155. else
  156. {
  157. return -1;
  158. }
  159. }
  160. while ((ch = string[stringPos]) > ' ' && ch != delim);
  161. setarg(paramPos, 0, num * neg);
  162. }
  163. case 'h', 'x':
  164. {
  165. new
  166. num = 0,
  167. ch = string[stringPos];
  168. do
  169. {
  170. stringPos++;
  171. switch (ch)
  172. {
  173. case 'x', 'X':
  174. {
  175. num = 0;
  176. continue;
  177. }
  178. case '0' .. '9':
  179. {
  180. num = (num << 4) | (ch - '0');
  181. }
  182. case 'a' .. 'f':
  183. {
  184. num = (num << 4) | (ch - ('a' - 10));
  185. }
  186. case 'A' .. 'F':
  187. {
  188. num = (num << 4) | (ch - ('A' - 10));
  189. }
  190. default:
  191. {
  192. return -1;
  193. }
  194. }
  195. }
  196. while ((ch = string[stringPos]) > ' ' && ch != delim);
  197. setarg(paramPos, 0, num);
  198. }
  199. case 'c':
  200. {
  201. setarg(paramPos, 0, string[stringPos++]);
  202. }
  203. case 'f':
  204. {
  205.  
  206. new changestr[16], changepos = 0, strpos = stringPos;
  207. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  208. {
  209. changestr[changepos++] = string[strpos++];
  210. }
  211. changestr[changepos] = '\0';
  212. setarg(paramPos,0,_:floatstr(changestr));
  213. }
  214. case 'p':
  215. {
  216. delim = format[formatPos++];
  217. continue;
  218. }
  219. case '\'':
  220. {
  221. new
  222. end = formatPos - 1,
  223. ch;
  224. while ((ch = format[++end]) && ch != '\'') {}
  225. if (!ch)
  226. {
  227. return -1;
  228. }
  229. format[end] = '\0';
  230. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  231. {
  232. if (format[end + 1])
  233. {
  234. return -1;
  235. }
  236. return 0;
  237. }
  238. format[end] = '\'';
  239. stringPos = ch + (end - formatPos);
  240. formatPos = end + 1;
  241. }
  242. case 'u':
  243. {
  244. new
  245. end = stringPos - 1,
  246. id = 0,
  247. bool:num = true,
  248. ch;
  249. while ((ch = string[++end]) && ch != delim)
  250. {
  251. if (num)
  252. {
  253. if ('0' <= ch <= '9')
  254. {
  255. id = (id * 10) + (ch - '0');
  256. }
  257. else
  258. {
  259. num = false;
  260. }
  261. }
  262. }
  263. if (num && IsPlayerConnected(id))
  264. {
  265. setarg(paramPos, 0, id);
  266. }
  267. else
  268. {
  269. #if !defined foreach
  270. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  271. #define __SSCANF_FOREACH__
  272. #endif
  273. string[end] = '\0';
  274. num = false;
  275. new
  276. name[MAX_PLAYER_NAME];
  277. id = end - stringPos;
  278. for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  279. {
  280. GetPlayerName(playerid, name, sizeof (name));
  281. if (!strcmp(name, string[stringPos], true, id))
  282. {
  283. setarg(paramPos, 0, playerid);
  284. num = true;
  285. break;
  286. }
  287. }
  288. if (!num)
  289. {
  290. setarg(paramPos, 0, INVALID_PLAYER_ID);
  291. }
  292. string[end] = ch;
  293. #if defined __SSCANF_FOREACH__
  294. #undef foreach
  295. #undef __SSCANF_FOREACH__
  296. #endif
  297. }
  298. stringPos = end;
  299. }
  300. case 's', 'z':
  301. {
  302. new
  303. i = 0,
  304. ch;
  305. if (format[formatPos])
  306. {
  307. while ((ch = string[stringPos++]) && ch != delim)
  308. {
  309. setarg(paramPos, i++, ch);
  310. }
  311. if (!i)
  312. {
  313. return -1;
  314. }
  315. }
  316. else
  317. {
  318. while ((ch = string[stringPos++]))
  319. {
  320. setarg(paramPos, i++, ch);
  321. }
  322. }
  323. stringPos--;
  324. setarg(paramPos, i, '\0');
  325. }
  326. default:
  327. {
  328. continue;
  329. }
  330. }
  331. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  332. {
  333. stringPos++;
  334. }
  335. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  336. {
  337. stringPos++;
  338. }
  339. paramPos++;
  340. }
  341. do
  342. {
  343. if ((delim = format[formatPos++]) > ' ')
  344. {
  345. if (delim == '\'')
  346. {
  347. while ((delim = format[formatPos++]) && delim != '\'') {}
  348. }
  349. else if (delim != 'z')
  350. {
  351. return delim;
  352. }
  353. }
  354. }
  355. while (delim > ' ');
  356. return 0;
  357. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement