Guest User

Untitled

a guest
Dec 5th, 2011
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.77 KB | None | 0 0
  1. //RL Script made by Apoolecu aka. Sp!ax
  2. //V.0.2
  3.  
  4. #include <a_samp>
  5. #include <Dini>
  6. #include <filemanager>
  7. #include <zcmd>
  8.  
  9.  
  10. #pragma tabsize 0
  11.  
  12.  
  13. #define COLOR_WARNING 0xFF6347AA
  14. #define COLOR_INFO 0xF6F60000
  15. #define COLOR_WHITE 0xFFFFFFFF
  16.  
  17. #define COLOR_GREEN 0x339933FF
  18. #define COLOR_YELLOW 0xFFDE00FF
  19. #define COLOR_BLUE 0x0000F600
  20. #define COLOR_RED 0xCE000000
  21. #define COLOR_ORANGE 0xFF830000
  22. /*
  23. #define NEED_TAXI 0xF6EB35F6
  24. #define NEED_MEDIC 0x00F600F6
  25. #define NEED_FEUER 0xF60052F6
  26. #define NEED_POLICE 0x006CF6F6
  27. #define NEED_MAKLER 0x00D9F6F6
  28. #define NEED_ADAC 0xF64B00F6*/
  29.  
  30. #define COLOR_GREY 0xBEBEBEAA
  31. #define color_DGREEN 0x33AA33AA
  32. #define COLOR_BLACK 0x000000
  33. #define COLOR_GRAD5 0xE3E3E3FF
  34. #define COLOR_GRAD4 0xD8D8D8FF
  35. #define COLOR_GRAD1 0xB4B5B7FF
  36. #define COLOR_LIGHTBLUE 0x33CCFFAA
  37. #define COLOR_GRAD2 0xBFC0C2FF
  38. #define COLOR_LIGHTBLUE 0x33CCFFAA
  39. #define COLOR_LILA 0xF600E6F6
  40. #define COLOR_GRAD3 0xCBCCCEFF
  41. #define color_lred 0xAA3333AA
  42. #define COLOR_FADE1 0xE6E6E6E6
  43. #define COLOR_FADE2 0xC8C8C8C8
  44. #define COLOR_FADE3 0xAAAAAAAA
  45. #define COLOR_FADE4 0x8C8C8C8C
  46. #define COLOR_FADE5 0x6E6E6E6E
  47. #define COLOR_PURPLE 0xC2A2DAAA
  48. #define COLOR_CADETBLUE 0x5F9EA0
  49. #define COLOR_GRAD6 0xF0F0F0FF
  50. #define COLOR_INVISIBLE 0xFFFFFF00
  51. #define COLOR_ORANGE 0xFF830000
  52. #define COLOR_lorange 0xFF830000
  53. #define COLOR_t 0xFFC4C4FF
  54.  
  55. #define DIALOG_LOGIN 1
  56. #define DIALOG_REG 2
  57. #define DIALOG_REG2 3
  58. #define DIALOG_REG3 4
  59.  
  60. #define MAX_HOUSE 500
  61. enum house_daten
  62. {
  63. besitzer[MAX_PLAYER_NAME],
  64. ID,
  65. interior,
  66. level,
  67. preis,
  68. punkte,
  69. Float:hX,Float:hZ,Float:hY,
  70. Float:hX2,Float:hZ2,Float:hY2,
  71. Text3D:hlabel,
  72. Pickup,
  73. Pickup2,
  74. bereit
  75. }
  76. new Haus[MAX_HOUSE][house_daten];
  77.  
  78. enum spieler_daten
  79. {
  80. wanted,
  81. admin,
  82. skin,
  83. rang,
  84. job,
  85. duty,
  86. money,
  87. geschlecht,
  88. alter,
  89. cuff,
  90. tod,
  91. haendler,
  92. level1,
  93. Float:lastx,Float:lasty,Float:lastz,
  94. eingeloggt
  95. }
  96. new pName[MAX_PLAYER_NAME];
  97. new Spieler[MAX_PLAYERS][spieler_daten];
  98.  
  99. enum Auto_System
  100. {
  101. aID,
  102. aModel,
  103. Float:aX,
  104. Float:aY,
  105. Float:aZ,
  106. Float:aAngle,
  107. }
  108.  
  109. new Auto[MAX_VEHICLES][Auto_System];
  110.  
  111. new Text:txtTimeDisp;
  112. new hour, minute;
  113. new timestr[32];
  114.  
  115. forward SpeicherUser(playerid);
  116. forward UpdateTime();
  117. forward SpeicherFahrzeug(carid);
  118. forward LadeFahrzeug(carid);
  119. forward SpeicherHaus(id);
  120. forward LadeHaus(id);
  121. forward InstalliereServer();
  122.  
  123. main()
  124. {
  125. print("\n----------------------------------");
  126. print(" Reallife Script by Apoolecu");
  127. print("----------------------------------\n");
  128. }
  129.  
  130. public OnGameModeInit()
  131. {
  132. SetGameModeText("Realife Script");
  133. AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  134. txtTimeDisp = TextDrawCreate(605.0,25.0,"00:00");
  135. TextDrawUseBox(txtTimeDisp, 0);
  136. TextDrawFont(txtTimeDisp, 3);
  137. TextDrawSetShadow(txtTimeDisp,0); // no shadow
  138. TextDrawSetOutline(txtTimeDisp,2); // thickness 1
  139. TextDrawBackgroundColor(txtTimeDisp,0x000000FF);
  140. TextDrawColor(txtTimeDisp,0xFFFFFFFF);
  141. TextDrawAlignment(txtTimeDisp,3);
  142. TextDrawLetterSize(txtTimeDisp,0.5,1.5);
  143. if(!dir_exists("scriptfiles/Server"))
  144. { InstalliereServer();}
  145. for(new i = 1; i < MAX_VEHICLES; i++)
  146. {
  147. new string[90];
  148. format(string, sizeof(string), "Server/Fahrzeug/%d.car", i);
  149. if(fexist(string))
  150. {
  151. LadeFahrzeug(i);
  152. CreateVehicle(Auto[i][aModel], Auto[i][aX], Auto[i][aY], Auto[i][aZ], Auto[i][aAngle],0, 0, -1);
  153. }
  154. }
  155. for(new h = 1,string[125]; h < MAX_HOUSE; h++)
  156. {
  157. format(string, sizeof(string), "Server/Haus/%d.haus", h);
  158. if(fexist(string))
  159. {
  160. LadeHaus(h);
  161. if(Haus[h][bereit] == 0)
  162. {
  163. format(string,sizeof string,"Besitzer: KEINER\nLevel: %d\nPreis: %d $\nPremiumpunkte: %d\n/kaufen",Haus[h][level],Haus[h][preis],Haus[h][punkte]);
  164. Haus[h][hlabel] = Create3DTextLabel(string,COLOR_WHITE,Haus[h][hX],Haus[h][hY],Haus[h][hZ]+0.75,40.0,0,1);
  165. Haus[h][Pickup] = CreatePickup(1273, 1, Haus[h][hX], Haus[h][hY], Haus[h][hZ], -1);
  166. Haus[h][Pickup2] = CreatePickup(1559, 1, Haus[h][hX2], Haus[h][hY2], Haus[h][hZ2], -1);
  167. }
  168. if(Haus[h][bereit] == 1)
  169. {
  170. format(string,sizeof string,"Besitzer: %s\nLevel: %d\nPreis: %d $\nPremiumpunkte: %d",Haus[h][besitzer],Haus[h][level],Haus[h][preis],Haus[h][punkte]);
  171. Haus[h][hlabel] = Create3DTextLabel(string,COLOR_WHITE,Haus[h][hX],Haus[h][hY],Haus[h][hZ]+0.75,40.0,0,1);
  172. Haus[h][Pickup] = CreatePickup(1272, 1, Haus[h][hX], Haus[h][hY], Haus[h][hZ], -1);
  173. Haus[h][Pickup2] = CreatePickup(1559, 1, Haus[h][hX2], Haus[h][hY2], Haus[h][hZ2], -1);
  174. }
  175. }
  176. }
  177. return 1;
  178. }
  179.  
  180. public OnGameModeExit()
  181. {
  182. return 1;
  183. }
  184.  
  185. public OnPlayerRequestClass(playerid, classid)
  186. {
  187. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  188. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  189. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  190. return 1;
  191. }
  192.  
  193. public OnPlayerConnect(playerid)
  194. {
  195. new string[64],accFormat[40];
  196. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  197. format(string,sizeof string,"[SERVERINFO] %s hat den Server betreten",pName);
  198. SendClientMessageToAll(COLOR_INFO,string);
  199. format(accFormat,sizeof accFormat,"Server/User/%s.User",pName);
  200. SetPlayerColor(playerid,COLOR_WHITE);
  201. gettime(hour, minute);
  202. SetPlayerTime(playerid,hour,minute);
  203. if(fexist(accFormat))
  204. {
  205. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD ,"Login","Willkommen zurück!\nGebe dein Passwort ein um zu spielen.","Abbrechen","Weiter");
  206. }
  207. else
  208. {
  209. ShowPlayerDialog(playerid,DIALOG_REG,DIALOG_STYLE_PASSWORD ,"Registrieren","Willkommen!\nGebe ein Passwort ein um auf dem Server zu spielen.","Weiter","Abbrechen");
  210. }
  211. return 1;
  212. }
  213.  
  214. public OnPlayerDisconnect(playerid, reason)
  215. {
  216. new string[90];
  217. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  218. switch(reason)
  219. {
  220. case 0: format(string,sizeof string,"[SERVERINFO] %s hat den Server aufgrund eines Timouts verlassen.",pName);
  221. case 1: format(string,sizeof string,"[SERVERINFO] %s hat den Server verlassen.",pName);
  222. case 2: format(string,sizeof string,"[SERVERINFO] %s hat den Server aufgrund eines Kicks/Banns verlassen.",pName);
  223. }
  224. SendClientMessageToAll(COLOR_INFO,string);
  225. SpeicherUser(playerid);
  226. Spieler[playerid][eingeloggt] = 0;
  227. Spieler[playerid][geschlecht] = 0;
  228. Spieler[playerid][alter] = 0;
  229. Spieler[playerid][tod] = 0;
  230. Spieler[playerid][cuff] = 0;
  231. Spieler[playerid][money] = 0;
  232. Spieler[playerid][wanted] = 0;
  233. Spieler[playerid][haendler] = 0;
  234. Spieler[playerid][skin] = 0;
  235. Spieler[playerid][job] = 0;
  236. Spieler[playerid][rang] = 0;
  237. Spieler[playerid][duty] = 0;
  238. Spieler[playerid][level1] = 0;
  239. Spieler[playerid][admin] = 0;
  240. Spieler[playerid][lastx] = (0.0);
  241. Spieler[playerid][lasty] = (0.0);
  242. Spieler[playerid][lastz] = (0.0);
  243. return 1;
  244. }
  245.  
  246. public OnPlayerSpawn(playerid)
  247. {
  248. SetPlayerSkin(playerid,Spieler[playerid][skin]);
  249. GivePlayerMoney(playerid,Spieler[playerid][money]);
  250. SetPlayerWantedLevel(playerid,Spieler[playerid][wanted]);
  251. TextDrawShowForPlayer(playerid,txtTimeDisp);
  252. gettime(hour, minute);
  253. SetPlayerTime(playerid,hour,minute);
  254. return 1;
  255. }
  256.  
  257. public OnPlayerDeath(playerid, killerid, reason)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnVehicleSpawn(vehicleid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnVehicleDeath(vehicleid, killerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnPlayerText(playerid, text[])
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnPlayerCommandText(playerid, cmdtext[])
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  283. {
  284. return 1;
  285. }
  286.  
  287. public OnPlayerExitVehicle(playerid, vehicleid)
  288. {
  289. return 1;
  290. }
  291.  
  292. public OnPlayerStateChange(playerid, newstate, oldstate)
  293. {
  294. return 1;
  295. }
  296.  
  297. public OnPlayerEnterCheckpoint(playerid)
  298. {
  299. return 1;
  300. }
  301.  
  302. public OnPlayerLeaveCheckpoint(playerid)
  303. {
  304. return 1;
  305. }
  306.  
  307. public OnPlayerEnterRaceCheckpoint(playerid)
  308. {
  309. return 1;
  310. }
  311.  
  312. public OnPlayerLeaveRaceCheckpoint(playerid)
  313. {
  314. return 1;
  315. }
  316.  
  317. public OnRconCommand(cmd[])
  318. {
  319. return 1;
  320. }
  321.  
  322. public OnPlayerRequestSpawn(playerid)
  323. {
  324. return 1;
  325. }
  326.  
  327. public OnObjectMoved(objectid)
  328. {
  329. return 1;
  330. }
  331.  
  332. public OnPlayerObjectMoved(playerid, objectid)
  333. {
  334. return 1;
  335. }
  336.  
  337. public OnPlayerPickUpPickup(playerid, pickupid)
  338. {
  339. return 1;
  340. }
  341.  
  342. public OnVehicleMod(playerid, vehicleid, componentid)
  343. {
  344. return 1;
  345. }
  346.  
  347. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  348. {
  349. return 1;
  350. }
  351.  
  352. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  353. {
  354. return 1;
  355. }
  356.  
  357. public OnPlayerSelectedMenuRow(playerid, row)
  358. {
  359. return 1;
  360. }
  361.  
  362. public OnPlayerExitedMenu(playerid)
  363. {
  364. return 1;
  365. }
  366.  
  367. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  368. {
  369. return 1;
  370. }
  371.  
  372. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  373. {
  374. return 1;
  375. }
  376.  
  377. public OnRconLoginAttempt(ip[], password[], success)
  378. {
  379. return 1;
  380. }
  381.  
  382. public OnPlayerUpdate(playerid)
  383. {
  384. return 1;
  385. }
  386.  
  387. public OnPlayerStreamIn(playerid, forplayerid)
  388. {
  389. return 1;
  390. }
  391.  
  392. public OnPlayerStreamOut(playerid, forplayerid)
  393. {
  394. return 1;
  395. }
  396.  
  397. public OnVehicleStreamIn(vehicleid, forplayerid)
  398. {
  399. return 1;
  400. }
  401.  
  402. public OnVehicleStreamOut(vehicleid, forplayerid)
  403. {
  404. return 1;
  405. }
  406.  
  407. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  408. {
  409. new accFormat[128];
  410. GetPlayerName(playerid,pName,sizeof pName);
  411. format(accFormat,sizeof accFormat,"Server/User/%s.User",pName);
  412. if(response)
  413. {
  414. switch(dialogid) // dialogid auswählen
  415. {
  416. case DIALOG_LOGIN: // ID Login
  417. {
  418. if(!strlen(inputtext))
  419. {
  420. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Willkommen zurück!\nGebe dein Passwort ein um zu spielen.","Abbrechen","Weiter");
  421. return SendClientMessage(playerid,COLOR_INFO,"[SERVERINFO] Kein Passwort angegeben!");
  422. }
  423. if(strcmp(inputtext,dini_Get(accFormat,"Passwort")) == 0)
  424. {
  425. Spieler[playerid][money] = dini_Int(accFormat,"money");
  426. Spieler[playerid][wanted] = dini_Int(accFormat,"wanted");
  427. Spieler[playerid][geschlecht] = dini_Int(accFormat,"geschlecht");
  428. Spieler[playerid][alter] = dini_Int(accFormat,"alter");
  429. Spieler[playerid][tod] = dini_Int(accFormat,"tod");
  430. Spieler[playerid][haendler] = dini_Int(accFormat,"haendler");
  431. Spieler[playerid][cuff] = dini_Int(accFormat,"cuff");
  432. Spieler[playerid][skin] = dini_Int(accFormat,"skin");
  433. Spieler[playerid][job] = dini_Int(accFormat,"job");
  434. Spieler[playerid][rang] = dini_Int(accFormat,"rang");
  435. Spieler[playerid][duty] = dini_Int(accFormat,"duty");
  436. Spieler[playerid][level1] = dini_Int(accFormat,"level");
  437. Spieler[playerid][admin] = dini_Int(accFormat,"admin");
  438. Spieler[playerid][lastx] = dini_Float(accFormat,"lastx");
  439. Spieler[playerid][lasty] = dini_Float(accFormat,"lasty");
  440. Spieler[playerid][lastz] = dini_Float(accFormat,"lastz");
  441. Spieler[playerid][eingeloggt] = 1;
  442. SendClientMessage(playerid,COLOR_YELLOW,"[SERVERINFO] Du wurdest erfolgreich eingeloggt.");
  443. }
  444. else
  445. {
  446. ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login","Bitte logge dich ein","Abbrechen","Weiter");
  447. SendClientMessage(playerid,COLOR_INFO,"[SERVERINFO] Das Passwort war Falsch!");
  448. }
  449. }
  450. case DIALOG_REG: // ID Registrieren
  451. {
  452. if(!strlen(inputtext))
  453. {
  454. ShowPlayerDialog(playerid,DIALOG_REG,DIALOG_STYLE_PASSWORD,"Registrieren","Willkommen!\nGebe ein Passwort ein um auf dem Server zu Spielen.","Abbrechen","Weiter");
  455. return SendClientMessage(playerid,COLOR_RED,"[SERVERINFO] Das Passwort ist zu kurz!");
  456. }
  457. dini_Create(accFormat);
  458. dini_Set(accFormat,"Passwort",inputtext);
  459. ShowPlayerDialog(playerid,DIALOG_REG2,1,"Registieren","Gebe nun dein Alter ein.\n(z.B. 17)","Weiter","");
  460. }
  461. case DIALOG_REG2: // Alter
  462. {
  463. if(!strlen(inputtext))
  464. {
  465. ShowPlayerDialog(playerid,DIALOG_REG2,1,"Registrieren","Gebe nun dein Alter ein.\n(z.B. 17)","Weiter","");
  466. return SendClientMessage(playerid,COLOR_RED,"[SERVERINFO] Das angegeben Alter ist nicht korrekt!");
  467. }
  468. dini_Set(accFormat,"alter",inputtext);
  469. dini_Set(accFormat,"money","5000");
  470. dini_Set(accFormat,"wanted","0");
  471. dini_Set(accFormat,"cuff","0");
  472. dini_Set(accFormat,"skin","0");
  473. dini_Set(accFormat,"job","0");
  474. dini_Set(accFormat,"rang","0");
  475. dini_Set(accFormat,"duty","0");
  476. dini_Set(accFormat,"tod","0");
  477. dini_Set(accFormat,"admin","0");
  478. dini_Set(accFormat,"level1","1");
  479. dini_Set(accFormat,"haendler","0");
  480. ShowPlayerDialog(playerid,DIALOG_REG3,2,"Registieren","Männlich\nWeiblich","Weiter","");
  481. }
  482. case DIALOG_REG3: // Geschlecht
  483. {
  484. if(listitem == 0)
  485. {
  486. dini_Set(accFormat,"geschlecht","1");
  487. Spieler[playerid][eingeloggt] = 1;
  488. SendClientMessage(playerid,COLOR_YELLOW,"[SERVERINFO] Account wurde angelegt und du wurdest eingeloggt.");
  489. }
  490. if(listitem == 1)
  491. {
  492. dini_Set(accFormat,"geschlecht","2");
  493. Spieler[playerid][eingeloggt] = 1;
  494. SendClientMessage(playerid,COLOR_YELLOW,"[SERVERINFO] Account wurde angelegt und du wurdest eingeloggt.");
  495. }
  496. }
  497. }
  498. }
  499. return 1;
  500. }
  501.  
  502. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  503. {
  504. return 1;
  505. }
  506.  
  507. public OnPlayerCommandPerformed(playerid,cmdtext[],success) {
  508. if(success == 0)
  509. {
  510. SendClientMessage(playerid,COLOR_RED,"Dieser Befehl ist nicht verfügbar.");
  511. return 1;
  512. }
  513. return 1;
  514. }
  515.  
  516. public UpdateTime()
  517. {
  518. gettime(hour, minute);
  519. format(timestr,60,"%02d:%02d",hour,minute);
  520. TextDrawSetString(txtTimeDisp,timestr);
  521.  
  522. SetWorldTime(hour);
  523.  
  524. new x=0;
  525. while(x!=MAX_PLAYERS) {
  526. if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) {
  527. SetPlayerTime(x,hour,minute);
  528. }
  529. x++;
  530. }
  531. }
  532.  
  533. public SpeicherUser(playerid)
  534. {
  535. new accFormat[40];
  536. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  537. format(accFormat,sizeof accFormat,"Server/User/%s.User",pName);
  538. if(fexist(accFormat) && Spieler[playerid][eingeloggt])
  539. {
  540. dini_IntSet(accFormat,"wanted",Spieler[playerid][wanted]);
  541. dini_IntSet(accFormat,"geschlecht",Spieler[playerid][geschlecht]);
  542. dini_IntSet(accFormat,"alter",Spieler[playerid][alter]);
  543. dini_IntSet(accFormat,"tod",Spieler[playerid][tod]);
  544. dini_IntSet(accFormat,"haendler",Spieler[playerid][haendler]);
  545. dini_IntSet(accFormat,"cuff",Spieler[playerid][cuff]);
  546. dini_IntSet(accFormat,"money",Spieler[playerid][money]);
  547. dini_IntSet(accFormat,"skin",Spieler[playerid][skin]);
  548. dini_IntSet(accFormat,"job",Spieler[playerid][job]);
  549. dini_IntSet(accFormat,"rang",Spieler[playerid][rang]);
  550. dini_IntSet(accFormat,"duty",Spieler[playerid][duty]);
  551. dini_IntSet(accFormat,"level", Spieler[playerid][level1]);
  552. dini_IntSet(accFormat,"admin", Spieler[playerid][admin]);
  553. dini_FloatSet(accFormat,"lastx",Spieler[playerid][lastx]);
  554. dini_FloatSet(accFormat,"lasty",Spieler[playerid][lasty]);
  555. dini_FloatSet(accFormat,"lastz",Spieler[playerid][lastz]);
  556. }
  557. return 1;
  558. }
  559.  
  560. public SpeicherFahrzeug(carid)
  561. {
  562. if(carid <= 0)
  563. {
  564. return 1;
  565. }
  566. new str[90];
  567. format(str, sizeof(str), "Server/Fahrzeug/%d.car", carid);
  568. dini_Create(str);
  569. {
  570. Auto[carid][aModel] = GetVehicleModel(carid);
  571. dini_IntSet(str,"ID",Auto[carid][aID]);
  572. dini_FloatSet(str,"aX", Auto[carid][aX]);
  573. dini_FloatSet(str,"aY", Auto[carid][aY]);
  574. dini_FloatSet(str,"aZ", Auto[carid][aZ]);
  575. dini_FloatSet(str,"aAngle", Auto[carid][aAngle]);
  576. dini_IntSet(str,"model",Auto[carid][aModel]);
  577. }
  578. return 1;
  579. }
  580.  
  581. public LadeFahrzeug(carid)
  582. {
  583. new str[90];
  584. format(str, sizeof(str), "Server/Fahrzeug/%d.car", carid);
  585. if(carid <= 0)
  586. {
  587. return 1;
  588. }
  589. if(fexist(str))
  590. {
  591. Auto[carid][aID] = dini_Int(str, "ID");
  592. Auto[carid][aX] = dini_Float(str, "aX");
  593. Auto[carid][aY] = dini_Float(str, "aY");
  594. Auto[carid][aZ] = dini_Float(str, "aZ");
  595. Auto[carid][aAngle] = dini_Float(str, "aAngle");
  596. Auto[carid][aModel] = dini_Int(str, "Model");
  597. }
  598. return 1;
  599. }
  600.  
  601. public SpeicherHaus(id)
  602. {
  603. new str[125];
  604. if(id <= 0)
  605. {
  606. return 1;
  607. }
  608. format(str, sizeof(str), "Server/Haus/%d.haus", id);
  609. dini_Create(str);
  610. if(fexist(str))
  611. {
  612. dini_Set(str,"besitzer",Haus[id][besitzer]);
  613. dini_IntSet(str,"ID",Haus[id][ID]);
  614. dini_IntSet(str,"interior",Haus[id][interior]);
  615. dini_IntSet(str,"Preis",Haus[id][preis]);
  616. dini_IntSet(str,"Level",Haus[id][level]);
  617. dini_IntSet(str,"Punkte",Haus[id][punkte]);
  618. dini_FloatSet(str,"hX", Haus[id][hX]);
  619. dini_FloatSet(str,"hY", Haus[id][hY]);
  620. dini_FloatSet(str,"hZ", Haus[id][hZ]);
  621. dini_FloatSet(str,"hX2", Haus[id][hX2]);
  622. dini_FloatSet(str,"hY2", Haus[id][hY2]);
  623. dini_FloatSet(str,"hZ2", Haus[id][hZ2]);
  624. dini_IntSet(str,"Bereit",Haus[id][bereit]);
  625. printf("X %.1f ; Y %.1f; Z %.1f",Haus[id][hX],Haus[id][hY],Haus[id][hZ]);
  626. }
  627. return 1;
  628. }
  629.  
  630. public LadeHaus(id)
  631. {
  632. new str[125];
  633. format(str, sizeof(str), "Server/Haus/%d.haus", id);
  634. if(id == 0)
  635. {
  636. return 1;
  637. }
  638. if(fexist(str))
  639. {
  640. format(Haus[id][besitzer],24,"%s",dini_Get(str, "besitzer"));
  641. Haus[id][ID] = dini_Int(str, "ID");
  642. Haus[id][interior] = dini_Int(str, "interior");
  643. Haus[id][preis] = dini_Int(str, "Preis");
  644. Haus[id][level] = dini_Int(str, "Level");
  645. Haus[id][punkte] = dini_Int(str, "punkte");
  646. Haus[id][hX] = dini_Float(str, "hX");
  647. Haus[id][hY] = dini_Float(str, "hY");
  648. Haus[id][hZ] = dini_Float(str, "hZ");
  649. Haus[id][hX2] = dini_Float(str, "hX2");
  650. Haus[id][hY2] = dini_Float(str, "hY2");
  651. Haus[id][hZ2] = dini_Float(str, "hZ2");
  652. Haus[id][bereit] = dini_Int(str, "Bereit");
  653. printf("X %.1f ; Y %.1f; Z %.1f",Haus[id][hX],Haus[id][hY],Haus[id][hZ]);
  654. }
  655. return 1;
  656. }
  657.  
  658. public InstalliereServer()
  659. {
  660. print("____RL Script By Apoolecu aka Sp!ax____");
  661. print("Alle für den Server benoetigten sachen");
  662. print("werden Installiert, bitte warte");
  663. if(!dir_exists("scriptfiles/Server"))
  664. {
  665. print("Installiere: Hauptverzeichnis");
  666. print("Verzeichnis: scriptfiles/Server");
  667. dir_create("scriptfiles/Server");
  668. }
  669. if(!dir_exists("scriptfiles/Server/User"))
  670. {
  671. print("Installiere: Userverzeichnis");
  672. print("Verzeichnis: scriptfiles/Server/User");
  673. dir_create("scriptfiles/Server/User");
  674. }
  675. if(!dir_exists("scriptfiles/Server/Fahrzeug"))
  676. {
  677. print("Installiere: Fahrzeugverzeichnis");
  678. print("Verzeichnis: scriptfiles/Server/Fahrzeug");
  679. dir_create("scriptfiles/Server/Fahrzeug");
  680. }
  681. if(!dir_exists("scriptfiles/Server/Haus"))
  682. {
  683. print("Installiere: Haueserverzeichnis");
  684. print("Verzeichnis: scriptfiles/Server/Haus");
  685. dir_create("scriptfiles/Server/Haus");
  686. }
  687. print("Installation wurde erfolgreich beendet");
  688. print("_____RL Script by Apoolecu aka Sp!ax_____");
  689. print("_________________________________________");
  690. }
  691. CMD:hkaufen(playerid, params[])
  692. {
  693. for(new h = 1,string[125],sUnterbefehl[16]; h < MAX_HOUSE; h ++)
  694. {
  695. if(IsPlayerInRangeOfPoint(playerid,5.0,Haus[h][hX],Haus[h][hY],Haus[h][hZ]) && Haus[h][bereit] == 0)
  696. {
  697. if(sscanf(params,"s",sUnterbefehl)){
  698. SendClientMessage(playerid,COLOR_RED,"Benutze: /hkaufen [Premium/Normal]");
  699. }
  700. if(strfind(sUnterbefehl, "Premium", true) != -1)
  701. {
  702. GetPlayerName(playerid,pName,sizeof pName);
  703. SendClientMessage(playerid,COLOR_YELLOW,"Du hast das Haus für Premiumpunkte gekauft.");
  704. Spieler[playerid][lastx] = Haus[h][hX];
  705. Spieler[playerid][lasty] = Haus[h][hY];
  706. Spieler[playerid][lastz] = Haus[h][hZ];
  707. strmid(Haus[h][besitzer], pName,0, sizeof(pName)-1, MAX_PLAYER_NAME);
  708. DestroyPickup(Haus[h][Pickup]);
  709. Haus[h][bereit] = 1;
  710. Delete3DTextLabel(Haus[h][hlabel]);
  711. format(string,sizeof string,"Besitzer: %s\nLevel: %d\nPreis: %d $\nPremiumpunkte: %d",Haus[h][besitzer],Haus[h][level],Haus[h][preis],Haus[h][punkte]);
  712. Haus[h][hlabel] = Create3DTextLabel(string,COLOR_WHITE,Haus[h][hX],Haus[h][hY],Haus[h][hZ]+0.75,40.0,0,1);
  713. Haus[h][Pickup] = CreatePickup(1272, 1, Haus[h][hX], Haus[h][hY], Haus[h][hZ], -1);
  714. }
  715. else if(strfind(sUnterbefehl, "Normal", true) != -1)
  716. {
  717. GetPlayerName(playerid,pName,sizeof pName);
  718. SendClientMessage(playerid,COLOR_YELLOW,"Du hast das Haus für Geld gekauft.");
  719. Spieler[playerid][lastx] = Haus[h][hX];
  720. Spieler[playerid][lasty] = Haus[h][hY];
  721. Spieler[playerid][lastz] = Haus[h][hZ];
  722. GivePlayerMoney(playerid, -Haus[h][preis]);
  723. Haus[h][bereit] = 1;
  724. DestroyPickup(Haus[h][Pickup]);
  725. Delete3DTextLabel(Haus[h][hlabel]);
  726. strmid(Haus[h][besitzer], pName,0, sizeof(pName)-1, MAX_PLAYER_NAME);
  727. format(string,sizeof string,"Besitzer: %s\nLevel: %d\nPreis: %d $\nPremiumpunkte: %d",Haus[h][besitzer],Haus[h][level],Haus[h][preis],Haus[h][punkte]);
  728. Haus[h][hlabel] = Create3DTextLabel(string,COLOR_WHITE,Haus[h][hX],Haus[h][hY],Haus[h][hZ]+0.75,40.0,0,1);
  729. Haus[h][Pickup] = CreatePickup(1272, 1, Haus[h][hX], Haus[h][hY], Haus[h][hZ], -1);
  730. }
  731. }
  732. }
  733. return 1;
  734. }
  735. CMD:hauschange(playerid, params[])
  736. {
  737. if(Spieler[playerid][admin] >=1)
  738. {
  739. for(new h = 1,sUnterbefehl[16]; h < MAX_HOUSE; h ++)
  740. {
  741. if(IsPlayerInRangeOfPoint(playerid,5.0,Haus[h][hX],Haus[h][hY],Haus[h][hZ]) && Haus[h][bereit] == 0)
  742. {
  743. if(sscanf(params,"s",sUnterbefehl)){
  744. SendClientMessage(playerid,COLOR_RED,"Benutze: /hkaufen [Nutzbar/Interior]");
  745. }
  746. if(strfind(sUnterbefehl, "Nutzbar", true) != -1)
  747. {
  748. SendClientMessage(playerid,COLOR_GREY,"Es sind derzeit folgende Interior nutzbar:");
  749. SendClientMessage(playerid,COLOR_GREY,"ID: 1a|1b|2a|2b|3|5a|5b|5c|8a|8b|9|10a|10b|12|15|");
  750. }
  751. else if(strfind(sUnterbefehl, "1a", true) != -1)
  752. {
  753. Haus[h][interior] = 1;
  754. Haus[h][hX2] = 2535.83;
  755. Haus[h][hY2] = -1674.32;
  756. Haus[h][hZ2] = 1015.50;
  757. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 1a.");
  758. }
  759. else if(strfind(sUnterbefehl, "1b", true) != -1)
  760. {
  761. Haus[h][interior] = 1;
  762. Haus[h][hX2] = -2158.72;
  763. Haus[h][hY2] = 641.29;
  764. Haus[h][hZ2] = 1052.38;
  765. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 1b.");
  766. }
  767. else if(strfind(sUnterbefehl, "2a", true) != -1)
  768. {
  769. Haus[h][interior] = 2;
  770. Haus[h][hX2] = 2567.52;
  771. Haus[h][hY2] = -1294.59;
  772. Haus[h][hZ2] = 1063.25;
  773. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 2a.");
  774. }
  775. else if(strfind(sUnterbefehl, "3", true) != -1)
  776. {
  777. Haus[h][interior] = 3;
  778. Haus[h][hX2] = 2496.65;
  779. Haus[h][hY2] = -1696.55;
  780. Haus[h][hZ2] = 1014.74;
  781. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 3.");
  782. }
  783. else if(strfind(sUnterbefehl, "5a", true) != -1)
  784. {
  785. Haus[h][interior] = 5;
  786. Haus[h][hX2] = 2338.32;
  787. Haus[h][hY2] = -1180.61;
  788. Haus[h][hZ2] = 1027.98;
  789. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 5a.");
  790. }
  791. else if(strfind(sUnterbefehl, "5b", true) != -1)
  792. {
  793. Haus[h][interior] = 5;
  794. Haus[h][hX2] = 318.565;
  795. Haus[h][hY2] = 1115.210;
  796. Haus[h][hZ2] = 1082.98;
  797. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 5b.");
  798. }
  799. else if(strfind(sUnterbefehl, "5c", true) != -1)
  800. {
  801. Haus[h][interior] = 5;
  802. Haus[h][hX2] = 1299.14;
  803. Haus[h][hY2] = -794.77;
  804. Haus[h][hZ2] = 1084.00;
  805. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 5c.");
  806. }
  807. else if(strfind(sUnterbefehl, "8a", true) != -1)
  808. {
  809. Haus[h][interior] = 8;
  810. Haus[h][hX2] = 2807.63;
  811. Haus[h][hY2] = -1170.15;
  812. Haus[h][hZ2] = 1025.57;
  813. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 8a.");
  814. }
  815. else if(strfind(sUnterbefehl, "8b", true) != -1)
  816. {
  817. Haus[h][interior] = 8;
  818. Haus[h][hX2] = 2365.42;
  819. Haus[h][hY2] = -1131.85;
  820. Haus[h][hZ2] = 1050.88;
  821. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 8b.");
  822. }
  823. else if(strfind(sUnterbefehl, "9", true) != -1)
  824. {
  825. Haus[h][interior] = 9;
  826. Haus[h][hX2] = 2251.85;
  827. Haus[h][hY2] = -1138.16;
  828. Haus[h][hZ2] = 1050.63;
  829. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 9.");
  830. }
  831. else if(strfind(sUnterbefehl, "10a", true) != -1)
  832. {
  833. Haus[h][interior] = 10;
  834. Haus[h][hX2] = 2260.76;
  835. Haus[h][hY2] = -1210.45;
  836. Haus[h][hZ2] = 1049.02;
  837. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 10a.");
  838. }
  839. else if(strfind(sUnterbefehl, "10b", true) != -1)
  840. {
  841. Haus[h][interior] = 10;
  842. Haus[h][hX2] = 2262.83;
  843. Haus[h][hY2] = -1137.71;
  844. Haus[h][hZ2] = 1050.63;
  845. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 10b.");
  846. }
  847. else if(strfind(sUnterbefehl, "12", true) != -1)
  848. {
  849. Haus[h][interior] = 10;
  850. Haus[h][hX2] = 2324.33;
  851. Haus[h][hY2] = -1144.79;
  852. Haus[h][hZ2] = 1050.71;
  853. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 12.");
  854. }
  855. else if(strfind(sUnterbefehl, "15", true) != -1)
  856. {
  857. Haus[h][interior] = 15;
  858. Haus[h][hX2] = 2220.26;
  859. Haus[h][hY2] = -1148.01;
  860. Haus[h][hZ2] = 1025.80;
  861. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 15.");
  862. }
  863. else if(strfind(sUnterbefehl, "2b", true) != -1)
  864. {
  865. Haus[h][interior] = 2;
  866. Haus[h][hX2] = 2451.77;
  867. Haus[h][hY2] = -1699.80;
  868. Haus[h][hZ2] = 1013.51;
  869. SendClientMessage(playerid,COLOR_GREEN,"Das Interior ist jetzt ID 2b.");
  870. }
  871. Haus[h][Pickup2] = CreatePickup(1559,1,Haus[h][hX2],Haus[h][hY2],Haus[h][hZ2],-1);
  872. }
  873. }
  874. }
  875. return 1;
  876. }
  877. CMD:chaus(playerid, params[])
  878. {
  879. if(Spieler[playerid][admin] >2)
  880. {
  881. new hlevel,hpunkte,hpreis;
  882. if(sscanf(params,"iii",hlevel,hpunkte,hpreis))
  883. SendClientMessage(playerid,COLOR_RED,"Benutze: /chaus [Level] [Premiumpunkte] [Preis]");
  884. else if(hlevel < 1 || hlevel > 50) SendClientMessage(playerid,COLOR_RED,"Es sind nur Level zwischen 1-50 erlaubt.");
  885. else
  886. {
  887. new Haus1,string[125];
  888. for(new i; i < MAX_HOUSE; i++)
  889. {
  890. if(Haus[i][hX] == 0.0 && i >=1)
  891. {
  892. Haus1 = i;
  893. break;
  894. }
  895. }
  896. new Float:X,Float:Y,Float:Z;
  897. GetPlayerPos(playerid,X,Y,Z);
  898. Haus[Haus1][Pickup] = CreatePickup(1273, 1, X, Y, Z, -1);
  899. Haus[Haus1][ID] = Haus1;
  900. Haus[Haus1][hX] = X;
  901. Haus[Haus1][hY] = Y;
  902. Haus[Haus1][hZ] = Z;
  903. printf("X %.1f ; Y %.1f; Z %.1f",X,Y,Z);
  904. printf("X %.1f ; Y %.1f; Z %.1f",Haus[Haus1][hX],Haus[Haus1][hY],Haus[Haus1][hZ]);
  905. Haus[Haus1][level] = hlevel;
  906. Haus[Haus1][punkte] = hpunkte;
  907. Haus[Haus1][preis] = hpreis;
  908. Haus[Haus1][bereit] = 0;
  909. format(string,sizeof string,"Besitzer: KEINER\nLevel: %d\nPreis: %d $\nPremiumpunkte: %d\n/kaufen",Haus[Haus1][level],Haus[Haus1][preis],Haus[Haus1][punkte]);
  910. Create3DTextLabel(string,COLOR_WHITE,Haus[Haus1][hX],Haus[Haus1][hY],Haus[Haus1][hZ]+0.75,40.0,0,1);
  911. SpeicherHaus(Haus1);
  912. }
  913. }
  914. return 1;
  915. }
  916. CMD:giveadmin(playerid,params[])
  917. {
  918. if(Spieler[playerid][admin] >= 2|| IsPlayerAdmin(playerid))
  919. {
  920. new pID, rangA, Nachricht[125];
  921. if(sscanf(params,"ui",pID,rangA)){
  922. return SendClientMessage(playerid,COLOR_RED,"Benutze: /giveadmin [playerid/name] [rang]");}
  923. else if (rangA < 0 || rangA > 5){ SendClientMessage(playerid, COLOR_RED, "Es sind nur Ränge zwischen 0-5 erlaubt.");}
  924. else if(!IsPlayerConnected(pID)){ SendClientMessage(playerid, COLOR_RED, "Dieser User ist nicht online.");}
  925. Spieler[pID][admin] = rangA;
  926. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  927. format(Nachricht, sizeof(Nachricht), "%s hat die deinen Admin Rang auf %d gesetzt",pName,rangA);
  928. SendClientMessage(pID,COLOR_GREY,Nachricht);
  929. GetPlayerName(pID,pName,MAX_PLAYER_NAME);
  930. format(Nachricht, sizeof(Nachricht), "Du hast %s den Admin Rang auf %d gesetzt",pName,rangA);
  931. SendClientMessage(playerid,COLOR_GREY,Nachricht);
  932. SpeicherUser(pID);
  933. }
  934. return 1;
  935. }
  936. CMD:vehicle(playerid,params[])
  937. {
  938. if(Spieler[playerid][admin] >= 2)
  939. {
  940. new modell, Fahrzeug;
  941. if(sscanf(params,"i",modell)){
  942. return SendClientMessage(playerid,COLOR_RED,"Benutze: /vehicle [Modell]");}
  943. else if (modell < 399 || modell > 612){ SendClientMessage(playerid, COLOR_RED, "Es sind nur Modelle zwischen 400-611 erlaubt.");}
  944. else
  945. {
  946. for(new i; i < MAX_VEHICLES; i++)
  947. {
  948. if(Auto[i][aX] == 0.0 && i >=1)
  949. {
  950. Fahrzeug = i;
  951. break;
  952. }
  953. }
  954. new Float:X,Float:Y,Float:Z,Float:Angle;
  955. GetPlayerPos(playerid,X,Y,Z);
  956. GetPlayerFacingAngle(playerid,Angle);
  957. GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
  958. CreateVehicle(modell,X+3,Y,Z,Angle,0,0,-1);
  959. SendClientMessage(playerid,COLOR_YELLOW,"Das Fahrzeug wurde erstellt.");
  960. Auto[Fahrzeug][aID] = Fahrzeug;
  961. Auto[Fahrzeug][aX] = X;
  962. Auto[Fahrzeug][aY] = Y;
  963. Auto[Fahrzeug][aZ] = Z;
  964. Auto[Fahrzeug][aAngle] = Angle;
  965. SpeicherFahrzeug(Fahrzeug);
  966. }
  967. }
  968. return 1;
  969. }
  970. stock sscanf(string[], format[], {Float,_}:...)
  971. {
  972. #if defined isnull
  973. if (isnull(string))
  974. #else
  975. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  976. #endif
  977. {
  978. return format[0];
  979. }
  980. #pragma tabsize 4
  981. new
  982. formatPos = 0,
  983. stringPos = 0,
  984. paramPos = 2,
  985. paramCount = numargs(),
  986. delim = ' ';
  987. while (string[stringPos] && string[stringPos] <= ' ')
  988. {
  989. stringPos++;
  990. }
  991. while (paramPos < paramCount && string[stringPos])
  992. {
  993. switch (format[formatPos++])
  994. {
  995. case '\0':
  996. {
  997. return 0;
  998. }
  999. case 'i', 'd':
  1000. {
  1001. new
  1002. neg = 1,
  1003. num = 0,
  1004. ch = string[stringPos];
  1005. if (ch == '-')
  1006. {
  1007. neg = -1;
  1008. ch = string[++stringPos];
  1009. }
  1010. do
  1011. {
  1012. stringPos++;
  1013. if ('0' <= ch <= '9')
  1014. {
  1015. num = (num * 10) + (ch - '0');
  1016. }
  1017. else
  1018. {
  1019. return -1;
  1020. }
  1021. }
  1022. while ((ch = string[stringPos]) > ' ' && ch != delim);
  1023. setarg(paramPos, 0, num * neg);
  1024. }
  1025. case 'h', 'x':
  1026. {
  1027. new
  1028. num = 0,
  1029. ch = string[stringPos];
  1030. do
  1031. {
  1032. stringPos++;
  1033. switch (ch)
  1034. {
  1035. case 'x', 'X':
  1036. {
  1037. num = 0;
  1038. continue;
  1039. }
  1040. case '0' .. '9':
  1041. {
  1042. num = (num << 4) | (ch - '0');
  1043. }
  1044. case 'a' .. 'f':
  1045. {
  1046. num = (num << 4) | (ch - ('a' - 10));
  1047. }
  1048. case 'A' .. 'F':
  1049. {
  1050. num = (num << 4) | (ch - ('A' - 10));
  1051. }
  1052. default:
  1053. {
  1054. return -1;
  1055. }
  1056. }
  1057. }
  1058. while ((ch = string[stringPos]) > ' ' && ch != delim);
  1059. setarg(paramPos, 0, num);
  1060. }
  1061. case 'c':
  1062. {
  1063. setarg(paramPos, 0, string[stringPos++]);
  1064. }
  1065. case 'f':
  1066. {
  1067.  
  1068. new changestr[16], changepos = 0, strpos = stringPos;
  1069. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  1070. {
  1071. changestr[changepos++] = string[strpos++];
  1072. }
  1073. changestr[changepos] = '\0';
  1074. setarg(paramPos,0,_:floatstr(changestr));
  1075. }
  1076. case 'p':
  1077. {
  1078. delim = format[formatPos++];
  1079. continue;
  1080. }
  1081. case '\'':
  1082. {
  1083. new
  1084. end = formatPos - 1,
  1085. ch;
  1086. while ((ch = format[++end]) && ch != '\'') {}
  1087. if (!ch)
  1088. {
  1089. return -1;
  1090. }
  1091. format[end] = '\0';
  1092. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  1093. {
  1094. if (format[end + 1])
  1095. {
  1096. return -1;
  1097. }
  1098. return 0;
  1099. }
  1100. format[end] = '\'';
  1101. stringPos = ch + (end - formatPos);
  1102. formatPos = end + 1;
  1103. }
  1104. case 'u':
  1105. {
  1106. new
  1107. end = stringPos - 1,
  1108. id = 0,
  1109. bool:num = true,
  1110. ch;
  1111. while ((ch = string[++end]) && ch != delim)
  1112. {
  1113. if (num)
  1114. {
  1115. if ('0' <= ch <= '9')
  1116. {
  1117. id = (id * 10) + (ch - '0');
  1118. }
  1119. else
  1120. {
  1121. num = false;
  1122. }
  1123. }
  1124. }
  1125. if (num && IsPlayerConnected(id))
  1126. {
  1127. setarg(paramPos, 0, id);
  1128. }
  1129. else
  1130. {
  1131. #if !defined foreach
  1132. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  1133. #define __SSCANF_FOREACH__
  1134. #endif
  1135. string[end] = '\0';
  1136. num = false;
  1137. new
  1138. name[MAX_PLAYER_NAME];
  1139. id = end - stringPos;
  1140. foreach (Player, playerid)
  1141. {
  1142. GetPlayerName(playerid, name, sizeof (name));
  1143. if (!strcmp(name, string[stringPos], true, id))
  1144. {
  1145. setarg(paramPos, 0, playerid);
  1146. num = true;
  1147. break;
  1148. }
  1149. }
  1150. if (!num)
  1151. {
  1152. setarg(paramPos, 0, INVALID_PLAYER_ID);
  1153. }
  1154. string[end] = ch;
  1155. #if defined __SSCANF_FOREACH__
  1156. #undef foreach
  1157. #undef __SSCANF_FOREACH__
  1158. #endif
  1159. }
  1160. stringPos = end;
  1161. }
  1162. case 's', 'z':
  1163. {
  1164. new
  1165. i = 0,
  1166. ch;
  1167. if (format[formatPos])
  1168. {
  1169. while ((ch = string[stringPos++]) && ch != delim)
  1170. {
  1171. setarg(paramPos, i++, ch);
  1172. }
  1173. if (!i)
  1174. {
  1175. return -1;
  1176. }
  1177. }
  1178. else
  1179. {
  1180. while ((ch = string[stringPos++]))
  1181. {
  1182. setarg(paramPos, i++, ch);
  1183. }
  1184. }
  1185. stringPos--;
  1186. setarg(paramPos, i, '\0');
  1187. }
  1188. default:
  1189. {
  1190. continue;
  1191. }
  1192. }
  1193. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  1194. {
  1195. stringPos++;
  1196. }
  1197. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  1198. {
  1199. stringPos++;
  1200. }
  1201. paramPos++;
  1202. }
  1203. do
  1204. {
  1205. if ((delim = format[formatPos++]) > ' ')
  1206. {
  1207. if (delim == '\'')
  1208. {
  1209. while ((delim = format[formatPos++]) && delim != '\'') {}
  1210. }
  1211. else if (delim != 'z')
  1212. {
  1213. return delim;
  1214. }
  1215. }
  1216. }
  1217. while (delim > ' ');
  1218. return 0;
  1219. }
  1220.  
Advertisement
Add Comment
Please, Sign In to add comment