Advertisement
Guest User

Casino

a guest
Jan 1st, 2012
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.59 KB | None | 0 0
  1. //Gemacht von Bunnyhopper alias PumpguN
  2. // macht damit, was ihr wollt
  3.  
  4. #include <a_samp>
  5.  
  6. //
  7. #define COLOR_GREEN 0x33AA33AA
  8. #define COLOR_RED 0xAA3333AA
  9.  
  10. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  11.  
  12. #if defined FILTERSCRIPT
  13.  
  14. public OnFilterScriptInit()
  15. {
  16. print("\n--------------------------------------");
  17. print(" Casino System aus Langeweile");
  18. print("--------------------------------------\n");
  19. return 1;
  20. }
  21.  
  22. public OnFilterScriptExit()
  23. {
  24. return 1;
  25. }
  26.  
  27. #else
  28.  
  29. #endif
  30.  
  31. public OnPlayerRequestClass(playerid, classid)
  32. {
  33. SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  34. SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  35. SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  36. return 1;
  37. }
  38.  
  39. public OnPlayerConnect(playerid)
  40. {
  41. return 1;
  42. }
  43.  
  44. public OnPlayerDisconnect(playerid, reason)
  45. {
  46. return 1;
  47. }
  48.  
  49. public OnPlayerSpawn(playerid)
  50. {
  51. return 1;
  52. }
  53.  
  54. public OnPlayerDeath(playerid, killerid, reason)
  55. {
  56. return 1;
  57. }
  58.  
  59. public OnVehicleSpawn(vehicleid)
  60. {
  61. return 1;
  62. }
  63.  
  64. public OnVehicleDeath(vehicleid, killerid)
  65. {
  66. return 1;
  67. }
  68.  
  69. public OnPlayerText(playerid, text[])
  70. {
  71. return 1;
  72. }
  73.  
  74. public OnPlayerCommandText(playerid, cmdtext[])
  75. {
  76. dcmd(cdice,5,cmdtext);
  77. dcmd(guess,5,cmdtext);
  78. return 0;
  79. }
  80. dcmd_cdice(playerid,params[])
  81. {
  82. if(IsPlayerConnected(playerid))
  83. {
  84. new einsatz;
  85. if(sscanf(params,"d",einsatz)) return SendClientMessage(playerid,COLOR_RED,"FEHLER: /cdice <Einsatz>");
  86. if(GetPlayerMoney(playerid) >= einsatz)
  87. {
  88. new dice = random(5)+5;
  89. new gegenzahl = random(5)+5;
  90. if(einsatz < 5000 || einsatz > 99999)
  91. {
  92. SendClientMessage(playerid, COLOR_RED, "Der Einsatz muss zwischen $5000 und $99999 liegen.");
  93. return 1;
  94. }
  95. if(dice == gegenzahl)
  96. {
  97. new string[258];
  98. format(string,sizeof(string), "Du hast mit einer %d gegen eine %d gewonnen. Dein Einsatz hat sich soeben verdoppelt.",dice,gegenzahl);
  99. SendClientMessage(playerid,COLOR_GREEN,string);
  100. GivePlayerMoney(playerid, einsatz+einsatz);
  101. }
  102. else
  103. {
  104. new string[258];
  105. format(string,sizeof(string), "Du hast mit einer %d gegen eine %d verloren. Dein Einsatz hat sich in Luft aufgelöst.", dice,gegenzahl);
  106. GivePlayerMoney(playerid,-einsatz);
  107. SendClientMessage(playerid,COLOR_RED,string);
  108. }
  109. }
  110. else
  111. {
  112. new string[128];
  113. format(string,sizeof(string),"Du benötigst mehr Geld für deinen Einsatz (%d) oder Du setzt einen niedrigeren ein.",einsatz);
  114. SendClientMessage(playerid,COLOR_RED,string);
  115. }
  116. }
  117. return 1;
  118. }
  119. dcmd_guess(playerid,params[])
  120. {
  121. if(IsPlayerConnected(playerid))
  122. {
  123. new zahl,einsatz;
  124. if(sscanf(params,"dd",zahl,einsatz)) return SendClientMessage(playerid,COLOR_RED,"FEHLER: /guess <zahl> <einsatz>");
  125. if(GetPlayerMoney(playerid) >= einsatz)
  126. {
  127. new dice = random(6)+4;
  128. if(zahl > 10)
  129. {
  130. SendClientMessage(playerid, COLOR_RED, "Die geschätzte Zahl muss unter 10 liegen.");
  131. return 1;
  132. }
  133. if(einsatz < 5000 || einsatz > 99999)
  134. {
  135. SendClientMessage(playerid, COLOR_RED, "Der Einsatz muss zwischen $5000 und $99999 liegen.");
  136. return 1;
  137. }
  138. if(zahl == dice)
  139. {
  140. new string[258];
  141. format(string,sizeof(string), "Du hast auf die %d getippt und gewonnen. Dein Einsatz verdreifacht sich.",zahl);
  142. SendClientMessage(playerid,COLOR_GREEN,string);
  143. GivePlayerMoney(playerid, einsatz+einsatz+einsatz);
  144. }
  145. else
  146. {
  147. new string[258];
  148. format(string,sizeof(string), "Du hast auf die %d getippt, doch die richtige lautete %d. Dein Einsatz hat sich in Luft aufgelöst.", zahl,dice);
  149. GivePlayerMoney(playerid,-einsatz);
  150. SendClientMessage(playerid,COLOR_RED,string);
  151. }
  152. }
  153. else
  154. {
  155. new string[128];
  156. format(string,sizeof(string),"Du benötigst mehr Geld für deinen Einsatz (%d) oder Du setzt einen niedrigeren ein.",einsatz);
  157. SendClientMessage(playerid,COLOR_RED,string);
  158. }
  159. }
  160. return 1;
  161. }
  162. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  163. {
  164. return 1;
  165. }
  166.  
  167. public OnPlayerExitVehicle(playerid, vehicleid)
  168. {
  169. return 1;
  170. }
  171.  
  172. public OnPlayerStateChange(playerid, newstate, oldstate)
  173. {
  174. return 1;
  175. }
  176.  
  177. public OnPlayerEnterCheckpoint(playerid)
  178. {
  179. return 1;
  180. }
  181.  
  182. public OnPlayerLeaveCheckpoint(playerid)
  183. {
  184. return 1;
  185. }
  186.  
  187. public OnPlayerEnterRaceCheckpoint(playerid)
  188. {
  189. return 1;
  190. }
  191.  
  192. public OnPlayerLeaveRaceCheckpoint(playerid)
  193. {
  194. return 1;
  195. }
  196.  
  197. public OnRconCommand(cmd[])
  198. {
  199. return 1;
  200. }
  201.  
  202. public OnPlayerRequestSpawn(playerid)
  203. {
  204. return 1;
  205. }
  206.  
  207. public OnObjectMoved(objectid)
  208. {
  209. return 1;
  210. }
  211.  
  212. public OnPlayerObjectMoved(playerid, objectid)
  213. {
  214. return 1;
  215. }
  216.  
  217. public OnPlayerPickUpPickup(playerid, pickupid)
  218. {
  219. return 1;
  220. }
  221.  
  222. public OnVehicleMod(playerid, vehicleid, componentid)
  223. {
  224. return 1;
  225. }
  226.  
  227. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  228. {
  229. return 1;
  230. }
  231.  
  232. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  233. {
  234. return 1;
  235. }
  236.  
  237. public OnPlayerSelectedMenuRow(playerid, row)
  238. {
  239. return 1;
  240. }
  241.  
  242. public OnPlayerExitedMenu(playerid)
  243. {
  244. return 1;
  245. }
  246.  
  247. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  248. {
  249. return 1;
  250. }
  251.  
  252. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  253. {
  254. return 1;
  255. }
  256.  
  257. public OnRconLoginAttempt(ip[], password[], success)
  258. {
  259. return 1;
  260. }
  261.  
  262. public OnPlayerUpdate(playerid)
  263. {
  264. return 1;
  265. }
  266.  
  267. public OnPlayerStreamIn(playerid, forplayerid)
  268. {
  269. return 1;
  270. }
  271.  
  272. public OnPlayerStreamOut(playerid, forplayerid)
  273. {
  274. return 1;
  275. }
  276.  
  277. public OnVehicleStreamIn(vehicleid, forplayerid)
  278. {
  279. return 1;
  280. }
  281.  
  282. public OnVehicleStreamOut(vehicleid, forplayerid)
  283. {
  284. return 1;
  285. }
  286.  
  287. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  288. {
  289. return 1;
  290. }
  291.  
  292. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  293. {
  294. return 1;
  295. }
  296. stock sscanf(string[], format[], {Float,_}:...)
  297. {
  298. #if defined isnull
  299. if (isnull(string))
  300. #else
  301. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  302. #endif
  303. {
  304. return format[0];
  305. }
  306. #pragma tabsize 4
  307. new
  308. formatPos = 0,
  309. stringPos = 0,
  310. paramPos = 2,
  311. paramCount = numargs(),
  312. delim = ' ';
  313. while (string[stringPos] && string[stringPos] <= ' ')
  314. {
  315. stringPos++;
  316. }
  317. while (paramPos < paramCount && string[stringPos])
  318. {
  319. switch (format[formatPos++])
  320. {
  321. case '\0':
  322. {
  323. return 0;
  324. }
  325. case 'i', 'd':
  326. {
  327. new
  328. neg = 1,
  329. num = 0,
  330. ch = string[stringPos];
  331. if (ch == '-')
  332. {
  333. neg = -1;
  334. ch = string[++stringPos];
  335. }
  336. do
  337. {
  338. stringPos++;
  339. if ('0' <= ch <= '9')
  340. {
  341. num = (num * 10) + (ch - '0');
  342. }
  343. else
  344. {
  345. return -1;
  346. }
  347. }
  348. while ((ch = string[stringPos]) > ' ' && ch != delim);
  349. setarg(paramPos, 0, num * neg);
  350. }
  351. case 'h', 'x':
  352. {
  353. new
  354. num = 0,
  355. ch = string[stringPos];
  356. do
  357. {
  358. stringPos++;
  359. switch (ch)
  360. {
  361. case 'x', 'X':
  362. {
  363. num = 0;
  364. continue;
  365. }
  366. case '0' .. '9':
  367. {
  368. num = (num << 4) | (ch - '0');
  369. }
  370. case 'a' .. 'f':
  371. {
  372. num = (num << 4) | (ch - ('a' - 10));
  373. }
  374. case 'A' .. 'F':
  375. {
  376. num = (num << 4) | (ch - ('A' - 10));
  377. }
  378. default:
  379. {
  380. return -1;
  381. }
  382. }
  383. }
  384. while ((ch = string[stringPos]) > ' ' && ch != delim);
  385. setarg(paramPos, 0, num);
  386. }
  387. case 'c':
  388. {
  389. setarg(paramPos, 0, string[stringPos++]);
  390. }
  391. case 'f':
  392. {
  393.  
  394. new changestr[16], changepos = 0, strpos = stringPos;
  395. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  396. {
  397. changestr[changepos++] = string[strpos++];
  398. }
  399. changestr[changepos] = '\0';
  400. setarg(paramPos,0,_:floatstr(changestr));
  401. }
  402. case 'p':
  403. {
  404. delim = format[formatPos++];
  405. continue;
  406. }
  407. case '\'':
  408. {
  409. new
  410. end = formatPos - 1,
  411. ch;
  412. while ((ch = format[++end]) && ch != '\'') {}
  413. if (!ch)
  414. {
  415. return -1;
  416. }
  417. format[end] = '\0';
  418. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  419. {
  420. if (format[end + 1])
  421. {
  422. return -1;
  423. }
  424. return 0;
  425. }
  426. format[end] = '\'';
  427. stringPos = ch + (end - formatPos);
  428. formatPos = end + 1;
  429. }
  430. case 'u':
  431. {
  432. new
  433. end = stringPos - 1,
  434. id = 0,
  435. bool:num = true,
  436. ch;
  437. while ((ch = string[++end]) && ch != delim)
  438. {
  439. if (num)
  440. {
  441. if ('0' <= ch <= '9')
  442. {
  443. id = (id * 10) + (ch - '0');
  444. }
  445. else
  446. {
  447. num = false;
  448. }
  449. }
  450. }
  451. if (num && IsPlayerConnected(id))
  452. {
  453. setarg(paramPos, 0, id);
  454. }
  455. else
  456. {
  457. #if !defined foreach
  458. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  459. #define __SSCANF_FOREACH__
  460. #endif
  461. string[end] = '\0';
  462. num = false;
  463. new
  464. name[MAX_PLAYER_NAME];
  465. id = end - stringPos;
  466. foreach (Player, playerid)
  467. {
  468. GetPlayerName(playerid, name, sizeof (name));
  469. if (!strcmp(name, string[stringPos], true, id))
  470. {
  471. setarg(paramPos, 0, playerid);
  472. num = true;
  473. break;
  474. }
  475. }
  476. if (!num)
  477. {
  478. setarg(paramPos, 0, INVALID_PLAYER_ID);
  479. }
  480. string[end] = ch;
  481. #if defined __SSCANF_FOREACH__
  482. #undef foreach
  483. #undef __SSCANF_FOREACH__
  484. #endif
  485. }
  486. stringPos = end;
  487. }
  488. case 's', 'z':
  489. {
  490. new
  491. i = 0,
  492. ch;
  493. if (format[formatPos])
  494. {
  495. while ((ch = string[stringPos++]) && ch != delim)
  496. {
  497. setarg(paramPos, i++, ch);
  498. }
  499. if (!i)
  500. {
  501. return -1;
  502. }
  503. }
  504. else
  505. {
  506. while ((ch = string[stringPos++]))
  507. {
  508. setarg(paramPos, i++, ch);
  509. }
  510. }
  511. stringPos--;
  512. setarg(paramPos, i, '\0');
  513. }
  514. default:
  515. {
  516. continue;
  517. }
  518. }
  519. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  520. {
  521. stringPos++;
  522. }
  523. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  524. {
  525. stringPos++;
  526. }
  527. paramPos++;
  528. }
  529. do
  530. {
  531. if ((delim = format[formatPos++]) > ' ')
  532. {
  533. if (delim == '\'')
  534. {
  535. while ((delim = format[formatPos++]) && delim != '\'') {}
  536. }
  537. else if (delim != 'z')
  538. {
  539. return delim;
  540. }
  541. }
  542. }
  543. while (delim > ' ');
  544. return 0;
  545. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement