Guest User

Untitled

a guest
Jun 1st, 2012
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.70 KB | None | 0 0
  1. #include <a_samp>
  2. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  3.  
  4. ////////////////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////////////////
  6. ////////////////////////////////////////////////////////////////////////////////
  7. ////////////////////////////////////////////////////////////////////////////////
  8. ////////////////////////////////////////////////////////////////////////////////
  9. ////////////////////////////////////////////////////////////////////////////////
  10. ///////////////////////////EINSTELLUNGEN////////////////////////////////////////
  11.  
  12. #define MAX_TAXIS 5 // Anzahl der Taxis
  13. #define TAXI_ID 420 // Fahrzeug Typ
  14. #define PAY_TIME 5 // Abstand in dem Geld abgezogen wird (Sekunden)
  15. #define TAXI_SKIN 0 // Welcher Skin ist Taxifahrer (0: CJ-Standart Skin)
  16.  
  17. new script_taxi[MAX_TAXIS];
  18. stock CreateTaxis() // Taxis erstellen, MAX_TAXIS muss mit der Anzahl der CreateVehicle übereinstimmen
  19. {
  20. script_taxi[0]=CreateVehicle(TAXI_ID,2040.6560,1348.6108,10.6719,132.2145,-1,-1,-1);
  21. script_taxi[1]=CreateVehicle(TAXI_ID,2040.2594,1341.1702,10.6719,135.3479,-1,-1,-1);
  22. script_taxi[2]=CreateVehicle(TAXI_ID,2040.5894,1332.7135,10.6719,134.4079,-1,-1,-1);
  23. script_taxi[3]=CreateVehicle(TAXI_ID,2040.9341,1325.4912,10.6719,136.6012,-1,-1,-1);
  24. script_taxi[4]=CreateVehicle(TAXI_ID,2040.6262,1316.5095,10.6719,131.9012,-1,-1,-1);
  25. return 1;
  26. }
  27.  
  28. /******Made by GPawn-Growen******/
  29. /******Kosten: 5 EUR*************/
  30. /******Datum: 27.05.2012*********/
  31.  
  32. ////////////////////////////////////////////////////////////////////////////////
  33. ////////////////////////////////////////////////////////////////////////////////
  34. ////////////////////////////////////////////////////////////////////////////////
  35. ////////////////////////////////////////////////////////////////////////////////
  36. ////////////////////////////////////////////////////////////////////////////////
  37. ////////////////////////////////////////////////////////////////////////////////
  38.  
  39. #define color_info 0xFFFFFFFF
  40. #define color_rot 0xAA3333AA
  41. #define color_gruen 0x33AA33AA
  42. new player_preis[MAX_PLAYERS];
  43. new player_taxi[MAX_PLAYERS];
  44. new pay_taxi[MAX_PLAYERS];
  45. new payed[MAX_PLAYERS];
  46. forward check_taxi(playerid,fahrerid,kosten);
  47.  
  48. public OnFilterScriptInit()
  49. {
  50. CreateTaxis();
  51. return 1;
  52. }
  53.  
  54. public OnFilterScriptExit()
  55. {
  56. for(new v=0;v<MAX_TAXIS;v++)
  57. {
  58. DestroyVehicle(script_taxi[v]);
  59. }
  60. return 1;
  61. }
  62.  
  63. public OnPlayerConnect(playerid)
  64. {
  65. payed[playerid]=0;
  66. player_preis[playerid]=0;
  67. player_taxi[playerid]=0;
  68. return 1;
  69. }
  70.  
  71. public OnPlayerCommandText(playerid, cmdtext[])
  72. {
  73. dcmd(fahre,5,cmdtext);
  74. return 0;
  75. }
  76.  
  77. dcmd_fahre(playerid,params[])
  78. {
  79. if(GetPlayerSkin(playerid) != TAXI_SKIN) return SendClientMessage(playerid, color_info, "FEHLER: Du bist kein Taxifahrer!");
  80. new preis,say[80];
  81. if(sscanf(params, "d",preis)) return SendClientMessage(playerid, color_info,"BENUTZE: /fahre [PREIS]");
  82. else if(preis > 200 || preis < 1) return SendClientMessage(playerid, color_info, "FEHLER: Preis muss zwischen 1 und 200 EUR liegen!");
  83. else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, color_info, "FEHLER: Du darfst nicht in einem Fahrzeug sitzen!");
  84. player_preis[playerid]=preis;
  85. format(say,sizeof say,"TAXI: %s ist mit dem Taxi unterwegs, Kosten pro KM: %d",NAME(playerid),player_preis[playerid]);
  86. SendClientMessageToAll(color_gruen,say);
  87. return 1;
  88. }
  89.  
  90. public OnPlayerStateChange(playerid, newstate, oldstate)
  91. {
  92.  
  93. if(newstate == PLAYER_STATE_DRIVER && GetPlayerSkin(playerid) == TAXI_SKIN)
  94. {
  95. new xx = GetVehicleModel(GetPlayerVehicleID(playerid));
  96. if(xx == TAXI_ID)
  97. {
  98. player_taxi[playerid]=GetPlayerVehicleID(playerid);
  99. }
  100. }
  101. else if(newstate == PLAYER_STATE_PASSENGER)
  102. {
  103. new xx = GetVehicleModel(GetPlayerVehicleID(playerid));
  104. if(xx == TAXI_ID)
  105. {
  106. for(new i=0;i<MAX_PLAYERS;i++)
  107. {
  108. if(i != playerid)
  109. {
  110. if(GetPlayerVehicleID(playerid) == player_taxi[i])
  111. {
  112. return pay_taxi[playerid]=SetTimerEx("check_taxi",PAY_TIME*1000,1,"ddd",playerid,i,player_preis[i]);
  113. }
  114. }
  115. }
  116. }
  117. }
  118. if(oldstate == PLAYER_STATE_PASSENGER || oldstate == PLAYER_STATE_DRIVER )
  119. {
  120. player_taxi[playerid]=0;
  121. payed[playerid]=0;
  122. return KillTimer(pay_taxi[playerid]);
  123. }
  124. return 1;
  125. }
  126.  
  127. public check_taxi(playerid,fahrerid,kosten)
  128. {
  129. new say[50];
  130. payed[playerid]+=kosten;
  131. format(say,sizeof say,"~r~Kosten: ~w~%d EUR",payed[playerid]);
  132. GameTextForPlayer(playerid, say, PAY_TIME*1010, 4);
  133. format(say,sizeof say,"~g~Gehalt: ~w~%d EUR",payed[playerid]);
  134. GameTextForPlayer(fahrerid, say, PAY_TIME*1010, 4);
  135. GivePlayerMoney(playerid,-kosten);
  136. GivePlayerMoney(fahrerid,kosten);
  137. return 1;
  138. }
  139.  
  140. stock NAME(playerid)
  141. {
  142. new spname[128];
  143. GetPlayerName(playerid,spname,sizeof(spname));
  144. return spname;
  145. }
  146.  
  147. stock sscanf(string[], format[], {Float,_}:...)
  148. {
  149. #if defined isnull
  150. if (isnull(string))
  151. #else
  152. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  153. #endif
  154. {
  155. return format[0];
  156. }
  157. #pragma tabsize 4
  158. new
  159. formatPos = 0,
  160. stringPos = 0,
  161. paramPos = 2,
  162. paramCount = numargs(),
  163. delim = ' ';
  164. while (string[stringPos] && string[stringPos] <= ' ')
  165. {
  166. stringPos++;
  167. }
  168. while (paramPos < paramCount && string[stringPos])
  169. {
  170. switch (format[formatPos++])
  171. {
  172. case '\0':
  173. {
  174. return 0;
  175. }
  176. case 'i', 'd':
  177. {
  178. new
  179. neg = 1,
  180. num = 0,
  181. ch = string[stringPos];
  182. if (ch == '-')
  183. {
  184. neg = -1;
  185. ch = string[++stringPos];
  186. }
  187. do
  188. {
  189. stringPos++;
  190. if ('0' <= ch <= '9')
  191. {
  192. num = (num * 10) + (ch - '0');
  193. }
  194. else
  195. {
  196. return -1;
  197. }
  198. }
  199. while ((ch = string[stringPos]) > ' ' && ch != delim);
  200. setarg(paramPos, 0, num * neg);
  201. }
  202. case 'h', 'x':
  203. {
  204. new
  205. num = 0,
  206. ch = string[stringPos];
  207. do
  208. {
  209. stringPos++;
  210. switch (ch)
  211. {
  212. case 'x', 'X':
  213. {
  214. num = 0;
  215. continue;
  216. }
  217. case '0' .. '9':
  218. {
  219. num = (num << 4) | (ch - '0');
  220. }
  221. case 'a' .. 'f':
  222. {
  223. num = (num << 4) | (ch - ('a' - 10));
  224. }
  225. case 'A' .. 'F':
  226. {
  227. num = (num << 4) | (ch - ('A' - 10));
  228. }
  229. default:
  230. {
  231. return -1;
  232. }
  233. }
  234. }
  235. while ((ch = string[stringPos]) > ' ' && ch != delim);
  236. setarg(paramPos, 0, num);
  237. }
  238. case 'c':
  239. {
  240. setarg(paramPos, 0, string[stringPos++]);
  241. }
  242. case 'f':
  243. {
  244.  
  245. new changestr[16], changepos = 0, strpos = stringPos;
  246. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  247. {
  248. changestr[changepos++] = string[strpos++];
  249. }
  250. changestr[changepos] = '\0';
  251. setarg(paramPos,0,_:floatstr(changestr));
  252. }
  253. case 'p':
  254. {
  255. delim = format[formatPos++];
  256. continue;
  257. }
  258. case '\'':
  259. {
  260. new
  261. end = formatPos - 1,
  262. ch;
  263. while ((ch = format[++end]) && ch != '\'') {}
  264. if (!ch)
  265. {
  266. return -1;
  267. }
  268. format[end] = '\0';
  269. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  270. {
  271. if (format[end + 1])
  272. {
  273. return -1;
  274. }
  275. return 0;
  276. }
  277. format[end] = '\'';
  278. stringPos = ch + (end - formatPos);
  279. formatPos = end + 1;
  280. }
  281. case 'u':
  282. {
  283. new
  284. end = stringPos - 1,
  285. id = 0,
  286. bool:num = true,
  287. ch;
  288. while ((ch = string[++end]) && ch != delim)
  289. {
  290. if (num)
  291. {
  292. if ('0' <= ch <= '9')
  293. {
  294. id = (id * 10) + (ch - '0');
  295. }
  296. else
  297. {
  298. num = false;
  299. }
  300. }
  301. }
  302. if (num && IsPlayerConnected(id))
  303. {
  304. setarg(paramPos, 0, id);
  305. }
  306. else
  307. {
  308. #if !defined foreach
  309. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  310. #define __SSCANF_FOREACH__
  311. #endif
  312. string[end] = '\0';
  313. num = false;
  314. new
  315. name[MAX_PLAYER_NAME];
  316. id = end - stringPos;
  317. foreach (Player, playerid)
  318. {
  319. GetPlayerName(playerid, name, sizeof (name));
  320. if (!strcmp(name, string[stringPos], true, id))
  321. {
  322. setarg(paramPos, 0, playerid);
  323. num = true;
  324. break;
  325. }
  326. }
  327. if (!num)
  328. {
  329. setarg(paramPos, 0, INVALID_PLAYER_ID);
  330. }
  331. string[end] = ch;
  332. #if defined __SSCANF_FOREACH__
  333. #undef foreach
  334. #undef __SSCANF_FOREACH__
  335. #endif
  336. }
  337. stringPos = end;
  338. }
  339. case 's', 'z':
  340. {
  341. new
  342. i = 0,
  343. ch;
  344. if (format[formatPos])
  345. {
  346. while ((ch = string[stringPos++]) && ch != delim)
  347. {
  348. setarg(paramPos, i++, ch);
  349. }
  350. if (!i)
  351. {
  352. return -1;
  353. }
  354. }
  355. else
  356. {
  357. while ((ch = string[stringPos++]))
  358. {
  359. setarg(paramPos, i++, ch);
  360. }
  361. }
  362. stringPos--;
  363. setarg(paramPos, i, '\0');
  364. }
  365. default:
  366. {
  367. continue;
  368. }
  369. }
  370. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  371. {
  372. stringPos++;
  373. }
  374. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  375. {
  376. stringPos++;
  377. }
  378. paramPos++;
  379. }
  380. do
  381. {
  382. if ((delim = format[formatPos++]) > ' ')
  383. {
  384. if (delim == '\'')
  385. {
  386. while ((delim = format[formatPos++]) && delim != '\'') {}
  387. }
  388. else if (delim != 'z')
  389. {
  390. return delim;
  391. }
  392. }
  393. }
  394. while (delim > ' ');
  395. return 0;
  396. }
Advertisement
Add Comment
Please, Sign In to add comment