Guest User

Bug fs

a guest
Jul 24th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.48 KB | None | 0 0
  1. /*===================================================================================================*\
  2. ||===================================================================================================||
  3. || ________ ________ ___ _ ______ ______ ________ ||
  4. || \ | _____| | ____ | | \ | | | _ \ | _ \ | ____ | / ||
  5. || ======== \ | |_____ | |____| | | |\ \ | | | | | | | |_| / | |____| | / ======== ||
  6. || | | _____ | | ____ | | | \ \| | | | | | | _ \ | ____ | | ||
  7. || ======== / ______| | | | | | | | \ \ | | |_| | | | \ \ | | | | \ ======== ||
  8. || / |________| |_| |_| |_| \__| |______/ |_| \_| |_| |_| \ ||
  9. || ||
  10. ||===================================================================================================||
  11. || Created on the 10th of March 2009 by =>Sandra<= ||
  12. || Do NOT remove my credits!! ||
  13. \*===================================================================================================*/
  14.  
  15.  
  16. #include <a_samp>
  17.  
  18. #define MAX_CCTVS 100
  19. #define MAX_CCTVMENUS 10 //(This number should be MAX_CCTVS divided by 10 (round up))
  20. #define COLOR_RED 0xAA3333AA
  21. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  22. enum pInfo{pKey[128],pLevel,pAdmin,pHelper,pVIP,pSocio,pGrampo,gPupgrade,pConnectTime,pReg,pSex,pAge,pMuted,
  23. pSequestrado,pExp,pCash,pConta,pCrimes,pKills,pDeaths,pPhoneBook,pLottoNr,pFishes,pBiggestFish,pEmprego,
  24. pSalario,pHeadValue,pHeadValueT,pJailed,pJailTime,pMats,pDrogas,pDrogas2,pDrogas3,pLider,pMembro,pCargo,
  25. pSkin,pContractTime,pDetSkill,pSexSkill,pBoxSkill,pLawSkill,pMechSkill,pNewsSkill,pDrogasSkill,pCookSkill,
  26. pFishSkill,Float:pSHealth,pInt,pCapacete,pLocal,pTeam,pPnumber,pPHousekey,pPbiskey,Float:pPos_x,Float:pPos_y,
  27. Float:pPos_z,pCarLic,pFlyLic,pBoatLic,pFishLic,pGunLic,pPayDay,pCDPlayer,pWins,pLoses,pAlcoholPerk,pDrugPerk,
  28. pMiserPerk,pPainPerk,pTraderPerk,pTut,pWarns,pMarried,pParedao,pRequestingBackup,pMask,pMaskuse,pBarraca,
  29. pMarriedTo[64],pSpawn,pSafeDrogas,pSafeDrogas2,pSafeDrogas3,pVeiculo,pVeiculo2,pVeiculo3,pCarKey,pCarKey2,
  30. psMats,pPHouseCarkey,pLuta,pDorgado,pDorgado2,pDoenca,pCreditos,pLastLogin[20],pGun1,pGun2,pGun3,pGun4,pGun5,
  31. pGun6,pGun7,pGun8,pGun9,pGun10,pGun11,pGun12,pAmmo1,pAmmo2,pAmmo3,pAmmo4,pAmmo5,pAmmo6, pAmmo7,pAmmo8,pAmmo9,
  32. pAmmo10,pAmmo11,pAmmo12,pCheckInfoOrg,pCaixinha,pBan,};
  33. //CameraInfo
  34. new TotalCCTVS;
  35. new CameraName[MAX_CCTVS][32];
  36. new Float:CCTVLA[MAX_PLAYERS][3]; //CCTV LookAt
  37. new Float:CCTVLAO[MAX_CCTVS][3];
  38. new Float:CCTVRadius[MAX_PLAYERS]; //CCTV Radius
  39. new Float:CCTVDegree[MAX_PLAYERS] = 0.0;
  40. new Float:CCTVCP[MAX_CCTVS][4]; //CCTV CameraPos
  41. new CurrentCCTV[MAX_PLAYERS] = -1;
  42.  
  43. //TextDraw
  44. new Text:TD;
  45.  
  46. //Menus:
  47. new Menu:CCTVMenu[MAX_CCTVMENUS];
  48. new MenuType[MAX_CCTVMENUS];
  49. new TotalMenus;
  50. new PlayerMenu[MAX_PLAYERS];
  51.  
  52. enum LP
  53. {
  54. Float:LX,
  55. Float:LY,
  56. Float:LZ,
  57. Float:LA,
  58. LInterior
  59. }
  60. new Spawned[MAX_PLAYERS];
  61. new LastPos[MAX_PLAYERS][LP];
  62.  
  63. new KeyTimer[MAX_PLAYERS];
  64.  
  65. public OnFilterScriptInit()
  66. {
  67.  
  68. //Put All AddCCTV-lines here below:
  69. //======================================================
  70. //======================================================
  71. AddCCTV("Posto Sul", 1929.9230,-1738.3425,22.5919, 0.0);
  72. AddCCTV("Saida LS", 1-15.8403,-1521.7112,9.3724, 180.0);
  73. AddCCTV("DP LS", 1509.7046,-1681.9382,19.2422, 90.0);
  74. AddCCTV("Prefeitura", 1519.3434,-1724.9624,22.8507, 0.0);
  75. AddCCTV("Praca DP", 1451.3877,-1655.5955,24.6834, 90.0);
  76. AddCCTV("Banco", 1456.7614,-1042.7587,36.6236, 150.0);
  77. AddCCTV("Loja de Armas", 1792.9620,-1190.6348,40.7203, 270.0);
  78. AddCCTV("Ammnu Nation", 1333.0316,-1292.9337,29.0600, 270.0);
  79. AddCCTV("Loterica", 1671.4789,-1137.9192,37.8054, 270.0);
  80. AddCCTV("Binco", 2256.9570,-1644.5586,20.5150, 0.0);
  81. AddCCTV("ZIP", 1442.2295,-1176.3035,48.8760, 310.0);
  82. AddCCTV("VICTIM", 436.5767,-1535.5353,42.0033, 270.0);
  83. AddCCTV("Hospital", 2035.8033,-1410.3185,24.4542, 90.0);
  84. //======================================================
  85. //======================================================
  86.  
  87. //Creating Textdraw
  88. TD = TextDrawCreate(160, 400, "~y~Comandos:~n~Setas: ~w~Move a Camera~n~~y~Espaco: ~w~Aumenta velocidade~n~~y~Agachar: ~w~/saircamera");
  89. TextDrawLetterSize(TD, 0.4, 0.9);
  90. TextDrawSetShadow(TD, 0);
  91. TextDrawUseBox(TD,1);
  92. TextDrawBoxColor(TD,0x00000055);
  93. TextDrawTextSize(TD, 380, 400);
  94.  
  95. //Creating Menu's
  96. new Count, Left = TotalCCTVS;
  97. for(new menu; menu<MAX_CCTVMENUS; menu++)
  98. {
  99. if(Left > 12)
  100. {
  101. CCTVMenu[menu] = CreateMenu("Escolha Camera:", 1, 200, 100, 220);
  102. TotalMenus++;
  103. MenuType[menu] = 1;
  104. for(new i; i<11; i++)
  105. {
  106. AddMenuItem(CCTVMenu[menu], 0, CameraName[Count]);
  107. Count++;
  108. Left--;
  109. }
  110. AddMenuItem(CCTVMenu[menu], 0, "Proximo");
  111. }
  112. else if(Left<13 && Left > 0)
  113. {
  114. CCTVMenu[menu] = CreateMenu("Escolha Camera:", 1, 200, 100, 220);
  115. TotalMenus++;
  116. MenuType[menu] = 2;
  117. new tmp = Left;
  118. for(new i; i<tmp; i++)
  119. {
  120. AddMenuItem(CCTVMenu[menu], 0, CameraName[Count]);
  121. Count++;
  122. Left--;
  123. }
  124. }
  125. }
  126.  
  127. print("\n\n-----------------------------------------------");
  128. print(" Remote CCTV Filterscript by =>Sandra<= Loaded!");
  129. print("-----------------------------------------------\n\n");
  130. return 1;
  131. }
  132.  
  133. public OnFilterScriptExit()
  134. {
  135. TextDrawHideForAll(TD);
  136. TextDrawDestroy(TD);
  137. for(new i; i<TotalMenus; i++)
  138. {
  139. DestroyMenu(CCTVMenu[i]);
  140. }
  141. return 1;
  142. }
  143.  
  144. public OnPlayerConnect(playerid)
  145. {
  146. Spawned[playerid] = 0;
  147. CurrentCCTV[playerid] = -1;
  148. return 1;
  149. }
  150. public OnPlayerDisconnect(playerid, reason)
  151. {
  152. if(CurrentCCTV[playerid] > -1)
  153. {
  154. KillTimer(KeyTimer[playerid]);
  155. TextDrawHideForPlayer(playerid, TD);
  156. }
  157. CurrentCCTV[playerid] = -1;
  158. return 1;
  159. }
  160.  
  161. public OnPlayerSpawn(playerid)
  162. {
  163. Spawned[playerid] = 1;
  164. return 1;
  165. }
  166. public OnPlayerDeath(playerid, killerid, reason)
  167. {
  168. Spawned[playerid] = 0;
  169. return 1;
  170. }
  171.  
  172. public OnPlayerCommandText(playerid, cmdtext[])
  173. {
  174. if (strcmp("/camera", cmdtext, true) == 0)
  175. {
  176. if(PlayerToPoint(5.0,playerid,217.3896,81.3217,1005.0391))
  177. {
  178. PlayerMenu[playerid] = 0;
  179. TogglePlayerControllable(playerid, 0);
  180. ShowMenuForPlayer(CCTVMenu[0], playerid);
  181. }
  182. return 1;
  183. }
  184. if (strcmp("/saircamera", cmdtext, true) == 0)
  185. {
  186. if(CurrentCCTV[playerid] > -1)
  187. {
  188. SetPlayerPos(playerid, LastPos[playerid][LX], LastPos[playerid][LY], LastPos[playerid][LZ]);
  189. SetPlayerFacingAngle(playerid, LastPos[playerid][LA]);
  190. SetPlayerInterior(playerid, LastPos[playerid][LInterior]);
  191. TogglePlayerControllable(playerid, 1);
  192. KillTimer(KeyTimer[playerid]);
  193. SetCameraBehindPlayer(playerid);
  194. TextDrawHideForPlayer(playerid, TD);
  195. CurrentCCTV[playerid] = -1;
  196.  
  197. return 1;
  198. }
  199. }
  200. return 0;
  201. }
  202.  
  203.  
  204. forward CheckKeyPress(playerid);
  205. public CheckKeyPress(playerid)
  206. {
  207. new keys, updown, leftright;
  208. GetPlayerKeys(playerid, keys, updown, leftright);
  209. if(CurrentCCTV[playerid] > -1 && PlayerMenu[playerid] == -1)
  210. {
  211. if(leftright == KEY_RIGHT)
  212. {
  213. if(keys == KEY_SPRINT)
  214. {
  215. CCTVDegree[playerid] = (CCTVDegree[playerid] - 2.0);
  216. }
  217. else
  218. {
  219. CCTVDegree[playerid] = (CCTVDegree[playerid] - 0.5);
  220. }
  221. if(CCTVDegree[playerid] < 0)
  222. {
  223. CCTVDegree[playerid] = 359;
  224. }
  225. MovePlayerCCTV(playerid);
  226.  
  227. }
  228. if(leftright == KEY_LEFT)
  229. {
  230. if(keys == KEY_SPRINT)
  231. {
  232. CCTVDegree[playerid] = (CCTVDegree[playerid] + 2.0);
  233. }
  234. else
  235. {
  236. CCTVDegree[playerid] = (CCTVDegree[playerid] + 0.5);
  237. }
  238. if(CCTVDegree[playerid] >= 360)
  239. {
  240. CCTVDegree[playerid] = 0;
  241. }
  242. MovePlayerCCTV(playerid);
  243.  
  244. }
  245. if(updown == KEY_UP)
  246. {
  247. if(CCTVRadius[playerid] < 25)
  248. {
  249. if(keys == KEY_SPRINT)
  250. {
  251. CCTVRadius[playerid] = (CCTVRadius[playerid] + 0.5);
  252. MovePlayerCCTV(playerid);
  253. }
  254. else
  255. {
  256. CCTVRadius[playerid] = (CCTVRadius[playerid] + 0.1);
  257. MovePlayerCCTV(playerid);
  258. }
  259. }
  260. }
  261. if(updown == KEY_DOWN)
  262. {
  263. if(keys == KEY_SPRINT)
  264. {
  265. if(CCTVRadius[playerid] >= 0.6)
  266. {
  267. CCTVRadius[playerid] = (CCTVRadius[playerid] - 0.5);
  268. MovePlayerCCTV(playerid);
  269. }
  270. }
  271. else
  272. {
  273. if(CCTVRadius[playerid] >= 0.2)
  274. {
  275. CCTVRadius[playerid] = (CCTVRadius[playerid] - 0.1);
  276. MovePlayerCCTV(playerid);
  277. }
  278. }
  279. }
  280. if(keys == KEY_CROUCH)
  281. {
  282. OnPlayerCommandText(playerid, "/saircamera");
  283. }
  284. }
  285. MovePlayerCCTV(playerid);
  286. }
  287.  
  288. stock MovePlayerCCTV(playerid)
  289. {
  290. CCTVLA[playerid][0] = CCTVLAO[CurrentCCTV[playerid]][0] + (floatmul(CCTVRadius[playerid], floatsin(-CCTVDegree[playerid], degrees)));
  291. CCTVLA[playerid][1] = CCTVLAO[CurrentCCTV[playerid]][1] + (floatmul(CCTVRadius[playerid], floatcos(-CCTVDegree[playerid], degrees)));
  292. SetPlayerCameraLookAt(playerid, CCTVLA[playerid][0], CCTVLA[playerid][1], CCTVLA[playerid][2]);
  293. }
  294.  
  295.  
  296. stock AddCCTV(name[], Float:X, Float:Y, Float:Z, Float:Angle)
  297. {
  298. if(TotalCCTVS >= MAX_CCTVS) return 0;
  299. format(CameraName[TotalCCTVS], 32, "%s", name);
  300. CCTVCP[TotalCCTVS][0] = X;
  301. CCTVCP[TotalCCTVS][1] = Y;
  302. CCTVCP[TotalCCTVS][2] = Z;
  303. CCTVCP[TotalCCTVS][3] = Angle;
  304. CCTVLAO[TotalCCTVS][0] = X;
  305. CCTVLAO[TotalCCTVS][1] = Y;
  306. CCTVLAO[TotalCCTVS][2] = Z-10;
  307. TotalCCTVS++;
  308. return TotalCCTVS-1;
  309. }
  310.  
  311. SetPlayerToCCTVCamera(playerid, CCTV)
  312. {
  313. if(CCTV >= TotalCCTVS)
  314. {
  315. SendClientMessage(playerid, 0xFF0000AA, "Invald CCTV");
  316. return 1;
  317. }
  318. if(CurrentCCTV[playerid] == -1)
  319. {
  320. GetPlayerPos(playerid, LastPos[playerid][LX], LastPos[playerid][LY], LastPos[playerid][LZ]);
  321. GetPlayerFacingAngle(playerid, LastPos[playerid][LA]);
  322. LastPos[playerid][LInterior] = GetPlayerInterior(playerid);
  323. SetPlayerInterior(playerid, 6); //Troque o "A" pelo ID do interior da Origem 1.
  324. }
  325. else
  326. {
  327. KillTimer(KeyTimer[playerid]);
  328. }
  329. CurrentCCTV[playerid] = CCTV;
  330. TogglePlayerControllable(playerid, 0);
  331. //SetPlayerPos(playerid, CCTVCP[CCTV][0], CCTVCP[CCTV][1], (CCTVCP[CCTV][2]-50));
  332. SetPlayerPos(playerid, CCTVCP[CCTV][0], CCTVCP[CCTV][1], -100.0);
  333. SetPlayerCameraPos(playerid, CCTVCP[CCTV][0], CCTVCP[CCTV][1], CCTVCP[CCTV][2]);
  334. SetPlayerCameraLookAt(playerid, CCTVLAO[CCTV][0], (CCTVLAO[CCTV][1]+0.2), CCTVLAO[CCTV][2]);
  335. CCTVLA[playerid][0] = CCTVLAO[CCTV][0];
  336. CCTVLA[playerid][1] = CCTVLAO[CCTV][1]+0.2;
  337. CCTVLA[playerid][2] = CCTVLAO[CCTV][2];
  338. SetPlayerInterior(playerid, 0); //Troque o "A" pelo ID do interior da Origem 1.
  339. CCTVRadius[playerid] = 12.5;
  340. CCTVDegree[playerid] = CCTVCP[CCTV][3];
  341. MovePlayerCCTV(playerid);
  342. KeyTimer[playerid] = SetTimerEx("CheckKeyPress", 75, 1, "i", playerid);
  343. TextDrawShowForPlayer(playerid, TD);
  344. return 1;
  345. }
  346.  
  347. public OnPlayerSelectedMenuRow(playerid, row)
  348. {
  349. new Menu:Current = GetPlayerMenu(playerid);
  350. for(new menu; menu<TotalMenus; menu++)
  351. {
  352.  
  353. if(Current == CCTVMenu[menu])
  354. {
  355. if(MenuType[PlayerMenu[playerid]] == 1)
  356. {
  357. if(row == 11)
  358. {
  359. ShowMenuForPlayer(CCTVMenu[menu+1], playerid);
  360. TogglePlayerControllable(playerid, 0);
  361. PlayerMenu[playerid] = (menu+1);
  362. }
  363. else
  364. {
  365. if(PlayerMenu[playerid] == 0)
  366. {
  367. SetPlayerToCCTVCamera(playerid, row);
  368. PlayerMenu[playerid] = -1;
  369. }
  370. else
  371. {
  372. SetPlayerToCCTVCamera(playerid, ((PlayerMenu[playerid]*11)+row));
  373. PlayerMenu[playerid] = -1;
  374. }
  375. }
  376. }
  377. else
  378. {
  379. if(PlayerMenu[playerid] == 0)
  380. {
  381. SetPlayerToCCTVCamera(playerid, row);
  382. PlayerMenu[playerid] = -1;
  383. }
  384. else
  385. {
  386. SetPlayerToCCTVCamera(playerid, ((PlayerMenu[playerid]*11)+row));
  387. PlayerMenu[playerid] = -1;
  388. }
  389. }
  390. }
  391. }
  392.  
  393. return 1;
  394. }
  395.  
  396. public OnPlayerExitedMenu(playerid)
  397. {
  398. TogglePlayerControllable(playerid, 1);
  399. PlayerMenu[playerid] = -1;
  400. return 1;
  401. }
  402. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  403. {
  404. if(IsPlayerConnected(playerid))
  405. {
  406. new Float:oldposx, Float:oldposy, Float:oldposz;
  407. new Float:tempposx, Float:tempposy, Float:tempposz;
  408. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  409. tempposx = (oldposx -x);
  410. tempposy = (oldposy -y);
  411. tempposz = (oldposz -z);
  412. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  413. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  414. {
  415. return 1;
  416. }
  417. }
  418. return 0;
  419. }
Advertisement
Add Comment
Please, Sign In to add comment