Advertisement
Guest User

Dynamic House by Music4You V1

a guest
Aug 10th, 2013
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.26 KB | None | 0 0
  1. /*
  2. Haussystem by Items4Landwirt aka Music4You
  3.  
  4. - Es ist verboten meinen Namen aus dem Skript zu löschen!
  5. - Es ist verboten Dieses Skript nocheinmal zu veröffentlichen
  6. - Es ist verboten Dieses Skript als eigenes auszugeben.
  7.  
  8. Nun noch ein Paar YT Kanäle, von guten Freunden
  9. Music4You http://www.youtube.com/user/Music4You43
  10. Items4Sacred http://www.youtube.com/user/items4sacred
  11. Metalletsplay666 http://www.youtube.com/user/MetalLetsPlay666
  12.  
  13. */
  14. #define FILTERSCRIPT
  15. #define DEBUG
  16.  
  17. ////=============== Includes ===============
  18. #include <a_samp>
  19. #include <ocmd>
  20. #include <streamer>
  21. //=============== Defines ===============
  22. #define rot 0xFF0A00FF
  23. #define gruen 0x4BB400FF
  24. #define orange 0xFF9600FF
  25.  
  26. #define SCM SendClientMessage
  27.  
  28. #define MAX_HAUS 100
  29.  
  30. ////=============== News ===============
  31. new DB:Database, house, houseint[MAX_PLAYERS],inhouse[MAX_PLAYERS];
  32.  
  33. enum haus
  34. {
  35. Float:X,
  36. Float:Y,
  37. Float:Z,
  38. hausobjekt,
  39. hPickup,
  40. Text3D:hLabel,
  41. Preis,
  42. vergeben,
  43. Besitzer[MAX_PLAYER_NAME],
  44. locked,
  45. hInt,
  46. bool:erstellt
  47. }
  48. new HausInfo[MAX_HAUS][haus];
  49.  
  50. public OnFilterScriptInit()
  51. {
  52. print("\n=================================================");
  53. print(" SQLite Haussystem by Music4You aka Items4Landwirt");
  54. print("===================================================\n");
  55.  
  56. DisableInteriorEnterExits();
  57. Database = db_open("Haus.db");
  58. db_query(Database,"CREATE TABLE IF NOT EXISTS `haus`(`ID`,`X`,`Y`,`Z`,`Preis`,`vergeben`,`Besitzer`,`locked`,`hInt`)");
  59.  
  60. createhouse();
  61. #if defined DEBUG
  62. print("Tabellen wurden erstellt!\nHäuser Geladen!");
  63. #endif
  64. return 1;
  65. }
  66.  
  67. public OnFilterScriptExit()
  68. {
  69. return 1;
  70. }
  71.  
  72. public OnPlayerConnect(playerid)
  73. {
  74. return 1;
  75. }
  76.  
  77. public OnPlayerDisconnect(playerid, reason)
  78. {
  79. return 1;
  80. }
  81.  
  82. ocmd:chaus(playerid,params[])
  83. {
  84. new Float:x,Float:y,Float:z,Float:a,preis,inter,Text[256], query[256];
  85. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  86. if(sscanf(params,"dd", preis,inter)) return SCM(playerid,rot,"Benutze: /chaus [Preis][Interior ID (1-3)]");
  87. GetPlayerPos(playerid, x, y, z);
  88. GetPlayerFacingAngle(playerid,a);
  89. for(new i = 0;i < MAX_HAUS; i++)
  90. {
  91. if(HausInfo[i][erstellt] == true)continue;
  92. HausInfo[i][erstellt] = true;
  93. HausInfo[i][X] = x;
  94. HausInfo[i][Y] = y;
  95. HausInfo[i][Z] = z;
  96. HausInfo[i][Preis] = preis;
  97. HausInfo[i][vergeben] = 0;
  98. HausInfo[i][Besitzer] = 0;
  99. HausInfo[i][locked] = 1;
  100. HausInfo[i][hInt] = inter;
  101.  
  102. HausInfo[i][hausobjekt] = CreateDynamicPickup(1273, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
  103.  
  104. format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",i,HausInfo[i][Preis]);
  105. HausInfo[i][hLabel] = Create3DTextLabel(Text, orange, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z], 15, 0);
  106.  
  107. format(query,sizeof(query),"INSERT INTO `haus` (`ID`, `X`,`Y`,`Z`,`Preis`,`vergeben`,`Besitzer`,`locked`,`hInt`) VALUES ('%i','%f','%f','%f','%d','0','Niemand','1','%d')",i,x,y,z,preis,inter);
  108. db_query(Database,query);
  109. SCM(playerid,gruen,"Haus erstellt");
  110.  
  111. #if defined DEBUG
  112. print(query);
  113. #endif
  114. return 1;
  115. }
  116. return SCM(playerid,rot,"Es wude bereits die Maximale Anzahl von Häusern erstellt!");
  117. }
  118. ocmd:delhaus(playerid, params[])
  119. {
  120. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  121. new id = IsHaus(playerid),query[256];
  122. if(id != -1)
  123. {
  124. HausInfo[id][erstellt] = false;
  125. HausInfo[id][X] = 0.0;
  126. HausInfo[id][Y] = 0.0;
  127. HausInfo[id][Z] = 0.0;
  128. HausInfo[id][Preis] = 0;
  129. HausInfo[id][vergeben] = 0;
  130. HausInfo[id][Besitzer] = 0;
  131. HausInfo[id][locked] = 0;
  132. HausInfo[id][hInt] = 0;
  133. SCM(playerid,gruen,"Du hast das Haus gelöscht");
  134. DestroyDynamicPickup(HausInfo[id][hausobjekt]);
  135. Delete3DTextLabel(HausInfo[id][hLabel]);
  136.  
  137. format(query,sizeof(query),"SELECT * FROM haus WHERE ID = '%d'",id);
  138. format(query,sizeof(query),"DELETE FROM haus WHERE ID = '%d'",id);
  139. db_query(Database,query);
  140.  
  141. #if defined DEBUG
  142. print(query);
  143. #endif
  144. return 1;
  145. }
  146. else return SCM(playerid,rot,"Du bist an keinem Haus");
  147. }
  148. ocmd:delallhaus(playerid,params[])
  149. {
  150. if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
  151. for(new i=0,query[128];i<MAX_HAUS;i++)
  152. {
  153. HausInfo[i][erstellt] = false;
  154. HausInfo[i][X] = 0.0;
  155. HausInfo[i][Y] = 0.0;
  156. HausInfo[i][Z] = 0.0;
  157. HausInfo[i][Preis] = 0;
  158. HausInfo[i][vergeben] = 0;
  159. HausInfo[i][Besitzer] = 0;
  160. HausInfo[i][locked] = 0;
  161. HausInfo[i][hInt] = 0;
  162. DestroyDynamicPickup(HausInfo[i][hausobjekt]);
  163. Delete3DTextLabel(HausInfo[i][hLabel]);
  164.  
  165. format(query,sizeof(query),"SELECT * FROM haus WHERE ID = '%d'",i);
  166. format(query,sizeof(query),"DELETE FROM haus WHERE ID = '%d'",i);
  167. db_query(Database,query);
  168.  
  169. #if defined DEBUG
  170. print(query);
  171. #endif
  172. }
  173. SCM(playerid,gruen,"Du hast alle häuser gelöscht");
  174. return 1;
  175. }
  176. ocmd:hauskaufen(playerid,params[])
  177. {
  178. new id = IsHaus(playerid),Text[256],query[256];
  179. if(id != -1)
  180. {
  181. if(HausInfo[id][vergeben] != 0) return SCM(playerid,rot,"Das haus ist bereits vergeben!");
  182. HausInfo[id][vergeben] = 1;
  183. HausInfo[id][Besitzer] = SpielerName(playerid);
  184. SCM(playerid,gruen,"Du hast das Haus gekauft");
  185. GivePlayerMoney(playerid,-HausInfo[id][Preis]);
  186. Delete3DTextLabel(HausInfo[id][hLabel]);
  187. DestroyDynamicPickup(HausInfo[id][hausobjekt]);
  188. HausInfo[id][hausobjekt] = CreateDynamicPickup(1239, 1, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z]);
  189.  
  190. format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tJa",HausInfo[id][Besitzer]);
  191. HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
  192.  
  193. format(query,sizeof(query),"UPDATE `haus` SET `vergeben` = '%d',`Besitzer` = '%s' WHERE `ID` = '%d'",HausInfo[id][vergeben],HausInfo[id][Besitzer],id);
  194. db_query(Database,query);
  195.  
  196. #if defined DEBUG
  197. print(query);
  198. #endif
  199. return 1;
  200. }
  201. else return SCM(playerid,rot,"Du bist an keinem Haus");
  202. }
  203. ocmd:hausverkaufen(playerid,params[])
  204. {
  205. new id = IsHaus(playerid),Text[256],query[256];
  206. if(id != -1)
  207. {
  208. if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich verkaufen!");
  209. if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
  210. HausInfo[id][vergeben] = 0;
  211. HausInfo[id][Besitzer] = 0;
  212. HausInfo[id][locked]=1;
  213. SCM(playerid,gruen,"Du hast das Haus Verkauft");
  214. GivePlayerMoney(playerid,HausInfo[id][Preis]);
  215. Delete3DTextLabel(HausInfo[id][hLabel]);
  216. format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",id,HausInfo[id][Preis]);
  217. HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
  218.  
  219. format(query,sizeof(query),"UPDATE `haus` SET `vergeben` = '%d',`Besitzer` = 'Niemand',`locked`='1' WHERE `ID` = '%d'",HausInfo[id][vergeben],id);
  220. db_query(Database,query);
  221.  
  222. #if defined DEBUG
  223. print(query);
  224. #endif
  225. return 1;
  226. }
  227. else return SCM(playerid,rot,"Du bist an keinem Haus");
  228. }
  229. ocmd:aufschliessen(playerid,params[])
  230. {
  231. new id = IsHaus(playerid),Text[256],query[256];
  232. if(id != -1)
  233. {
  234. if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Abschließen!");
  235. if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
  236. if(HausInfo[id][locked]!=0) return SCM(playerid,rot,"Das Haus ist bereits Abgeschlossen!");
  237. HausInfo[id][locked]=1;
  238.  
  239. Delete3DTextLabel(HausInfo[id][hLabel]);
  240. format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tJa:",HausInfo[id][Besitzer]);
  241. HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
  242.  
  243. format(query,sizeof(query),"UPDATE `haus` SET `locked` = '1' WHERE `ID` = '%d'",id);
  244. db_query(Database,query);
  245. SCM(playerid,gruen,"Du hast dein Haus Abgeschlossen");
  246.  
  247. #if defined DEBUG
  248. print(query);
  249. #endif
  250. return 1;
  251. }
  252. else return SCM(playerid,rot,"Du bist an keinem Haus");
  253. }
  254. ocmd:abschliessen(playerid,params[])
  255. {
  256. new id = IsHaus(playerid),Text[256],query[256];
  257. if(id != -1)
  258. {
  259. if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Abschließen!");
  260. if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
  261. if(HausInfo[id][locked]!=1) return SCM(playerid,rot,"Das Haus ist bereits Aufgeschlossen!");
  262. HausInfo[id][locked]=0;
  263.  
  264. Delete3DTextLabel(HausInfo[id][hLabel]);
  265. format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tNein",HausInfo[id][Besitzer]);
  266. HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
  267.  
  268. format(query,sizeof(query),"UPDATE `haus` SET `locked` = '0' WHERE `ID` = '%d'",id);
  269. db_query(Database,query);
  270. SCM(playerid,gruen,"Du hast dein Haus Aufgeschlossen");
  271.  
  272. #if defined DEBUG
  273. print(query);
  274. #endif
  275. return 1;
  276. }
  277. else return SCM(playerid,rot,"Du bist an keinem Haus");
  278. }
  279. ocmd:betreten(playerid,params[])
  280. {
  281. new id = IsHaus(playerid);
  282. if(id != -1)
  283. {
  284. if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Betreten!");
  285. if(HausInfo[id][locked]!=0) return SCM(playerid,rot,"Das Haus ist Abgeschlossen");
  286.  
  287. switch(HausInfo[id][hInt])
  288. {
  289. case 0:
  290. {
  291. SCM(playerid,rot,"ERROR: kein interior vergeben, melde dich bei einem Admin!");
  292. }
  293. case 1:
  294. {
  295. SetPlayerPos(playerid,318.564971,1118.209960,1083.882812);
  296. SetPlayerInterior(playerid,5);
  297. SetPlayerVirtualWorld(playerid,id);
  298. houseint[playerid]=id;
  299. inhouse[playerid]=1;
  300. SCM(playerid,gruen,"Du hast das Haus Betreten");
  301. }
  302. case 2:
  303. {
  304. SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
  305. SetPlayerInterior(playerid,12);
  306. SetPlayerVirtualWorld(playerid,id);
  307. houseint[playerid]=id;
  308. inhouse[playerid]=1;
  309. SCM(playerid,gruen,"Du hast das Haus Betreten");
  310. }
  311. case 3:
  312. {
  313. SetPlayerPos(playerid,1267.663208,-781.323242,1091.906250);
  314. SetPlayerInterior(playerid,5);
  315. SetPlayerVirtualWorld(playerid,id);
  316. houseint[playerid]=id;
  317. inhouse[playerid]=1;
  318. SCM(playerid,gruen,"Du hast das Haus Betreten");
  319. }
  320. }
  321. return 1;
  322. }
  323. else return SCM(playerid,rot,"Du bist an keinem Haus");
  324. }
  325. ocmd:verlassen(playerid,params[])
  326. {
  327. new DBResult:Result, str[512],id=houseint[playerid];
  328. if(inhouse[playerid]!=1)return SCM(playerid,rot,"Du bist in keinem Haus!");
  329. format(str,sizeof(str),"SELECT * FROM `haus` WHERE `ID` = '%i'",houseint[playerid]);
  330. Result = db_query(Database,str);
  331. db_get_field_assoc(Result,"X",str,sizeof(str));
  332. HausInfo[id][X]=floatstr(str);
  333. db_get_field_assoc(Result,"Y",str,sizeof(str));
  334. HausInfo[id][Y]=floatstr(str);
  335. db_get_field_assoc(Result,"Z",str,sizeof(str));
  336. HausInfo[id][Z]=floatstr(str);
  337. SetPlayerPos(playerid,HausInfo[id][X],HausInfo[id][Y],HausInfo[id][Z]);
  338. SetPlayerInterior(playerid,0);
  339. SetPlayerVirtualWorld(playerid,0);
  340. houseint[playerid]=0;
  341. inhouse[playerid]=0;
  342. db_free_result(Result);
  343. return 1;
  344. }
  345.  
  346. stock SpielerName(playerid)
  347. {
  348. new name[MAX_PLAYER_NAME];
  349. GetPlayerName(playerid,name,sizeof(name));
  350. return name;
  351. }
  352. stock IsHaus(playerid)
  353. {
  354. new i=0;
  355. while(i != MAX_HAUS)
  356. {
  357. if(IsPlayerInRangeOfPoint(playerid, 3.0, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z])) return i;
  358. i++;
  359. }
  360. return -1;
  361. }
  362. stock createhouse()
  363. {
  364. new DBResult:Result, str[512],Text[256], rows,i=0;
  365. for(;i<MAX_HAUS;i++)
  366. {
  367. format(str,sizeof(str),"SELECT * FROM `haus` WHERE `ID` = '%i'",i);
  368. Result = db_query(Database,str);
  369. rows = db_num_rows(Result);
  370. if(rows == 0)continue;
  371.  
  372. db_get_field_assoc(Result,"X",str,sizeof(str));
  373. HausInfo[i][X]=floatstr(str);
  374. db_get_field_assoc(Result,"Y",str,sizeof(str));
  375. HausInfo[i][Y]=floatstr(str);
  376. db_get_field_assoc(Result,"Z",str,sizeof(str));
  377. HausInfo[i][Z]=floatstr(str);
  378. db_get_field_assoc(Result,"Preis",str,sizeof(str));
  379. HausInfo[i][Preis]=strval(str);
  380. db_get_field_assoc(Result,"vergeben",str,sizeof(str));
  381. HausInfo[i][vergeben]=strval(str);
  382. db_get_field_assoc(Result,"Besitzer",str,sizeof(str));
  383. format(HausInfo[i][Besitzer],MAX_PLAYER_NAME,"%s",str);
  384. db_get_field_assoc(Result,"locked",str,sizeof(str));
  385. HausInfo[i][locked]=strval(str);
  386. db_get_field_assoc(Result,"hInt",str,sizeof(str));
  387. HausInfo[i][hInt]=strval(str);
  388.  
  389. HausInfo[i][erstellt] = true;
  390. house++;
  391.  
  392. if(HausInfo[i][vergeben] == 1)
  393. {
  394. new lock[20];
  395. if(HausInfo[i][locked] == 1) { lock = "Ja"; }
  396. else if(HausInfo[i][locked] == 0) { lock = "Nein"; }
  397.  
  398. format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen\t%s",HausInfo[i][Besitzer],locked);
  399. HausInfo[i][hausobjekt] = CreateDynamicPickup(1239, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
  400. }
  401. else
  402. {
  403. format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",i,HausInfo[i][Preis]);
  404. HausInfo[i][hausobjekt] = CreateDynamicPickup(1273, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
  405. }
  406. HausInfo[i][hLabel] = Create3DTextLabel(Text, orange, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z], 15, 0);
  407. db_free_result(Result);
  408. }
  409. printf(" **Es wurde %d Häuser erfolgreich Geladen**",house);
  410. }
  411.  
  412. stock sscanf(string[], format[], {Float,_}:...)
  413. {
  414. #if defined isnull
  415. if (isnull(string))
  416. #else
  417. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  418. #endif
  419. {
  420. return format[0];
  421. }
  422. #pragma tabsize 4
  423. new
  424. formatPos = 0,
  425. stringPos = 0,
  426. paramPos = 2,
  427. paramCount = numargs(),
  428. delim = ' ';
  429. while (string[stringPos] && string[stringPos] <= ' ')
  430. {
  431. stringPos++;
  432. }
  433. while (paramPos < paramCount && string[stringPos])
  434. {
  435. switch (format[formatPos++])
  436. {
  437. case '\0':
  438. {
  439. return 0;
  440. }
  441. case 'i', 'd':
  442. {
  443. new
  444. neg = 1,
  445. num = 0,
  446. ch = string[stringPos];
  447. if (ch == '-')
  448. {
  449. neg = -1;
  450. ch = string[++stringPos];
  451. }
  452. do
  453. {
  454. stringPos++;
  455. if ('0' <= ch <= '9')
  456. {
  457. num = (num * 10) + (ch - '0');
  458. }
  459. else
  460. {
  461. return -1;
  462. }
  463. }
  464. while ((ch = string[stringPos]) > ' ' && ch != delim);
  465. setarg(paramPos, 0, num * neg);
  466. }
  467. case 'h', 'x':
  468. {
  469. new
  470. num = 0,
  471. ch = string[stringPos];
  472. do
  473. {
  474. stringPos++;
  475. switch (ch)
  476. {
  477. case 'x', 'X':
  478. {
  479. num = 0;
  480. continue;
  481. }
  482. case '0' .. '9':
  483. {
  484. num = (num << 4) | (ch - '0');
  485. }
  486. case 'a' .. 'f':
  487. {
  488. num = (num << 4) | (ch - ('a' - 10));
  489. }
  490. case 'A' .. 'F':
  491. {
  492. num = (num << 4) | (ch - ('A' - 10));
  493. }
  494. default:
  495. {
  496. return -1;
  497. }
  498. }
  499. }
  500. while ((ch = string[stringPos]) > ' ' && ch != delim);
  501. setarg(paramPos, 0, num);
  502. }
  503. case 'c':
  504. {
  505. setarg(paramPos, 0, string[stringPos++]);
  506. }
  507. case 'f':
  508. {
  509.  
  510. new changestr[16], changepos = 0, strpos = stringPos;
  511. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  512. {
  513. changestr[changepos++] = string[strpos++];
  514. }
  515. changestr[changepos] = '\0';
  516. setarg(paramPos,0,_:floatstr(changestr));
  517. }
  518. case 'p':
  519. {
  520. delim = format[formatPos++];
  521. continue;
  522. }
  523. case '\'':
  524. {
  525. new
  526. end = formatPos - 1,
  527. ch;
  528. while ((ch = format[++end]) && ch != '\'') {}
  529. if (!ch)
  530. {
  531. return -1;
  532. }
  533. format[end] = '\0';
  534. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  535. {
  536. if (format[end + 1])
  537. {
  538. return -1;
  539. }
  540. return 0;
  541. }
  542. format[end] = '\'';
  543. stringPos = ch + (end - formatPos);
  544. formatPos = end + 1;
  545. }
  546. case 'u':
  547. {
  548. new
  549. end = stringPos - 1,
  550. id = 0,
  551. bool:num = true,
  552. ch;
  553. while ((ch = string[++end]) && ch != delim)
  554. {
  555. if (num)
  556. {
  557. if ('0' <= ch <= '9')
  558. {
  559. id = (id * 10) + (ch - '0');
  560. }
  561. else
  562. {
  563. num = false;
  564. }
  565. }
  566. }
  567. if (num && IsPlayerConnected(id))
  568. {
  569. setarg(paramPos, 0, id);
  570. }
  571. else
  572. {
  573. #if !defined foreach
  574. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  575. #define __SSCANF_FOREACH__
  576. #endif
  577. string[end] = '\0';
  578. num = false;
  579. new
  580. name[MAX_PLAYER_NAME];
  581. id = end - stringPos;
  582. foreach (Player, playerid)
  583. {
  584. GetPlayerName(playerid, name, sizeof (name));
  585. if (!strcmp(name, string[stringPos], true, id))
  586. {
  587. setarg(paramPos, 0, playerid);
  588. num = true;
  589. break;
  590. }
  591. }
  592. if (!num)
  593. {
  594. setarg(paramPos, 0, INVALID_PLAYER_ID);
  595. }
  596. string[end] = ch;
  597. #if defined __SSCANF_FOREACH__
  598. #undef foreach
  599. #undef __SSCANF_FOREACH__
  600. #endif
  601. }
  602. stringPos = end;
  603. }
  604. case 's', 'z':
  605. {
  606. new
  607. i = 0,
  608. ch;
  609. if (format[formatPos])
  610. {
  611. while ((ch = string[stringPos++]) && ch != delim)
  612. {
  613. setarg(paramPos, i++, ch);
  614. }
  615. if (!i)
  616. {
  617. return -1;
  618. }
  619. }
  620. else
  621. {
  622. while ((ch = string[stringPos++]))
  623. {
  624. setarg(paramPos, i++, ch);
  625. }
  626. }
  627. stringPos--;
  628. setarg(paramPos, i, '\0');
  629. }
  630. default:
  631. {
  632. continue;
  633. }
  634. }
  635. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  636. {
  637. stringPos++;
  638. }
  639. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  640. {
  641. stringPos++;
  642. }
  643. paramPos++;
  644. }
  645. do
  646. {
  647. if ((delim = format[formatPos++]) > ' ')
  648. {
  649. if (delim == '\'')
  650. {
  651. while ((delim = format[formatPos++]) && delim != '\'') {}
  652. }
  653. else if (delim != 'z')
  654. {
  655. return delim;
  656. }
  657. }
  658. }
  659. while (delim > ' ');
  660. return 0;
  661. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement