Advertisement
Guest User

CCTV,by Genki

a guest
May 27th, 2016
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.24 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4. #include <dini>
  5. #define MAX_CCTV 100
  6. new PlayerText:Textdraw0[MAX_PLAYERS];
  7. new PlayerText:Textdraw1[MAX_PLAYERS];
  8. new PlayerText:Textdraw3[MAX_PLAYERS];
  9. new PlayerText:Textdraw4[MAX_PLAYERS];
  10. enum CCTVINFO
  11. {
  12. ID,
  13. Float:cx,
  14. Float:cy,
  15. Float:cz,
  16. Float:rx,
  17. Float:ry,
  18. Float:rz,
  19. OBJ1,
  20. vw
  21. }
  22. new cInfo[MAX_CCTV][CCTVINFO];
  23. enum PLAYERINFO
  24. {
  25. Float:px,
  26. Float:py,
  27. Float:pz,
  28. pvw,
  29. bool:watchel
  30. }
  31. new plInfo[MAX_PLAYERS][PLAYERINFO];
  32. new ccform[200];
  33. new ccdbform[20];
  34. new ccdb;
  35. new playered[MAX_PLAYERS];
  36. public OnFilterScriptInit()
  37. {
  38. print("\n--------------------------------------");
  39. print(" CCTV by Genki");
  40. print("--------------------------------------\n");
  41. format(ccdbform,sizeof(ccdbform),"/cctv/db.ini");
  42. if(!dini_Exists(ccdbform))
  43. {
  44. dini_Create(ccdbform);
  45. ccdb=0;
  46. dini_IntSet(ccdbform,"Db",ccdb);
  47. }
  48. else
  49. {
  50. ccdb=dini_Int(ccdbform,"Db");
  51. }
  52. for(new i=1;i<=ccdb;i++)
  53. {
  54. format(ccform,sizeof(ccform),"/cctv/%i.ini",i);
  55. cInfo[i][cx]=dini_Float(ccform,"x");
  56. cInfo[i][cy]=dini_Float(ccform,"y");
  57. cInfo[i][cz]=dini_Float(ccform,"z");
  58. cInfo[i][rx]=dini_Float(ccform,"rx");
  59. cInfo[i][ry]=dini_Float(ccform,"ry");
  60. cInfo[i][rz]=dini_Float(ccform,"rz");
  61. cInfo[i][ID]=dini_Int(ccform,"id");
  62. cInfo[i][OBJ1]=CreateObject(2921, cInfo[i][cx], cInfo[i][cy],cInfo[i][cz],  cInfo[i][rx], cInfo[i][ry], cInfo[i][rz]);
  63. cInfo[i][vw]=dini_Int(ccform,"vw");
  64. }
  65. return 1;
  66. }
  67.  
  68. public OnFilterScriptExit()
  69. {
  70. dini_IntSet(ccdbform,"Db",ccdb);
  71. for(new i=1;i<=ccdb;i++)
  72. {
  73. format(ccform,sizeof(ccform),"/cctv/%i.ini",i);
  74. DestroyObject(cInfo[i][OBJ1]);
  75. dini_IntSet(ccform,"id",cInfo[i][ID]);
  76. dini_FloatSet(ccform,"x",cInfo[i][cx]);
  77. dini_FloatSet(ccform,"y",cInfo[i][cy]);
  78. dini_FloatSet(ccform,"z",cInfo[i][cz]);
  79. dini_FloatSet(ccform,"rx",cInfo[i][rx]);
  80. dini_FloatSet(ccform,"ry",cInfo[i][ry]);
  81. dini_FloatSet(ccform,"rz",cInfo[i][rz]);
  82. dini_IntSet(ccform,"vw",cInfo[i][vw]);
  83.  
  84.  
  85. }
  86. return 1;
  87. }
  88. stock Float:GetPosInFrontOfCam(camid,&Float:x,&Float:y,Float:distance)
  89. {
  90. new Float:a;
  91. x=cInfo[camid][cx];
  92. y=cInfo[camid][cy];
  93. a=cInfo[camid][rz]+45;
  94. x += (distance * floatsin(-a, degrees));
  95. y += (distance * floatcos(-a, degrees));
  96. return a;
  97. }
  98. public OnPlayerConnect(playerid)
  99. {
  100. Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 639.555541, 423.111083, "LD_SPAC:white");
  101. PlayerTextDrawLetterSize(playerid, Textdraw0[playerid], 0.000000, 0.000000);
  102. PlayerTextDrawTextSize(playerid, Textdraw0[playerid], -639.555541, 24.888916);
  103. PlayerTextDrawAlignment(playerid, Textdraw0[playerid], 1);
  104. PlayerTextDrawColor(playerid, Textdraw0[playerid], -1061109505);
  105. PlayerTextDrawSetShadow(playerid, Textdraw0[playerid], 0);
  106. PlayerTextDrawSetOutline(playerid, Textdraw0[playerid], 0);
  107. PlayerTextDrawBackgroundColor(playerid, Textdraw0[playerid], -2139062017);
  108. PlayerTextDrawFont(playerid, Textdraw0[playerid], 4);
  109.  
  110. Textdraw1[playerid] = CreatePlayerTextDraw(playerid, 12.444426, 427.591003, "Camid:");
  111. PlayerTextDrawLetterSize(playerid, Textdraw1[playerid], 0.495333, 1.644800);
  112. PlayerTextDrawAlignment(playerid, Textdraw1[playerid], 1);
  113. PlayerTextDrawColor(playerid, Textdraw1[playerid], 255);
  114. PlayerTextDrawSetShadow(playerid, Textdraw1[playerid], 1);
  115. PlayerTextDrawSetOutline(playerid, Textdraw1[playerid], 0);
  116. PlayerTextDrawBackgroundColor(playerid, Textdraw1[playerid], 51);
  117. PlayerTextDrawFont(playerid, Textdraw1[playerid], 1);
  118. PlayerTextDrawSetProportional(playerid, Textdraw1[playerid], 1);
  119.  
  120.  
  121. Textdraw3[playerid] = CreatePlayerTextDraw(playerid, 612.889282, 401.208770, "LD_BEAT:right");
  122. PlayerTextDrawLetterSize(playerid, Textdraw3[playerid], 0.000000, 0.000000);
  123. PlayerTextDrawTextSize(playerid, Textdraw3[playerid], 25.333356, 13.439996);
  124. PlayerTextDrawAlignment(playerid, Textdraw3[playerid], 1);
  125. PlayerTextDrawColor(playerid, Textdraw3[playerid], 255);
  126. PlayerTextDrawSetShadow(playerid, Textdraw3[playerid], 0);
  127. PlayerTextDrawSetOutline(playerid, Textdraw3[playerid], 0);
  128. PlayerTextDrawFont(playerid, Textdraw3[playerid], 4);
  129. PlayerTextDrawSetSelectable(playerid, Textdraw3[playerid], true);
  130.  
  131. Textdraw4[playerid] = CreatePlayerTextDraw(playerid, 586.666992, 401.208923, "LD_BEAT:left");
  132. PlayerTextDrawLetterSize(playerid, Textdraw4[playerid], 0.000000, 0.000000);
  133. PlayerTextDrawTextSize(playerid, Textdraw4[playerid], 24.888872, 12.942211);
  134. PlayerTextDrawAlignment(playerid, Textdraw4[playerid], 1);
  135. PlayerTextDrawColor(playerid, Textdraw4[playerid], 255);
  136. PlayerTextDrawSetShadow(playerid, Textdraw4[playerid], 0);
  137. PlayerTextDrawSetOutline(playerid, Textdraw4[playerid], 0);
  138. PlayerTextDrawFont(playerid, Textdraw4[playerid], 4);
  139. PlayerTextDrawSetSelectable(playerid, Textdraw4[playerid], true);
  140.  
  141. PlayerTextDrawHide(playerid, Textdraw0[playerid]);
  142. PlayerTextDrawHide(playerid, Textdraw1[playerid]);
  143. PlayerTextDrawHide(playerid, Textdraw3[playerid]);
  144. PlayerTextDrawHide(playerid, Textdraw4[playerid]);
  145.  
  146. return 1;
  147. }
  148.  
  149. public OnPlayerDisconnect(playerid, reason)
  150. {
  151. PlayerTextDrawDestroy(playerid, Textdraw0[playerid]);
  152. PlayerTextDrawDestroy(playerid, Textdraw1[playerid]);
  153. PlayerTextDrawDestroy(playerid, Textdraw3[playerid]);
  154. PlayerTextDrawDestroy(playerid, Textdraw4[playerid]);
  155. return 1;
  156. }
  157. public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
  158. {
  159. new Float:x,Float:y;
  160. if(playertextid == Textdraw3[playerid])
  161. {
  162. if(playered[playerid]==ccdb)
  163. {
  164. SendClientMessage(playerid,-1,"Nincs tovább");
  165. }
  166. else
  167. {
  168. playered[playerid]++;
  169. GetPosInFrontOfCam(playered[playerid],x,y,15);
  170. SetPlayerVirtualWorld(playerid,cInfo[playered[playerid]][vw]);
  171. SetPlayerPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+500);
  172. SetPlayerCameraPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+1.1);
  173. SetPlayerCameraLookAt(playerid,x,y,cInfo[playered[playerid]][cz]-0.1);
  174. new newtext[11];
  175. format(newtext,sizeof(newtext),"Camid:%i",playered[playerid]);
  176. PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
  177. }
  178. }
  179. if(playertextid == Textdraw4[playerid])
  180. {
  181. if(playered[playerid]==1)
  182. {
  183. SendClientMessage(playerid,-1,"Nincs tovább");
  184. }
  185. else
  186. {
  187. playered[playerid]--;
  188. GetPosInFrontOfCam(playered[playerid],x,y,15);
  189. SetPlayerVirtualWorld(playerid,cInfo[playered[playerid]][vw]);
  190. SetPlayerPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+500);
  191. SetPlayerCameraPos(playerid,cInfo[playered[playerid]][cx],cInfo[playered[playerid]][cy],cInfo[playered[playerid]][cz]+1.1);
  192. SetPlayerCameraLookAt(playerid,x,y,cInfo[playered[playerid]][cz]-0.1);
  193. new newtext[11];
  194. format(newtext,sizeof(newtext),"Camid:%i",playered[playerid]);
  195. PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
  196. }
  197.  
  198. }
  199. return 1;
  200. }
  201.  
  202. stock createcam(aid,Float:ax,Float:ay,Float:az,virw)
  203. {
  204. format(ccform,sizeof(ccform),"/cctv/%i.ini",aid);
  205. dini_Create(ccform);
  206. {
  207. cInfo[aid][cx]=ax;
  208. cInfo[aid][cy]=ay;
  209. cInfo[aid][cz]=az;
  210. cInfo[aid][ID]=aid;
  211. cInfo[aid][vw]=virw;
  212. dini_IntSet(ccform,"id",aid);
  213. dini_FloatSet(ccform,"x",ax);
  214. dini_FloatSet(ccform,"y",ay);
  215. dini_FloatSet(ccform,"z",az);
  216. cInfo[aid][OBJ1]=CreateObject(2921, ax, ay, az,   0.00000, 0.00000, 0.00000);
  217. }
  218. return 1;
  219. }
  220.  
  221. CMD:createcc(playerid)
  222. {
  223. new Float:x, Float:y, Float:z;
  224. new virtw;
  225. GetPlayerPos(playerid,x,y,z);
  226. ccdb++;
  227. virtw=GetPlayerVirtualWorld(playerid);
  228. createcam(ccdb,x,y,z,virtw);
  229. dini_IntSet(ccdbform,"Db",ccdb);
  230. return 1;
  231. }
  232. CMD:watchcam(playerid,params[])
  233. {
  234. new Float:x,Float:y;
  235. playered[playerid]=0;
  236. new camid;
  237. if(sscanf(params,"i",camid)) return SendClientMessage(playerid,-1,"Használd /watchcam[camid]");
  238. if(camid>0 && camid<=ccdb)
  239. {
  240. if(plInfo[playerid][watchel]==false)
  241. {
  242. plInfo[playerid][watchel]=true;
  243. x=cInfo[camid][cx];
  244. y=cInfo[camid][cy];
  245. GetPlayerPos(playerid,plInfo[playerid][px],plInfo[playerid][py],plInfo[playerid][pz]);
  246. plInfo[playerid][pvw]=GetPlayerVirtualWorld(playerid);
  247. SetPlayerPos(playerid,cInfo[camid][cx],cInfo[camid][cy],cInfo[camid][cz]+500);
  248. GetPosInFrontOfCam(camid,x,y,15);
  249. TogglePlayerControllable(playerid,false);
  250. SetPlayerVirtualWorld(playerid,cInfo[camid][vw]);
  251. SetPlayerCameraPos(playerid,cInfo[camid][cx],cInfo[camid][cy],cInfo[camid][cz]+1.1);
  252. SetPlayerCameraLookAt(playerid,x,y,cInfo[camid][cz]-0.1);
  253. playered[playerid]=camid;
  254. new newtext[11];
  255. format(newtext,sizeof(newtext),"Camid:%i",camid);
  256. PlayerTextDrawSetString(playerid, Textdraw1[playerid], newtext);
  257. PlayerTextDrawShow(playerid, Textdraw1[playerid]);
  258. PlayerTextDrawShow(playerid, Textdraw0[playerid]);
  259. PlayerTextDrawShow(playerid, Textdraw3[playerid]);
  260. PlayerTextDrawShow(playerid, Textdraw4[playerid]);
  261. SelectTextDraw(playerid, 0xFF4040AA);
  262. }
  263. else
  264. {
  265. SendClientMessage(playerid,-1,"Már nézed a kamerát, nyilakkal váltogass");
  266. }
  267. }
  268. else
  269. {
  270. SendClientMessage(playerid,-1,"Nincs ilyen kamera");
  271. }
  272. return 1;
  273. }
  274. CMD:exitcam(playerid)
  275. {
  276. SetPlayerPos(playerid,plInfo[playerid][px],plInfo[playerid][py],plInfo[playerid][pz]);
  277. SetPlayerVirtualWorld(playerid,plInfo[playerid][pvw]);
  278. TogglePlayerControllable(playerid,true);
  279. SetCameraBehindPlayer(playerid);
  280. CancelSelectTextDraw(playerid);
  281. plInfo[playerid][watchel]=false;
  282. PlayerTextDrawHide(playerid, Textdraw0[playerid]);
  283. PlayerTextDrawHide(playerid, Textdraw1[playerid]);
  284. PlayerTextDrawHide(playerid, Textdraw3[playerid]);
  285. PlayerTextDrawHide(playerid, Textdraw4[playerid]);
  286. return 1;
  287. }
  288. CMD:eobj(playerid,params[])
  289. {
  290. new id;
  291. if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"Használd /editcc[camid]");
  292. playered[playerid]=id;
  293. EditObject(playerid,cInfo[id][OBJ1]);
  294. return 1;
  295. }
  296. public OnPlayerEditObject(playerid, playerobject, objectid, response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ)
  297. {
  298. if(response == EDIT_RESPONSE_FINAL)
  299. {
  300. cInfo[playered[playerid]][cx]=fX;
  301. cInfo[playered[playerid]][cy]=fY;
  302. cInfo[playered[playerid]][cz]=fZ;
  303. cInfo[playered[playerid]][rx]=fRotX;
  304. cInfo[playered[playerid]][ry]=fRotY;
  305. cInfo[playered[playerid]][rz]=fRotZ;
  306. dini_FloatSet(ccform,"x",cInfo[playered[playerid]][cx]);
  307. dini_FloatSet(ccform,"y",cInfo[playered[playerid]][cy]);
  308. dini_FloatSet(ccform,"z",cInfo[playered[playerid]][cz]);
  309. dini_FloatSet(ccform,"rx",cInfo[playered[playerid]][rx]);
  310. dini_FloatSet(ccform,"ry",cInfo[playered[playerid]][ry]);
  311. dini_FloatSet(ccform,"rz",cInfo[playered[playerid]][rz]);
  312. playered[playerid]=0;
  313.  
  314. }
  315. return 1;
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement