Advertisement
Guest User

InGame Job Maker by Mr.Gagi

a guest
Mar 24th, 2012
5,058
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.04 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <sscanf2>
  4. #include <YSI/y_ini>
  5. #include <YSI\y_commands>
  6. #include <streamer>
  7. #pragma tabsize 0
  8.  
  9. #define SCM SendClientMessage
  10. #define COLOR_RED 0xD62F4E
  11. #define COL_LIGHTBLUE "{1BD3E0}"
  12. #define COL_RED "{D62F4E}"
  13. #define COL_ORANGE "{E09B1B}"
  14. #define COL_WHITE "{FFFFFF}"
  15. #define DIALOG_JOB 1093
  16. #define JOB_FILE "Jobs/%d.ini"
  17. #define Player_File "Jobs/Player/%s.ini"
  18. #define MAX_JOBS 20
  19. #define MAX_CP 20
  20. new bool:False = false, _S_T_R_[128];
  21. #define SendFormatMSG(%0,%1,%2,%3)\
  22. do{\
  23. format(_S_T_R_, sizeof (_S_T_R_), (%2), %3);\
  24. SendClientMessage((%0),(%1), _S_T_R_);\
  25. }\
  26. while (False)
  27. #define randomEx(%0,%1) (random((%1) - (%0)) + (%0))
  28.  
  29. new
  30. JobName[MAX_PLAYERS][64],
  31. JobCP[MAX_PLAYERS],
  32. JobID[MAX_PLAYERS],
  33. PlayerCP[MAX_PLAYERS],
  34. JobVehID[MAX_PLAYERS],
  35. PlayerVeh[MAX_PLAYERS],
  36. bool:PlayerWork[MAX_PLAYERS],
  37. JobChoose[MAX_PLAYERS],
  38. JobMin[MAX_PLAYERS],
  39. JobMax[MAX_PLAYERS],
  40. bool:PlayerCreateJob[MAX_PLAYERS],
  41. bool:JobOnCP[MAX_PLAYERS],
  42. Seller[MAX_PLAYERS],
  43. Price[MAX_PLAYERS];
  44.  
  45. enum info
  46. {
  47. pJob,
  48. }
  49. new P_Data[MAX_PLAYERS][info];
  50.  
  51. enum jo
  52. {
  53. Float:TCPX,
  54. Float:TCPY,
  55. Float:TCPZ,
  56. Name[64],
  57. VehID,
  58. Choosed,
  59. Min,
  60. Max,
  61. Pickup,
  62. Text3D:Label
  63. }
  64. new Job[MAX_JOBS][jo];
  65.  
  66. enum jobs
  67. {
  68. Float:CPX,
  69. Float:CPY,
  70. Float:CPZ,
  71. }
  72. new CheckPoint[MAX_JOBS][MAX_CP][jobs];
  73.  
  74. public OnFilterScriptInit()
  75. {
  76. print("\n--------------------------------------");
  77. print(" InGame Job Maker by: Mr.Gagi (Gagi_Corleone)");
  78. print("--------------------------------------\n");
  79.  
  80. for(new i = 1; i<=MAX_JOBS;i++)
  81. {
  82. new gFile[35],string[128];
  83. format(gFile, 35, JOB_FILE ,i);
  84. INI_ParseFile(gFile, "LoadJobs", .bExtra = true, .extra = i);
  85. Job[i][Pickup] = CreateDynamicPickup(1239, 23, Job[i][TCPX],Job[i][TCPY],Job[i][TCPZ],-1,-1,-1,100.0);
  86. format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[i][Name]);
  87. Job[i][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[i][TCPX],Job[i][TCPY],Job[i][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
  88. }
  89. return 1;
  90. }
  91.  
  92. public OnFilterScriptExit()
  93. {
  94. return 1;
  95. }
  96. main()
  97. {
  98. print("\n----------------------------------");
  99. print(" InGame Job Maker by: Mr.Gagi (Gagi_Corleone)");
  100. print("----------------------------------\n");
  101. }
  102.  
  103.  
  104. public OnGameModeInit()
  105. {
  106. return 1;
  107. }
  108.  
  109. public OnGameModeExit()
  110. {
  111. return 1;
  112. }
  113.  
  114. public OnPlayerRequestClass(playerid, classid)
  115. {
  116. return 1;
  117. }
  118.  
  119. public OnPlayerConnect(playerid)
  120. {
  121. Seller[playerid] = 999;
  122. Price[playerid] = 0;
  123. new pFile[48];
  124. format(pFile, 48, Player_File, GetName(playerid));
  125.  
  126. if(!fexist(pFile))
  127. {
  128. new
  129. INI:UserFile = INI_Open(pFile);
  130. INI_WriteFloat(UserFile, "Job", 0);
  131. INI_Close(UserFile);
  132. }
  133. INI_ParseFile(pFile, "LoadPlayerData", .bExtra = true, .extra = playerid);
  134. return 1;
  135. }
  136.  
  137. public OnPlayerDisconnect(playerid, reason)
  138. {
  139. new pFile[48];
  140. format(pFile, 48, Player_File, GetName(playerid));
  141.  
  142. if(fexist(pFile))
  143. {
  144. new
  145. INI:UserFile = INI_Open(pFile);
  146. INI_WriteInt(UserFile, "Job", P_Data[playerid][pJob]);
  147. INI_Close(UserFile);
  148. }
  149. return 1;
  150. }
  151.  
  152. public OnPlayerSpawn(playerid)
  153. {
  154. return 1;
  155. }
  156.  
  157. public OnPlayerDeath(playerid, killerid, reason)
  158. {
  159. return 1;
  160. }
  161. public OnPlayerText(playerid, text[])
  162. {
  163. return 1;
  164. }
  165.  
  166. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  167. {
  168. return 1;
  169. }
  170.  
  171. public OnPlayerExitVehicle(playerid, vehicleid)
  172. {
  173. return 1;
  174. }
  175.  
  176. public OnPlayerStateChange(playerid, newstate, oldstate)
  177. {
  178. return 1;
  179. }
  180.  
  181. public OnPlayerEnterCheckpoint(playerid)
  182. {
  183. new cpid = PlayerCP[playerid];
  184. new jobid = P_Data[playerid][pJob];
  185. if(cpid >= 1)
  186. {
  187. if(IsPlayerInRangeOfPoint(playerid,3.0,CheckPoint[jobid][cpid][CPX],CheckPoint[jobid][cpid][CPY],CheckPoint[jobid][cpid][CPZ]))
  188. {
  189. if(GetPlayerVehicleID(playerid) == PlayerVeh[playerid])
  190. {
  191. PlayerCP[playerid]++;
  192. cpid = PlayerCP[playerid];
  193. new money = randomEx(Job[jobid][Min],Job[jobid][Max]);
  194. if(CheckPoint[jobid][cpid][CPX] == 0.0 && CheckPoint[jobid][cpid][CPY] == 0)//Last Checkpoint
  195. {
  196. if(Job[jobid][Choosed] == 2)
  197. {
  198. GivePlayerMoney(playerid,money);
  199. SendFormatMSG(playerid,-1,"You are get {E0941B}$%d",money);
  200. PlayerCP[playerid] = 0;
  201. DestroyVehicle(PlayerVeh[playerid]);
  202. SCM(playerid,-1,"You are finish your job!");
  203. DisablePlayerCheckpoint(playerid); PlayerWork[playerid] = false;
  204. return 1;
  205. }
  206. if(Job[jobid][Choosed] == 1){ PlayerCP[playerid] = 2; cpid = PlayerCP[playerid];}
  207. }
  208. SetPlayerCheckpoint(playerid,CheckPoint[jobid][cpid][CPX],CheckPoint[jobid][cpid][CPY],CheckPoint[jobid][cpid][CPZ],3.0);
  209. GivePlayerMoney(playerid,money);
  210. SendFormatMSG(playerid,-1,"You are get {E0941B}$%d",money);
  211. }
  212. }
  213. }
  214. return 1;
  215. }
  216.  
  217. public OnPlayerLeaveCheckpoint(playerid)
  218. {
  219. return 1;
  220. }
  221. public OnPlayerPickUpPickup(playerid, pickupid)
  222. {
  223. return 1;
  224. }
  225. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  226. {
  227. if(newkeys == KEY_FIRE)
  228. {
  229. if(PlayerCreateJob[playerid])
  230. {
  231. if(JobCP[playerid] == 1)
  232. {
  233. new dFile[32],Float:Pos[3],string[128];
  234. GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  235. format(dFile, 35, JOB_FILE, JobID[playerid]);
  236. new
  237. INI:File = INI_Open(dFile);
  238.  
  239. INI_WriteString(File, "Name", JobName[playerid]);
  240. INI_WriteFloat(File, "TCPX", Pos[0]);
  241. INI_WriteFloat(File, "TCPY", Pos[1]);
  242. INI_WriteFloat(File, "TCPZ", Pos[2]);
  243. INI_WriteInt(File, "Veh", JobVehID[playerid]);
  244. INI_WriteInt(File, "Min", JobMin[playerid]);
  245. INI_WriteInt(File, "Max", JobMax[playerid]);
  246. INI_WriteInt(File, "Choose", JobChoose[playerid]);
  247. INI_Close(File);
  248. format(Job[JobID[playerid]][Name],64,"%s",JobName[playerid]);
  249. Job[JobID[playerid]][TCPX] = Pos[0];
  250. Job[JobID[playerid]][TCPY] = Pos[1];
  251. Job[JobID[playerid]][TCPZ] = Pos[2];
  252. Job[JobID[playerid]][VehID] = JobVehID[playerid];
  253. Job[JobID[playerid]][Choosed] = JobChoose[playerid];
  254. Job[JobID[playerid]][Min] = JobMin[playerid];
  255. Job[JobID[playerid]][Max] = JobMax[playerid];
  256. Job[JobID[playerid]][Pickup] = CreateDynamicPickup(1239, 23, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ],-1,-1,-1,100.0);
  257. format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[JobID[playerid]][Name]);
  258. Job[JobID[playerid]][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
  259. JobCP[playerid]++;
  260. }
  261. else if(JobCP[playerid] > 1)
  262. {
  263. new dFile[32],Float:Pos[3],string[6];
  264. GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  265. format(dFile, 35, JOB_FILE, JobID[playerid]);
  266.  
  267. new
  268. INI:File = INI_Open(dFile);
  269.  
  270. format(string,6,"CPX%d",JobCP[playerid]);
  271. INI_WriteFloat(File, string, Pos[0]);
  272. CheckPoint[JobID[playerid]][JobCP[playerid]][CPX] = Pos[0];
  273.  
  274. format(string,6,"CPY%d",JobCP[playerid]);
  275. INI_WriteFloat(File, string, Pos[1]);
  276. CheckPoint[JobID[playerid]][JobCP[playerid]][CPY] = Pos[1];
  277.  
  278. format(string,6,"CPZ%d",JobCP[playerid]);
  279. INI_WriteFloat(File, string, Pos[2]);
  280. CheckPoint[JobID[playerid]][JobCP[playerid]][CPZ] = Pos[2];
  281.  
  282. INI_Close(File);
  283. JobCP[playerid]++;
  284. }
  285. }
  286. }
  287. return 1;
  288. }
  289. public OnPlayerUpdate(playerid)
  290. {
  291. return 1;
  292. }
  293. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  294. {
  295. switch(dialogid)
  296. {
  297. case DIALOG_JOB:
  298. {
  299. if(!response) return 1;
  300. switch(listitem)
  301. {
  302. case 0://Checpoint
  303. {
  304. SCM(playerid,-1,"You'r choose job based on chekpoint.");
  305. ShowPlayerDialog(playerid,DIALOG_JOB+1,DIALOG_STYLE_INPUT,"Job Name","Type job name","Insert","Close");
  306. JobOnCP[playerid] = true;
  307. }
  308. case 1://Checpoint
  309. {
  310. SCM(playerid,-1,"You'r choose job based on commands.");
  311. ShowPlayerDialog(playerid,DIALOG_JOB+1,DIALOG_STYLE_INPUT,"Job Name","Type job name","Insert","Close");
  312. JobOnCP[playerid] = false;
  313. }
  314. }
  315. }
  316. case DIALOG_JOB+1:
  317. {
  318. if(!response) return 1;
  319. if(JobOnCP[playerid]) { JobCP[playerid] = 1; SCM(playerid,-1,"To set checkpoint use click on mouse. First click is location for command /takejob");}
  320. format(JobName[playerid],64,"%s",inputtext);
  321. ShowPlayerDialog(playerid,DIALOG_JOB+2,DIALOG_STYLE_INPUT,"Job Veh","Type vehicle id for job","Insert","Close");
  322. }
  323. case DIALOG_JOB+2:
  324. {
  325. if(!response) return 1;
  326. SendFormatMSG(playerid,-1,"You are choose car id %d",strval(inputtext));
  327. JobVehID[playerid] = strval(inputtext);
  328. if(JobOnCP[playerid]) { ShowPlayerDialog(playerid,DIALOG_JOB+3,DIALOG_STYLE_INPUT,"Choose system","1 = After player enter in last\ncheckpoint start again checkpoints\n2 = After player enter in last\ncheckpoint disablecheckpoints\nType 1 or 2","Insert","Close"); }
  329. if(!JobOnCP[playerid]) { ShowPlayerDialog(playerid,DIALOG_JOB+6,DIALOG_STYLE_INPUT,"Type command name","Example: sellicecream (with no /)","Insert","Close"); }
  330. }
  331. case DIALOG_JOB+3:
  332. {
  333. if(!response) return 1;
  334. SendFormatMSG(playerid,-1,"You are choose option %d",strval(inputtext));
  335. JobChoose[playerid] = strval(inputtext);
  336. ShowPlayerDialog(playerid,DIALOG_JOB+4,DIALOG_STYLE_INPUT,"Choose minimum","Choose minimum money for get money on checkpoint","Insert","Close");
  337. }
  338. case DIALOG_JOB+4:
  339. {
  340. if(!response) return 1;
  341. SendFormatMSG(playerid,-1,"You are choose $%d for minimum money",strval(inputtext));
  342. JobMin[playerid] = strval(inputtext);
  343. ShowPlayerDialog(playerid,DIALOG_JOB+5,DIALOG_STYLE_INPUT,"Choose max","Choose max money for get money on checkpoint","Insert","Close");
  344. }
  345. case DIALOG_JOB+5:
  346. {
  347. if(!response) return 1;
  348. SendFormatMSG(playerid,-1,"You are choose $%d for max money",strval(inputtext));
  349. JobMax[playerid] = strval(inputtext);
  350. }
  351. case DIALOG_JOB+6:
  352. {
  353. if(!response) return 1;
  354. new dFile[32],Float:Pos[3],string[200];
  355. GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
  356. format(dFile, 35, JOB_FILE, JobID[playerid]);
  357. new
  358. INI:File = INI_Open(dFile);
  359.  
  360. INI_WriteString(File, "Name", JobName[playerid]);
  361. INI_WriteFloat(File, "TCPX", Pos[0]);
  362. INI_WriteFloat(File, "TCPY", Pos[1]);
  363. INI_WriteFloat(File, "TCPZ", Pos[2]);
  364. INI_WriteInt(File, "Veh", JobVehID[playerid]);
  365. INI_Close(File);
  366. format(Job[JobID[playerid]][Name],64,"%s",JobName[playerid]);
  367. Job[JobID[playerid]][TCPX] = Pos[0];
  368. Job[JobID[playerid]][TCPY] = Pos[1];
  369. Job[JobID[playerid]][TCPZ] = Pos[2];
  370. Job[JobID[playerid]][VehID] = JobVehID[playerid];
  371. Job[JobID[playerid]][Choosed] = JobChoose[playerid];
  372. Job[JobID[playerid]][Min] = JobMin[playerid];
  373. Job[JobID[playerid]][Max] = JobMax[playerid];
  374. Job[JobID[playerid]][Pickup] = CreateDynamicPickup(1239, 23, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ],-1,-1,-1,100.0);
  375. format(string,128,""COL_LIGHTBLUE"To take job "COL_ORANGE"%s\n"COL_LIGHTBLUE"Type "COL_RED"[/takejob]",Job[JobID[playerid]][Name]);
  376. Job[JobID[playerid]][Label] = CreateDynamic3DTextLabel(string, 0xFFFFFF, Job[JobID[playerid]][TCPX],Job[JobID[playerid]][TCPY],Job[JobID[playerid]][TCPZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100);
  377. new File:log = fopen("/Command.txt", io_write);
  378. format(string,sizeof(string),"YCMD:%s(playerid,params[],help)\r\n{\r\n#pragma unused help\r\n",inputtext);
  379. fwrite(log, string);
  380. format(string,sizeof(string),"if(P_Data[playerid][pJob] != %d) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"You are not %s\");\r\n",JobID[playerid]);
  381. fwrite(log, string);
  382. format(string,sizeof(string),"new pplayerid,price,Float:Position[3];\r\nif(sscanf(params,\"ui\",pplayerid,price)) return SCM(playerid,COLOR_RED,\"\"COL_WHITE\"Usage: /%s [Player ID/Part OfName] [Price]\");\r\n",inputtext);
  383. fwrite(log, string);
  384. fwrite(log, "if(!PlayerWork[playerid]) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"Type /startjob\");\r\n");
  385. fwrite(log, "if(PlayerVeh[playerid] != GetPlayerVehicleID(playerid)) return SCM(playerid,COLOR_RED,\"EROR: \"COL_WHITE\"You are not in your vehicle\");\r\n");
  386. fwrite(log, "if(pplayerid == INVALID_PLAYER_ID) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"Invalid ID\");\r\n");
  387. fwrite(log, "GetPlayerPos(pplayerid,Position[0],Position[1],Position[2]);\r\n");
  388. fwrite(log, "if(!IsPlayerInRangeOfPoint(playerid,5.0,Position[0],Position[1],Position[2])) return SCM(playerid,COLOR_RED,\"EROR:\"COL_WHITE\"You are not near to that player\");\r\n");
  389. fwrite(log, "Seller[pplayerid] = playerid;\r\nPrice[pplayerid] = price;\r\n");
  390. format(string,sizeof(string),"SendFormatMSG(pplayerid,-1,\"Player with job %s has you offered for price:",JobName[playerid]);
  391. fwrite(log, string);
  392. fwrite(log, " %d type /accept\",price);\r\n");
  393. fwrite(log, "SCM(playerid,-1,\"Wait for player answer\");\r\n");
  394. fwrite(log, "return 1;\r\n}\r\n==============In command /accept\r\n");
  395. format(string,sizeof(string),"if(strcmp(text,\"%s\",false) == 0)\r\n{\r\n",inputtext);
  396. fwrite(log, string);
  397. fwrite(log, "if(Seller[playerid] == 999) return SCM(playerid,COLOR_RED,\"No body dosen't gave you some offer\");\r\n");
  398. fwrite(log, "if(Price[playerid] > GetPlayerMoney(playerid)) return SCM(playerid,COLOR_RED,\"You don't have that money\"),Seller[playerid] = 999;\r\n");
  399. fwrite(log, "SCM(Seller[playerid],-1,\"Player is accept offer\");\r\nSCM(playerid,-1,\"You are accept offer\");\r\n");
  400. fwrite(log, "GivePlayerMoney(Seller[playerid],Price[playerid]);\r\nGivePlayerMoney(playerid,-Price[playerid]);\r\n");
  401. fwrite(log, "new Float:health; GetPlayerHealth(playerid,health);\r\nSetPlayerHealth(playerid,health+25);\r\n");
  402. fwrite(log, "}");
  403. fclose(log); // Close the file
  404. }
  405. }
  406. return 1;
  407. }
  408. forward LoadPlayerData(playerid, name[], value[]);
  409. public LoadPlayerData(playerid, name[], value[])
  410. {
  411. INI_Int("Job", P_Data[playerid][pJob]);
  412. return 1;
  413. }
  414. stock GetName(playerid)
  415. {
  416. new
  417. pName[MAX_PLAYER_NAME];
  418.  
  419. GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
  420. return pName;
  421. }
  422. forward GetJobID(playerid);
  423. public GetJobID(playerid)
  424. {
  425. new Float:Distance;
  426. for(new j = 1; j<MAX_JOBS; j++)
  427. {
  428. Distance = GetDistanceToJob(playerid, j);
  429. if(Distance < 5.0)
  430. {
  431. return j;
  432. }
  433. }
  434. return -1;
  435. }
  436. forward Float:GetDistanceToJob(playerid, j);
  437. public Float:GetDistanceToJob(playerid, j)
  438. {
  439. new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
  440. GetPlayerPos(playerid,x1,y1,z1);
  441. x2 = Job[j][TCPX];
  442. y2 = Job[j][TCPY];
  443. z2 = Job[j][TCPZ];
  444. return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  445. }
  446. forward LoadJobs(id, name[], value[]);
  447. public LoadJobs(id, name[], value[])
  448. {
  449. new string[6];
  450. INI_String("Name", Job[id][Name],64);
  451. INI_Float("TCPX", Job[id][TCPX]);
  452. INI_Float("TCPY", Job[id][TCPY]);
  453. INI_Float("TCPZ", Job[id][TCPZ]);
  454. INI_Int("Veh", Job[id][VehID]);
  455. INI_Int("Min", Job[id][Min]);
  456. INI_Int("Max", Job[id][Max]);
  457. INI_Int("Choose", Job[id][Choosed]);
  458. for(new i = 1;i <= MAX_CP;i++)
  459. {
  460. format(string,6,"CPX%d",i);
  461. INI_Float(string, CheckPoint[id][i][CPX]);
  462. format(string,6,"CPY%d",i);
  463. INI_Float(string, CheckPoint[id][i][CPY]);
  464. format(string,6,"CPZ%d",i);
  465. INI_Float(string, CheckPoint[id][i][CPZ]);
  466. }
  467. return 1;
  468. }
  469. //========Commands=========
  470. YCMD:createjob(playerid,params[],help)
  471. {
  472. #pragma unused help
  473. #pragma unused params
  474. new dFile[32];
  475. if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Need to be RCON admin!");
  476. if(PlayerCreateJob[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You already creating job!");
  477. ShowPlayerDialog(playerid,DIALOG_JOB,DIALOG_STYLE_LIST,"Job bassed on","Checkpoints\nCommands","Choose","Close");
  478. JobID[playerid] = 1;
  479. PlayerCreateJob[playerid] = true;
  480. for(new id = 1; id <= MAX_JOBS;id++)
  481. {
  482. format(dFile, 35, JOB_FILE, id);
  483. if(fexist(dFile)) JobID[playerid]++;
  484. if(JobID[playerid] > MAX_JOBS) return SCM(playerid,-1,"Change MAX_JOBS in FS for more jobs.");
  485. }
  486. return 1;
  487. }
  488. YCMD:finishcjob(playerid,params[],help)
  489. {
  490. #pragma unused help
  491. #pragma unused params
  492. if(!IsPlayerAdmin(playerid)) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"Need to be RCON admin!");
  493. if(!PlayerCreateJob[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't creating job!");
  494. JobID[playerid] = 0;
  495. PlayerCreateJob[playerid] = false;
  496. SCM(playerid,-1,"You are finish creating job.");
  497. return 1;
  498. }
  499. YCMD:takejob(playerid,params[],help)
  500. {
  501. #pragma unused help
  502. #pragma unused params
  503. new id = GetJobID(playerid);
  504. if(id == -1) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"There is no any job.");
  505. if(P_Data[playerid][pJob] != 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You already have job.");
  506. SendFormatMSG(playerid,-1,"Now your job is {E0941B}%s",Job[id][Name]);
  507. P_Data[playerid][pJob] = id;
  508. return 1;
  509. }
  510. YCMD:startjob(playerid,params[],help)
  511. {
  512. #pragma unused help
  513. #pragma unused params
  514. if(PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are already start job. Type /finishjob");
  515. new h = P_Data[playerid][pJob],Float:Pos[4]; GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); GetPlayerFacingAngle(playerid,Pos[3]);
  516. if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job.");
  517. if(!IsPlayerInRangeOfPoint(playerid,20.0,Job[h][TCPX],Job[h][TCPY],Job[h][TCPZ])) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You are not near to your job.");
  518. PlayerCP[playerid] = 2;
  519. if(Job[h][Choosed] != 0) SetPlayerCheckpoint(playerid,CheckPoint[h][PlayerCP[playerid]][CPX],CheckPoint[h][PlayerCP[playerid]][CPY],CheckPoint[h][PlayerCP[playerid]][CPZ],3.0);
  520. SCM(playerid,-1,"You are start with job. Go to red checkpoint.");
  521. PlayerVeh[playerid] = CreateVehicle(Job[h][VehID],Pos[0],Pos[1]+1,Pos[2],Pos[3],random(256),random(256),3600);
  522. PlayerWork[playerid] = true;
  523. return 1;
  524. }
  525. YCMD:finishjob(playerid,params[],help)
  526. {
  527. #pragma unused help
  528. #pragma unused params
  529. if(!PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You aren't start job.");
  530. if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job.");
  531. PlayerCP[playerid] = 0;
  532. DisablePlayerCheckpoint(playerid);
  533. SCM(playerid,-1,"You are finish with job.");
  534. DestroyVehicle(PlayerVeh[playerid]);
  535. PlayerWork[playerid] = false;
  536. return 1;
  537. }
  538. YCMD:quitjob(playerid,params[],help)
  539. {
  540. #pragma unused help
  541. #pragma unused params
  542. if(PlayerWork[playerid]) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"First finish work.");
  543. if(P_Data[playerid][pJob] == 0) return SCM(playerid,COLOR_RED,"EROR: "COL_WHITE"You don't have job.");
  544. SCM(playerid,-1,"You are quit from job.");
  545. P_Data[playerid][pJob] = 0;
  546. return 1;
  547. }
  548. YCMD:accept(playerid,params[],help)
  549. {
  550. #pragma unused help
  551. new text[48];
  552. if(sscanf(params,"s[48]",text)) return SCM(playerid,-1,"/accept [Something]");
  553. /*
  554. Other from command.txt
  555. */
  556. return 1;
  557. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement