Badyx

[FS] Sistema de trabajos v2

Oct 4th, 2012
444
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.60 KB | None | 0 0
  1. /*
  2. Sistema de trabajos By Badyx
  3.  
  4.  
  5. Fecha: 05/10/2012
  6. Tiempo: 1 hora
  7.  
  8.  
  9. 3 trabajos
  10.  
  11. Repartidor periodicos
  12. Repartidor de mensajeria
  13. Pescador
  14.  
  15. Para www.Pawnoscripting.com
  16.  
  17.  
  18. Caracteristicas V.2.0
  19.  
  20. Ahora se podra mover las posiciones de los trabajos donde se desee
  21.  
  22.  
  23. */
  24.  
  25. #include <a_samp>
  26. #include <streamer>
  27.  
  28. #define funcion%0(%1) \
  29. forward %0(%1); \
  30. public %0(%1)
  31.  
  32. #define Rojo 0xa80707FF
  33. #define Verde 0x1eb032FF
  34. #define PICKUP_RANGE 50
  35. #define MAX_S_PICKUPS 400
  36.  
  37. enum pickupINFO
  38. {
  39. pickupCreated,
  40. pickupVisible,
  41. pickupID,
  42. pickupRange,
  43. Float:pickupX,
  44. Float:pickupY,
  45. Float:pickupZ,
  46. pickupType,
  47. pickupModel
  48. }
  49. new Pickup[MAX_S_PICKUPS+1][pickupINFO];
  50.  
  51.  
  52. enum PosicionRP
  53. {
  54. Float:X,
  55. Float:Y,
  56. Float:Z,
  57. World,
  58. Interior,
  59. Float:Angle,
  60. PickupID,
  61. };
  62. new RepartidorPeriodicos[PosicionRP];
  63.  
  64. enum PosicionRepartidor
  65. {
  66. Float:X,
  67. Float:Y,
  68. Float:Z,
  69. World,
  70. Interior,
  71. Float:Angle,
  72. PickupID,
  73. };
  74. new Repartidor[PosicionRepartidor];
  75.  
  76.  
  77.  
  78.  
  79.  
  80. new Float:PuntosRPeriodicos[3][3] = {
  81. {910.0433,-1795.7535,13.5547},
  82. {923.4427,-1797.1438,13.5469},
  83. {934.5285,-1798.4348,13.7699}
  84. };
  85.  
  86. new Float:PuntosRepartidor[2][3] = {
  87. {1682.2114,-1635.0190,13.6392},
  88. {1804.1008,-2118.6482,13.5543}
  89. };
  90.  
  91. new bool:RepartiendoPeriodicos[MAX_PLAYERS];
  92. new bool:RepartiendoCajas[MAX_PLAYERS];
  93. new bool:EstaPescando[MAX_PLAYERS];
  94.  
  95. funcion OnFilterScriptInit()
  96. {
  97. CargarPosJobRPeriodicos();
  98. CargarPosJobRepartidor();
  99. SetTimer("MostrarInformacion", 1000, 1);
  100. return 1;
  101. }
  102.  
  103. #if defined FILTERSCRIPT
  104.  
  105.  
  106. #else
  107.  
  108. main(){}
  109.  
  110. #endif
  111.  
  112.  
  113. funcion OnPlayerConnect(playerid)
  114. {
  115. RepartiendoPeriodicos[playerid] = false;
  116. RepartiendoCajas[playerid] = false;
  117. EstaPescando[playerid] = false;
  118. return 1;
  119. }
  120.  
  121. funcion OnPlayerDisconnect(playerid, reason)
  122. {
  123. RepartiendoPeriodicos[playerid] = false;
  124. RepartiendoCajas[playerid] = false;
  125. EstaPescando[playerid] = false;
  126. return 1;
  127. }
  128.  
  129.  
  130. funcion OnPlayerCommandText(playerid, cmdtext[])
  131. {
  132.  
  133. /* Repartidor de periodicos */
  134.  
  135. if (strcmp("/RepartirPeriodicos", cmdtext, true, 10) == 0)
  136. {
  137. if (RepartiendoPeriodicos[playerid] == false)
  138. {
  139. if(EsBicicleta(GetPlayerVehicleID(playerid)))
  140. {
  141. if(IsPlayerInAnyVehicle(playerid))
  142. {
  143. SendClientMessage(playerid,Verde,"Repartiendo periodicos...");
  144. SendClientMessage(playerid,Verde,"Dirigete a los checkpoints (puntos rojos).");
  145. RepartiendoPeriodicos[playerid] = true;
  146. new randomize;
  147. randomize = random(sizeof(PuntosRPeriodicos));
  148. SetPlayerCheckpoint(playerid, PuntosRPeriodicos[randomize][0], PuntosRPeriodicos[randomize][1], PuntosRPeriodicos[randomize][2], 5.0);
  149. return 1;
  150. }
  151. return SendClientMessage(playerid,Rojo,"[Error] No estas en un coche!");
  152. }
  153. return SendClientMessage(playerid,Rojo,"[Error] Necesita estar en una bicicleta para usar este comando!");
  154. }
  155. return SendClientMessage(playerid,Rojo,"[Error] Usted ya esta repartiendo periodicos!");
  156. }
  157.  
  158. if (strcmp("/dRepartirPeriodicos", cmdtext, true, 10) == 0)
  159. {
  160. if (RepartiendoPeriodicos[playerid] == true)
  161. {
  162. SendClientMessage(playerid,Verde,"Dejaste de repartir periodicos.");
  163. RepartiendoPeriodicos[playerid] = false;
  164. DisablePlayerRaceCheckpoint(playerid);
  165. return 1;
  166. }
  167. return SendClientMessage(playerid,Rojo,"[Error] Usted no esta repartiendo periodicos!");
  168. }
  169.  
  170.  
  171. /* Repartidor */
  172.  
  173. if (strcmp("/Repartir", cmdtext, true, 10) == 0)
  174. {
  175. if (RepartiendoCajas[playerid] == false)
  176. {
  177. if(IsPlayerInAnyVehicle(playerid))
  178. {
  179. SendClientMessage(playerid,Verde,"Repariendo...");
  180. SendClientMessage(playerid,Verde,"Dirigete a los checkpoints (puntos rojos).");
  181. new randomize;
  182. randomize = random(sizeof(PuntosRPeriodicos));
  183. SetPlayerCheckpoint(playerid, PuntosRepartidor[randomize][0], PuntosRepartidor[randomize][1], PuntosRepartidor[randomize][2], 5.0);
  184. RepartiendoCajas[playerid] = true;
  185. return 1;
  186. }
  187. return SendClientMessage(playerid,Rojo,"[Error] No estas en un coche!");
  188. }
  189. return SendClientMessage(playerid,Rojo,"[Error] Usted ya esta repartiendo!");
  190. }
  191.  
  192. if (strcmp("/dRepartir", cmdtext, true, 10) == 0)
  193. {
  194. if (RepartiendoCajas[playerid] == true)
  195. {
  196. SendClientMessage(playerid,Verde,"Dejaste de repartir.");
  197. RepartiendoCajas[playerid] = false;
  198. DisablePlayerRaceCheckpoint(playerid);
  199. return 1;
  200. }
  201. return SendClientMessage(playerid,Rojo,"[Error] Usted no esta repartiendo!");
  202. }
  203.  
  204. /* Pescador */
  205.  
  206. if (strcmp("/Pescar", cmdtext, true, 10) == 0)
  207. {
  208. if (EstaPescando[playerid] == false)
  209. {
  210. if(EstaEnZonaPesca(playerid))
  211. {
  212. SendClientMessage(playerid,Verde,"Pescando...");
  213. EstaPescando[playerid] = true;
  214. SetTimerEx("Pescando", 5000, 0, "d", playerid);
  215. return 1;
  216. }
  217. return SendClientMessage(playerid,Rojo,"[Error] No estas en el muelle!");
  218. }
  219. return SendClientMessage(playerid,Rojo,"[Error] Usted no esta pescando!");
  220. }
  221.  
  222. if (strcmp("/dPescar", cmdtext, true, 10) == 0)
  223. {
  224. if (EstaPescando[playerid] == true)
  225. {
  226. SendClientMessage(playerid,Verde,"Dejaste de pescar.");
  227. EstaPescando[playerid] = false;
  228. DisablePlayerRaceCheckpoint(playerid);
  229. return 1;
  230. }
  231. return SendClientMessage(playerid,Rojo,"[Error] Usted no esta pescando!");
  232. }
  233.  
  234. if (strcmp("/Ayudame", cmdtext, true, 10) == 0)
  235. {
  236. new Mensajeayuda[600];
  237. format(Mensajeayuda, sizeof(Mensajeayuda),
  238. "{00F50A}|____________________Sistema de trabajos Badyx____________________| {F0F0F0}\n");
  239. strcat(Mensajeayuda, "{F5FF00}\n\n[Repartidor de periodicos] Use /RepartirPeriodicos para empezar a repartir\nUse /DrepartirPeriodicos para dejar de repartir\n[Info] Tendras que estar en una bicicleta e ir a los puntos marcados\n\n");
  240. strcat(Mensajeayuda, "{F5FF00}\n\n[Repartidos] Use /Repartir para empezar a repartir\nUse /Drepartir para dejar de repartir\n[Info] No se requiere nada en especial\n\n");
  241. strcat(Mensajeayuda, "{F5FF00}\n\n[Pescador] Use /Pescar para lanzar su caña\nUse /dPescar para dejar de pescar\n[Info] Se requiere estar en el puerto\n\n");
  242. ShowPlayerDialog(playerid, 999, DIALOG_STYLE_MSGBOX, "{00A5FF}Ayuda Trabajos.", Mensajeayuda, "Aceptar", "");
  243. return 1;
  244. }
  245.  
  246. if (strcmp("/CPosicionRPeriodico", cmdtext, true, 10) == 0)
  247. {
  248. if(IsPlayerAdmin(playerid))
  249. {
  250. new Float:x,Float:y,Float:z;
  251. GetPlayerPos(playerid, x, y, z);
  252. new Float:angle;
  253. GetPlayerFacingAngle(playerid, angle);
  254. RepartidorPeriodicos[X] = x;
  255. RepartidorPeriodicos[Y] = y;
  256. RepartidorPeriodicos[Z] = z;
  257. RepartidorPeriodicos[World] = GetPlayerVirtualWorld(playerid);
  258. RepartidorPeriodicos[Interior] = GetPlayerInterior(playerid);
  259. RepartidorPeriodicos[Angle] = angle;
  260. MoveStreamPickup(RepartidorPeriodicos[PickupID],RepartidorPeriodicos[X],RepartidorPeriodicos[Y],RepartidorPeriodicos[Z]);
  261. GuardarPosJobRPeriodicos();
  262. SendClientMessage(playerid, Verde, "[Info] Cambiaste correctamente la posicion del trabajo de repartidor de periodicos");
  263. return 1;
  264. }
  265. return SendClientMessage(playerid,Rojo,"[Error] Se requiere que usted este logeado con rcon");
  266. }
  267. if (strcmp("/CPosicionRepartidor", cmdtext, true, 10) == 0)
  268. {
  269. if(IsPlayerAdmin(playerid))
  270. {
  271. new Float:x,Float:y,Float:z;
  272. GetPlayerPos(playerid, x, y, z);
  273. new Float:angle;
  274. GetPlayerFacingAngle(playerid, angle);
  275. Repartidor[X] = x;
  276. Repartidor[Y] = y;
  277. Repartidor[Z] = z;
  278. Repartidor[World] = GetPlayerVirtualWorld(playerid);
  279. Repartidor[Interior] = GetPlayerInterior(playerid);
  280. Repartidor[Angle] = angle;
  281. MoveStreamPickup(Repartidor[PickupID],Repartidor[X],Repartidor[Y],Repartidor[Z]);
  282. GuardarPosJobRepartidor();
  283. SendClientMessage(playerid, Verde, "[Info] Cambiaste correctamente la posicion del trabajo de repartidor");
  284. return 1;
  285. }
  286. return SendClientMessage(playerid,Rojo,"[Error] Se requiere que usted este logeado con rcon");
  287. }
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294. return 0;
  295. }
  296.  
  297. funcion Pescando(playerid)
  298. {
  299. new RandomPesca = random(11);
  300. switch(RandomPesca)
  301. {
  302. case 0: {SendClientMessage(playerid,Rojo,"[Error] El hilo de tu caña se a roto!");return 1;}
  303. case 1: {SendClientMessage(playerid,Verde,"Encontraste un calcetin con 100 de dinero"); GivePlayerMoney(playerid, 100);return 1;}
  304. case 2: {SendClientMessage(playerid,Verde,"Encontraste un calcetin con 20 de dinero"); GivePlayerMoney(playerid, 100);return 1;}
  305. case 3: {SendClientMessage(playerid,Verde,"Pescaste un atun y lo vendiste por 10 de dinero");GivePlayerMoney(playerid, 10);return 1;}
  306. case 4: {SendClientMessage(playerid,Rojo,"[Error] El hilo de tu caña se a roto!");return 1;}
  307. case 5: {SendClientMessage(playerid,Verde,"Pescaste un pulpo y lo vendiste por 20 de dinero");GivePlayerMoney(playerid, 20);return 1;}
  308. case 6: {SendClientMessage(playerid,Verde,"Pescaste una sardina y lo vendiste por 1 de dinero");GivePlayerMoney(playerid, 1);return 1;}
  309. case 7: {SendClientMessage(playerid,Rojo,"[Error] El hilo de tu caña se a roto!");return 1;}
  310. case 8: {SendClientMessage(playerid,Verde,"Encontraste un calcetin con 50 de dinero"); GivePlayerMoney(playerid, 100);return 1;}
  311. case 9: {SendClientMessage(playerid,Rojo,"[Error] El hilo de tu caña se a roto!");return 1;}
  312. case 10: {SendClientMessage(playerid,Rojo,"[Error] El hilo de tu caña se a roto!");return 1;}
  313. }
  314. return 1;
  315. }
  316.  
  317.  
  318. funcion EsBicicleta(vehicleid)
  319. {
  320. new model = GetVehicleModel(vehicleid);
  321. if(model == 481 || model == 509 || model == 510)
  322. {
  323. return 1;
  324. }
  325. return 0;
  326. }
  327.  
  328. funcion OnPlayerEnterCheckpoint(playerid)
  329. {
  330. new string[30];
  331. new Pasta = random(20), randomize;
  332. if (RepartiendoPeriodicos[playerid] == true)
  333. {
  334. if(EsBicicleta(GetPlayerVehicleID(playerid)))
  335. {
  336. PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
  337. format(string, sizeof(string), "~w~Te pagaron~n~~g~$%d",Pasta);
  338. GameTextForPlayer(playerid, string, 5000, 1);
  339. GivePlayerMoney(playerid, Pasta);
  340. randomize = random(sizeof(PuntosRPeriodicos));
  341. SetPlayerCheckpoint(playerid, PuntosRPeriodicos[randomize][0], PuntosRPeriodicos[randomize][1], PuntosRPeriodicos[randomize][2], 5.0);
  342. }
  343. return 1;
  344. }
  345.  
  346. if (RepartiendoCajas[playerid] == true)
  347. {
  348. PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
  349. format(string, sizeof(string), "~w~Te pagaron~n~~g~$%d",Pasta);
  350. GameTextForPlayer(playerid, string, 5000, 1);
  351. GivePlayerMoney(playerid, Pasta);
  352. randomize = random(sizeof(PuntosRepartidor));
  353. SetPlayerCheckpoint(playerid, PuntosRepartidor[randomize][0], PuntosRepartidor[randomize][1], PuntosRepartidor[randomize][2], 5.0);
  354. return 1;
  355. }
  356. return 1;
  357. }
  358.  
  359. funcion EstaEnZonaPesca(playerid)
  360. {
  361. if(IsPlayerConnected(playerid))
  362. {
  363. if(IsPlayerInRangeOfPoint(playerid,2,403.8346,-2088.3628,7.8359) || IsPlayerInRangeOfPoint(playerid,2,398.6683,-2088.4817,7.8359))
  364. {
  365. return 1;
  366. }
  367. else if(IsPlayerInRangeOfPoint(playerid,2,396.0295,-2088.3022,7.8359) || IsPlayerInRangeOfPoint(playerid,2,391.0287,-2088.2808,7.8359))
  368. {
  369. return 1;
  370. }
  371. else if(IsPlayerInRangeOfPoint(playerid,2,383.2155,-2088.3271,7.8359) || IsPlayerInRangeOfPoint(playerid,2,375.0619,-2088.2026,7.8359))
  372. {
  373. return 1;
  374. }
  375. else if(IsPlayerInRangeOfPoint(playerid,2,369.8253,-2088.4463,7.8359) || IsPlayerInRangeOfPoint(playerid,2,367.2083,-2088.3237,7.8359))
  376. {
  377. return 1;
  378. }
  379. else if(IsPlayerInRangeOfPoint(playerid,2,362.1855,-2088.4866,7.8359) || IsPlayerInRangeOfPoint(playerid,2,354.4520,-2088.3418,7.8359))
  380. {
  381. return 1;
  382. }
  383. }
  384. return 0;
  385. }
  386.  
  387.  
  388. funcion CargarPosJobRPeriodicos()
  389. {
  390. new arrCoords[7][64];
  391. new strFromFile2[256];
  392. new File: file = fopen("Trabajos/RepartidorPeriodicos.cfg", io_read);
  393. if (file)
  394. {
  395. fread(file, strFromFile2);
  396. split(strFromFile2, arrCoords, '|');
  397. RepartidorPeriodicos[X] = floatstr(arrCoords[0]);
  398. RepartidorPeriodicos[Y] = floatstr(arrCoords[1]);
  399. RepartidorPeriodicos[Z] = floatstr(arrCoords[2]);
  400. RepartidorPeriodicos[World] = strval(arrCoords[3]);
  401. RepartidorPeriodicos[Interior] = strval(arrCoords[4]);
  402. RepartidorPeriodicos[Angle] = floatstr(arrCoords[5]);
  403. RepartidorPeriodicos[PickupID] = strval(arrCoords[6]);
  404. RepartidorPeriodicos[PickupID] = CreateStreamPickup(1239,1,RepartidorPeriodicos[X],RepartidorPeriodicos[Y],RepartidorPeriodicos[Z],PICKUP_RANGE);
  405. print("[Info] Posicion de trabajo de repartidor periodicos cargada");
  406. }
  407. fclose(file);
  408. return 1;
  409. }
  410.  
  411. funcion GuardarPosJobRPeriodicos()
  412. {
  413. new File: file2;
  414. new coordsstring[512];
  415. format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%f|%d\n",
  416. RepartidorPeriodicos[X],
  417. RepartidorPeriodicos[Y],
  418. RepartidorPeriodicos[Z],
  419. RepartidorPeriodicos[World],
  420. RepartidorPeriodicos[Interior],
  421. RepartidorPeriodicos[Angle],
  422. RepartidorPeriodicos[PickupID]);
  423. file2 = fopen("Trabajos/RepartidorPeriodicos.cfg", io_write);
  424. fwrite(file2, coordsstring);
  425. fclose(file2);
  426. return 1;
  427. }
  428.  
  429. funcion CargarPosJobRepartidor()
  430. {
  431. new arrCoords[7][64];
  432. new strFromFile2[256];
  433. new File: file = fopen("Trabajos/Repartidor.cfg", io_read);
  434. if (file)
  435. {
  436. fread(file, strFromFile2);
  437. split(strFromFile2, arrCoords, '|');
  438. Repartidor[X] = floatstr(arrCoords[0]);
  439. Repartidor[Y] = floatstr(arrCoords[1]);
  440. Repartidor[Z] = floatstr(arrCoords[2]);
  441. Repartidor[World] = strval(arrCoords[3]);
  442. Repartidor[Interior] = strval(arrCoords[4]);
  443. Repartidor[Angle] = floatstr(arrCoords[5]);
  444. Repartidor[PickupID] = strval(arrCoords[6]);
  445. Repartidor[PickupID] = CreateStreamPickup(1239,1,Repartidor[X],Repartidor[Y],Repartidor[Z],PICKUP_RANGE);
  446. print("[Info] Posicion de trabajo de repartidor cargada");
  447. }
  448. fclose(file);
  449. return 1;
  450. }
  451.  
  452. funcion GuardarPosJobRepartidor()
  453. {
  454. new File: file2;
  455. new coordsstring[512];
  456. format(coordsstring, sizeof(coordsstring), "%f|%f|%f|%d|%d|%f|%d\n",
  457. Repartidor[X],
  458. Repartidor[Y],
  459. Repartidor[Z],
  460. Repartidor[World],
  461. Repartidor[Interior],
  462. Repartidor[Angle],
  463. Repartidor[PickupID]);
  464. file2 = fopen("Trabajos/Repartidor.cfg", io_write);
  465. fwrite(file2, coordsstring);
  466. fclose(file2);
  467. return 1;
  468. }
  469.  
  470. funcion CreateStreamPickup(model,type,Float:x,Float:y,Float:z,range)
  471. {
  472. new FoundID = 0;
  473. new ID;
  474.  
  475. for ( new i = 0; FoundID <= 0 ; i++)
  476. {
  477. if( Pickup[i][pickupCreated] == 0 )
  478. {
  479. if( FoundID == 0 )
  480. {
  481. ID = i;
  482. FoundID = 1;
  483. }
  484. }
  485. if( i > MAX_S_PICKUPS )
  486. {
  487. FoundID = 2;
  488. }
  489. }
  490. if( FoundID == 2 )
  491. {
  492. print("[Error] Maximo de Pickups excedidos. El pickup no fue creado");
  493. return -1;
  494. }
  495. Pickup[ID][pickupCreated] = 1;
  496. Pickup[ID][pickupVisible] = 0;
  497. Pickup[ID][pickupModel] = model;
  498. Pickup[ID][pickupType] = type;
  499. Pickup[ID][pickupX] = x;
  500. Pickup[ID][pickupY] = y;
  501. Pickup[ID][pickupZ] = z;
  502. Pickup[ID][pickupRange] = range;
  503. return ID;
  504.  
  505. }
  506.  
  507. funcion split(const strsrc[], strdest[][], delimiter)
  508. {
  509. new i, li;
  510. new aNum;
  511. new len;
  512. while(i <= strlen(strsrc)){
  513. if(strsrc[i]==delimiter || i==strlen(strsrc)){
  514. len = strmid(strdest[aNum], strsrc, li, i, 128);
  515. strdest[aNum][len] = 0;
  516. li = i+1;
  517. aNum++;
  518. }
  519. i++;
  520. }
  521. return 1;
  522. }
  523.  
  524.  
  525. funcion MoveStreamPickup(ID,Float:x,Float:y,Float:z)
  526. {
  527. if(Pickup[ID][pickupCreated])
  528. {
  529. DestroyPickup(Pickup[ID][pickupID]);
  530. Pickup[ID][pickupVisible] = 0;
  531. Pickup[ID][pickupX] = x;
  532. Pickup[ID][pickupY] = y;
  533. Pickup[ID][pickupZ] = z;
  534. return 1;
  535. }
  536. return 0;
  537. }
  538.  
  539. funcion MostrarInformacion()
  540. {
  541. for(new i = 0; i < MAX_PLAYERS; i++)
  542. {
  543. if(IsPlayerInRangeOfPoint(i,1.0,RepartidorPeriodicos[X],RepartidorPeriodicos[Y],RepartidorPeriodicos[Z]))
  544. {
  545. if(GetPlayerVirtualWorld(i) == RepartidorPeriodicos[World])
  546. {
  547. GameTextForPlayer(i, "Aqui podras trabajar como repartidor de periodicos", 5000, 1);
  548. }
  549. }
  550. else if(IsPlayerInRangeOfPoint(i,1.0,Repartidor[X],Repartidor[Y],Repartidor[Z]))
  551. {
  552. if(GetPlayerVirtualWorld(i) == Repartidor[World])
  553. {
  554. GameTextForPlayer(i, "Aqui podras trabajar como repartidor", 5000, 1);
  555. }
  556. }
  557. }
  558. return 1;
  559. }
  560.  
  561. //============================================================================//
  562. // //
  563. // FINAL DEL SCRIPT //
  564. // //
  565. // SI TE SIRVIO RESPETA EL TRABAJO DEL CREADOR //
  566. // //
  567. //============================================================================//
Advertisement
Add Comment
Please, Sign In to add comment