Advertisement
Guest User

Untitled

a guest
Oct 30th, 2012
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.02 KB | None | 0 0
  1. /*
  2. Dynamisches Biz System by Freakynight
  3.  
  4. !!!!-Ihr müsst den Ordner "Bizz" in den Scritpfiles erstellen-!!!!
  5. */
  6. #include <a_samp>
  7. #include <dini>
  8. #include <ocmd>
  9.  
  10. #define MAX_BIZZ 500 //Wie viele Bizzes
  11.  
  12. #define BLAU "{0080FF}" //farbe für Pickup | BLAU
  13. #define WEISS "{FFFFFF}" //Farbe für Pickup | WEISS
  14. #define BLUE 0x0000FFFF
  15. #define ROT 0xE10000FF
  16.  
  17. new inBizz[MAX_PLAYERS] = -1;
  18. enum BizzInformationen
  19. {
  20. Float:PosX,
  21. Float:PosY,
  22. Float:PosZ,
  23. Besitzer[64],
  24. Besetzt,
  25. Preis,
  26. Level,
  27. Konto,
  28. Interior,
  29. Text3D:Label,
  30. Pickup,
  31. World
  32. }
  33. new bInfo[MAX_BIZZ][BizzInformationen];
  34.  
  35. enum BizzInnen
  36. {
  37. Float:SpawnX,
  38. Float:SpawnY,
  39. Float:SpawnZ,
  40. Int
  41. }
  42. new bInt[][BizzInnen] =
  43. {
  44. {363.4149,-74.2596,1001.5078,10}, //BSN
  45. {365.7547,-10.8823,1001.8516,9}, //cluckin
  46. {372.1370,-132.7309,1001.4922,5}, //well stacked pizza
  47. {286.1115,-41.3004,1001.5156,1}, //ammu
  48. {206.9614,-139.4169,1003.5078,3}, //Kleidung
  49. {-26.9958,-30.0071,1003.5573,4}, //24/7
  50. {771.9066,-3.8409,1000.7285,5}, //gym
  51. {493.4917,-23.5213,1000.6797,17} //disco
  52. };
  53. //Ihr könnt neue Interiorbizzes erstellen indem ihr hier oben es so einfügt: SpawnX,SpawnY,SpawnZ,Interior
  54.  
  55. public OnFilterScriptInit()
  56. {
  57. print("\n----------------");
  58. print("BizSystem by Freakynight wurde geladen.");
  59. print("----------------\n");
  60. for(new b = 1; b <MAX_BIZZ; b++)
  61. {
  62. LoadBizz(b);
  63. }
  64. return 1;
  65. }
  66.  
  67. public OnFilterScriptExit()
  68. {
  69. return 1;
  70. }
  71. ocmd:cbizz(playerid,params[])
  72. {
  73. if(IsPlayerAdmin(playerid))
  74. {
  75. new Float:x,Float:y,Float:z,preis,level,int;
  76. if(sscanf(params,"ddd",preis,level,int))return SendClientMessage(playerid,BLUE,"Benutze: /cbizz [PREIS] [LEVEL] [INT-NR]");
  77. GetPlayerPos(playerid,x,y,z);
  78. CreateBizz(x,y,z,"Keiner",preis,level,int,playerid+20+preis);
  79. }
  80. return 1;
  81. }
  82. ocmd:sellfirma(playerid,params[])
  83. {
  84. for(new b = 1; b <MAX_BIZZ; b++)
  85. {
  86. if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
  87. {
  88. new name[MAX_PLAYER_NAME];
  89. GetPlayerName(playerid,name,sizeof name);
  90. if(strcmp(bInfo[b][Besitzer],name,false) == 0)
  91. {
  92. SendClientMessage(playerid,BLUE,"Sie haben ihr Bizz an den Staat verkauft!");
  93. GivePlayerMoney(playerid,bInfo[b][Preis]);
  94. new BizzDatei[50];
  95. format(BizzDatei,50,"/Bizz/%d.txt",b);
  96. dini_IntSet(BizzDatei,"Besetzt",0);
  97. dini_Set(BizzDatei,"Besitzer","Keiner");
  98. KillBizz(b);
  99. LoadBizz(b);
  100. }
  101. else SendClientMessage(playerid,ROT,"Du bist nicht der Besitzer von dem Bizz!");
  102. }
  103. }
  104. return 1;
  105. }
  106. ocmd:bizhelp(playerid,params[])
  107. {
  108. SendClientMessage(playerid,-1,"/bauszahlen - /beinzahlen - /buyfirma - /sellfirma - /bkonto");
  109. return 1;
  110. }
  111. ocmd:bkonto(playerid,params[])
  112. {
  113. for(new b = 1; b <MAX_BIZZ; b++)
  114. {
  115. new Innenraum = bInfo[b][Interior];
  116. if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
  117. {
  118. new name[MAX_PLAYER_NAME];
  119. GetPlayerName(playerid,name,sizeof name);
  120. if(strcmp(bInfo[b][Besitzer],name,false) == 1)
  121. {
  122. new string[188];
  123. format(string,sizeof(string),"In deinem Biz sind zurzeit %d$ drin.",bInfo[b][Konto]);
  124. SendClientMessage(playerid,BLUE,string);
  125. return 1;
  126. }
  127. else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
  128. }
  129. else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
  130. }
  131. return 1;
  132. }
  133. ocmd:buyfirma(playerid,params[])
  134. {
  135. for(new b = 1; b <MAX_BIZZ; b++)
  136. {
  137. if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
  138. {
  139. if(bInfo[b][Besetzt] == 0)
  140. {
  141. new name[MAX_PLAYER_NAME];
  142. GetPlayerName(playerid,name,sizeof name);
  143. if(strcmp(bInfo[b][Besitzer],name,false) == 0)return SendClientMessage(playerid,ROT,"Dieses Bizz gehört dir bereits!");
  144. if(GetPlayerMoney(playerid) >= bInfo[b][Preis])
  145. {
  146. if(GetPlayerScore(playerid) >= bInfo[b][Level])
  147. {
  148. GivePlayerMoney(playerid,-bInfo[b][Preis]);
  149. new BizzDatei[64];
  150. format(BizzDatei,64,"/Bizz/%d.txt",b);
  151. dini_IntSet(BizzDatei,"Besetzt",1);
  152. dini_Set(BizzDatei,"Besitzer",name);
  153. SendClientMessage(playerid,BLUE,"Du hast erfolgreich das Bizz gekauft!");
  154. KillBizz(b);
  155. LoadBizz(b);
  156. }
  157. else SendClientMessage(playerid,ROT,"Dein Level ist zu niedrig!");
  158. }
  159. else SendClientMessage(playerid,ROT,"Du hast nicht genug Geld dabei!");
  160. }
  161. else SendClientMessage(playerid,ROT,"Das BIZZ gehört schon jemandem!");
  162. }
  163. }
  164. return 1;
  165. }
  166. ocmd:beinzahlen(playerid,params[])
  167. {
  168. for(new b = 1; b <MAX_BIZZ; b++)
  169. {
  170. new Innenraum = bInfo[b][Interior];
  171. if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
  172. {
  173. new name[MAX_PLAYER_NAME];
  174. GetPlayerName(playerid,name,sizeof name);
  175. if(strcmp(bInfo[b][Besitzer],name,false) == 1)
  176. {
  177. new egeld, string[128];
  178. if(sscanf(params,"d",egeld))return SendClientMessage(playerid,BLUE,"Benutze: /beinzahlen [Einzahl-Menge]");
  179. if(GetPlayerMoney(playerid) >= egeld)
  180. {
  181. new BizzDatei[50];
  182. format(BizzDatei,50,"/Bizz/%d.txt",b);
  183. bInfo[b][Konto] += egeld;
  184. dini_IntSet(BizzDatei,"Konto",bInfo[b][Konto]);
  185. GivePlayerMoney(playerid,-egeld);
  186. format(string,sizeof(string),"Du hast %d$ in die Bizz Kasse eingezahlt! Neuer Stand: %d",egeld,bInfo[b][Konto]);
  187. SendClientMessage(playerid,BLUE,string);
  188. KillBizz(b);
  189. LoadBizz(b);
  190. return 1;
  191. }
  192. else return SendClientMessage(playerid,ROT,"Du hast nicht genug Geld dabei!");
  193. }
  194. else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
  195. }
  196. else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
  197. }
  198. return 1;
  199. }
  200. ocmd:bauszahlen(playerid,params[])
  201. {
  202. for(new b = 1; b <MAX_BIZZ; b++)
  203. {
  204. new Innenraum = bInfo[b][Interior];
  205. if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
  206. {
  207. new name[MAX_PLAYER_NAME];
  208. GetPlayerName(playerid,name,sizeof name);
  209. if(strcmp(bInfo[b][Besitzer],name,false) == 1)
  210. {
  211. new ageld, string[128];
  212. if(sscanf(params,"d",ageld))return SendClientMessage(playerid,BLUE,"Benutze: /bauszahlen [Auszahl-Menge]");
  213. if(bInfo[b][Konto] >= ageld)
  214. {
  215. new BizzDatei[50];
  216. format(BizzDatei,50,"/Bizz/%d.txt",b);
  217. bInfo[b][Konto] -= ageld;
  218. dini_IntSet(BizzDatei,"Konto",bInfo[b][Konto]);
  219. GivePlayerMoney(playerid,ageld);
  220. format(string,sizeof(string),"Du hast %d$ aus der Bizz Kasse ausgezahlt! Neuer Stand: %d",ageld, bInfo[b][Konto]);
  221. SendClientMessage(playerid,BLUE,string);
  222. KillBizz(b);
  223. LoadBizz(b);
  224. return 1;
  225. }
  226. else return SendClientMessage(playerid,ROT,"In der Bizz Kasse ist nicht soviel Geld!");
  227. }
  228. else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
  229. }
  230. else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
  231. }
  232. return 1;
  233. }
  234. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  235. {
  236. if(newkeys == KEY_YES)
  237. {
  238. for(new b = 1; b <MAX_BIZZ; b++)
  239. {
  240. if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
  241. {
  242. new innenraum = bInfo[b][Interior];
  243. SetPlayerPos(playerid,bInt[innenraum][SpawnX],bInt[innenraum][SpawnY],bInt[innenraum][SpawnZ]);
  244. SetPlayerInterior(playerid,bInt[innenraum][Int]);
  245. SetPlayerVirtualWorld(playerid,bInfo[b][World]);
  246. inBizz[playerid] = b;
  247. return 1;
  248. }
  249. }
  250. }
  251. if(newkeys == KEY_NO)
  252. {
  253. if(inBizz[playerid] != -1)
  254. {
  255. new b = inBizz[playerid];
  256. new Innenraum = bInfo[b][Interior];
  257. if(IsPlayerInRangeOfPoint(playerid,10,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
  258. {
  259. SetPlayerPos(playerid,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]);
  260. SetPlayerInterior(playerid,0);
  261. SetPlayerVirtualWorld(playerid,0);
  262. return 1;
  263. }
  264. }
  265. }
  266. return 1;
  267. }
  268.  
  269. stock CreateBizz(Float:x,Float:y,Float:z,besitzer[64],preis,level,int,world)
  270. {
  271. new BizzDatei[50];
  272. for(new b = 1; b <MAX_BIZZ; b++)
  273. {
  274. format(BizzDatei,50,"/Bizz/%d.txt",b);
  275. if(!fexist(BizzDatei))
  276. {
  277. dini_Create(BizzDatei);
  278. dini_FloatSet(BizzDatei,"PosX",x);
  279. dini_FloatSet(BizzDatei,"PosY",y);
  280. dini_FloatSet(BizzDatei,"PosZ",z);
  281. dini_IntSet(BizzDatei,"Preis",preis);
  282. dini_IntSet(BizzDatei,"Level",level);
  283. dini_IntSet(BizzDatei,"Konto",0);
  284. dini_IntSet(BizzDatei,"Besetzt",0);
  285. dini_Set(BizzDatei,"Besitzer",besitzer);
  286. dini_IntSet(BizzDatei,"Interior",int);
  287. dini_IntSet(BizzDatei,"World",world);
  288. return LoadBizz(b);
  289. }
  290. }
  291. return 1;
  292. }
  293. stock KillBizz(bizid)
  294. {
  295. Delete3DTextLabel(bInfo[bizid][Label]);
  296. return DestroyPickup(bInfo[bizid][Pickup]);
  297. }
  298. stock LoadBizz(bizid)
  299. {
  300. new BizzDatei[64];
  301. format(BizzDatei,64,"/Bizz/%d.txt",bizid);
  302. if(!fexist(BizzDatei))return 0;
  303. bInfo[bizid][PosX] = dini_Float(BizzDatei,"PosX");
  304. bInfo[bizid][PosY] = dini_Float(BizzDatei,"PosY");
  305. bInfo[bizid][PosZ] = dini_Float(BizzDatei,"PosZ");
  306. bInfo[bizid][Level] = dini_Int(BizzDatei,"Level");
  307. bInfo[bizid][Konto] = dini_Int(BizzDatei,"Konto");
  308. bInfo[bizid][Preis] = dini_Int(BizzDatei,"Preis");
  309. bInfo[bizid][Interior] = dini_Int(BizzDatei,"Interior");
  310. bInfo[bizid][Besetzt] = dini_Int(BizzDatei,"Besetzt");
  311. format(bInfo[bizid][Besitzer],64,"%s",dini_Get(BizzDatei,"Besitzer"));
  312. if(bInfo[bizid][Besetzt] == 0)
  313. {
  314. bInfo[bizid][Pickup] = CreatePickup(1272 ,23,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],0);
  315.  
  316. new string[196];
  317. format(string,196,""BLAU"Besitzer: "WEISS"Keiner\n"BLAU"Preis: "WEISS"%d$\n"BLAU"Level: "WEISS"%d\nZum Kaufen "WEISS"/buyfirma",bInfo[bizid][Preis],bInfo[bizid][Level]);
  318. bInfo[bizid][Label] = Create3DTextLabel(string,BLUE,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],20,0,0);
  319. return print("Das Biz wurde erfolgreich geladen");
  320. }
  321. if(bInfo[bizid][Besetzt] == 1)
  322. {
  323. bInfo[bizid][Pickup] = CreatePickup(1239 ,23,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],0);
  324.  
  325. new string[196];
  326. format(string,196,""BLAU"Besitzer: "WEISS"%s\nZum Betreten: "BLAU"Z",bInfo[bizid][Besitzer]);
  327. bInfo[bizid][Label] = Create3DTextLabel(string,BLUE,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],20,0,0);
  328. return print("Das Biz wurde erfolgreich geladen");
  329. }
  330. return 1;
  331. }
  332.  
  333. stock sscanf(string[], format[], {Float,_}:...)
  334. {
  335. #if defined isnull
  336. if (isnull(string))
  337. #else
  338. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  339. #endif
  340. {
  341. return format[0];
  342. }
  343. #pragma tabsize 4
  344. new
  345. formatPos = 0,
  346. stringPos = 0,
  347. paramPos = 2,
  348. paramCount = numargs(),
  349. delim = ' ';
  350. while (string[stringPos] && string[stringPos] <= ' ')
  351. {
  352. stringPos++;
  353. }
  354. while (paramPos < paramCount && string[stringPos])
  355. {
  356. switch (format[formatPos++])
  357. {
  358. case '\0':
  359. {
  360. return 0;
  361. }
  362. case 'i', 'd':
  363. {
  364. new
  365. neg = 1,
  366. num = 0,
  367. ch = string[stringPos];
  368. if (ch == '-')
  369. {
  370. neg = -1;
  371. ch = string[++stringPos];
  372. }
  373. do
  374. {
  375. stringPos++;
  376. if ('0' <= ch <= '9')
  377. {
  378. num = (num * 10) + (ch - '0');
  379. }
  380. else
  381. {
  382. return -1;
  383. }
  384. }
  385. while ((ch = string[stringPos]) > ' ' && ch != delim);
  386. setarg(paramPos, 0, num * neg);
  387. }
  388. case 'h', 'x':
  389. {
  390. new
  391. num = 0,
  392. ch = string[stringPos];
  393. do
  394. {
  395. stringPos++;
  396. switch (ch)
  397. {
  398. case 'x', 'X':
  399. {
  400. num = 0;
  401. continue;
  402. }
  403. case '0' .. '9':
  404. {
  405. num = (num << 4) | (ch - '0');
  406. }
  407. case 'a' .. 'f':
  408. {
  409. num = (num << 4) | (ch - ('a' - 10));
  410. }
  411. case 'A' .. 'F':
  412. {
  413. num = (num << 4) | (ch - ('A' - 10));
  414. }
  415. default:
  416. {
  417. return -1;
  418. }
  419. }
  420. }
  421. while ((ch = string[stringPos]) > ' ' && ch != delim);
  422. setarg(paramPos, 0, num);
  423. }
  424. case 'c':
  425. {
  426. setarg(paramPos, 0, string[stringPos++]);
  427. }
  428. case 'f':
  429. {
  430.  
  431. new changestr[16], changepos = 0, strpos = stringPos;
  432. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  433. {
  434. changestr[changepos++] = string[strpos++];
  435. }
  436. changestr[changepos] = '\0';
  437. setarg(paramPos,0,_:floatstr(changestr));
  438. }
  439. case 'p':
  440. {
  441. delim = format[formatPos++];
  442. continue;
  443. }
  444. case '\'':
  445. {
  446. new
  447. end = formatPos - 1,
  448. ch;
  449. while ((ch = format[++end]) && ch != '\'') {}
  450. if (!ch)
  451. {
  452. return -1;
  453. }
  454. format[end] = '\0';
  455. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  456. {
  457. if (format[end + 1])
  458. {
  459. return -1;
  460. }
  461. return 0;
  462. }
  463. format[end] = '\'';
  464. stringPos = ch + (end - formatPos);
  465. formatPos = end + 1;
  466. }
  467. case 'u':
  468. {
  469. new
  470. end = stringPos - 1,
  471. id = 0,
  472. bool:num = true,
  473. ch;
  474. while ((ch = string[++end]) && ch != delim)
  475. {
  476. if (num)
  477. {
  478. if ('0' <= ch <= '9')
  479. {
  480. id = (id * 10) + (ch - '0');
  481. }
  482. else
  483. {
  484. num = false;
  485. }
  486. }
  487. }
  488. if (num && IsPlayerConnected(id))
  489. {
  490. setarg(paramPos, 0, id);
  491. }
  492. else
  493. {
  494. #if !defined foreach
  495. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  496. #define __SSCANF_FOREACH__
  497. #endif
  498. string[end] = '\0';
  499. num = false;
  500. new
  501. name[MAX_PLAYER_NAME];
  502. id = end - stringPos;
  503. foreach (Player, playerid)
  504. {
  505. GetPlayerName(playerid, name, sizeof (name));
  506. if (!strcmp(name, string[stringPos], true, id))
  507. {
  508. setarg(paramPos, 0, playerid);
  509. num = true;
  510. break;
  511. }
  512. }
  513. if (!num)
  514. {
  515. setarg(paramPos, 0, INVALID_PLAYER_ID);
  516. }
  517. string[end] = ch;
  518. #if defined __SSCANF_FOREACH__
  519. #undef foreach
  520. #undef __SSCANF_FOREACH__
  521. #endif
  522. }
  523. stringPos = end;
  524. }
  525. case 's', 'z':
  526. {
  527. new
  528. i = 0,
  529. ch;
  530. if (format[formatPos])
  531. {
  532. while ((ch = string[stringPos++]) && ch != delim)
  533. {
  534. setarg(paramPos, i++, ch);
  535. }
  536. if (!i)
  537. {
  538. return -1;
  539. }
  540. }
  541. else
  542. {
  543. while ((ch = string[stringPos++]))
  544. {
  545. setarg(paramPos, i++, ch);
  546. }
  547. }
  548. stringPos--;
  549. setarg(paramPos, i, '\0');
  550. }
  551. default:
  552. {
  553. continue;
  554. }
  555. }
  556. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  557. {
  558. stringPos++;
  559. }
  560. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  561. {
  562. stringPos++;
  563. }
  564. paramPos++;
  565. }
  566. do
  567. {
  568. if ((delim = format[formatPos++]) > ' ')
  569. {
  570. if (delim == '\'')
  571. {
  572. while ((delim = format[formatPos++]) && delim != '\'') {}
  573. }
  574. else if (delim != 'z')
  575. {
  576. return delim;
  577. }
  578. }
  579. }
  580. while (delim > ' ');
  581. return 0;
  582. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement