Guest User

Pspec

a guest
Dec 29th, 2012
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.97 KB | None | 0 0
  1. /* ________________________________
  2. __,__ ( )
  3. .--. .-" "-. .--. (wow! pspec system i wanted that )
  4. / .. \/ .-. .-. \/ .. \ ( only !!! )
  5. | | '| / Y \ |' | | / ( please dont remove the credits)
  6. | \ \ \ 0 | 0 / / / | / ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  7. \ '- ,\.-"`` ``"-./, -' / /
  8. `'-' /_ ^ ^ _\ '-'` /
  9. .--'| \._ _ _./ |'--.
  10. /` \ \.-. / / `\
  11. / '._/ |-' _.' \
  12. / ; /--~' | \
  13. / .'\|.-\--. \ \
  14. / .'-. /.-.;\ |\|'~'-.|\ \
  15. \ `-./`|_\_/ ` `\'. \
  16. '. ; ___) '.`; /
  17. '-.,_ ; ___) \/ /
  18. \ ``'------'\ \ ` /
  19. '. \ '. | ;/_
  20. ___> '. \_ _ _/ , '--.
  21. .' '. .-~~~~~-. / |--'`~~-. \
  22. // / .---'/ .-~~-._/ / / /---..__.' /
  23. ((_(_/ / / (_(_(_(---.__ .'
  24. | | _ `~~`
  25. | | \'.
  26. \ '....' |
  27. '.,___.'
  28.  
  29. #Name: pspec system
  30. #Author: CandyBoy
  31. #Release: 29/12/12
  32. */
  33.  
  34. #include <a_samp>
  35.  
  36. new Float:coords[MAX_PLAYERS][3], Spectating[MAX_PLAYERS];
  37. new Interior[MAX_PLAYERS];
  38.  
  39. new aWeaponNames[][32] = {
  40. {"Unarmed (Fist)"}, // 0
  41. {"Brass Knuckles"}, // 1
  42. {"Golf Club"}, // 2
  43. {"Night Stick"}, // 3
  44. {"Knife"}, // 4
  45. {"Baseball Bat"}, // 5
  46. {"Shovel"}, // 6
  47. {"Pool Cue"}, // 7
  48. {"Katana"}, // 8
  49. {"Chainsaw"}, // 9
  50. {"Purple Dildo"}, // 10
  51. {"Big White Vibrator"}, // 11
  52. {"Medium White Vibrator"}, // 12
  53. {"Small White Vibrator"}, // 13
  54. {"Flowers"}, // 14
  55. {"Cane"}, // 15
  56. {"Grenade"}, // 16
  57. {"Teargas"}, // 17
  58. {"Molotov"}, // 18
  59. {" "}, // 19
  60. {" "}, // 20
  61. {" "}, // 21
  62. {"Colt 45"}, // 22
  63. {"Colt 45 (Silenced)"}, // 23
  64. {"Desert Eagle"}, // 24
  65. {"Normal Shotgun"}, // 25
  66. {"Sawnoff Shotgun"}, // 26
  67. {"Combat Shotgun"}, // 27
  68. {"Micro Uzi (Mac 10)"}, // 28
  69. {"MP5"}, // 29
  70. {"AK47"}, // 30
  71. {"M4"}, // 31
  72. {"Tec9"}, // 32
  73. {"Country Rifle"}, // 33
  74. {"Sniper Rifle"}, // 34
  75. {"Rocket Launcher"}, // 35
  76. {"Heat-Seeking Rocket Launcher"}, // 36
  77. {"Flamethrower"}, // 37
  78. {"Minigun"}, // 38
  79. {"Satchel Charge"}, // 39
  80. {"Detonator"}, // 40
  81. {"Spray Can"}, // 41
  82. {"Fire Extinguisher"}, // 42
  83. {"Camera"}, // 43
  84. {"Night Vision Goggles"}, // 44
  85. {"Infrared Vision Goggles"}, // 45
  86. {"Parachute"}, // 46
  87. {"Fake Pistol"} // 47
  88. };
  89.  
  90. public OnFilterScriptInit()
  91. {
  92. print("\n--------------------------------------");
  93. print(" ----- pspec system loaded----------------");
  94. print("--------------------------------------\n");
  95. for(new i;i<MAX_PLAYERS;i++) Spectating[i] = -1;
  96. return 1;
  97. }
  98.  
  99. public OnPlayerConnect(playerid)
  100. {
  101. Spectating[playerid] = -1;
  102. return 1;
  103. }
  104.  
  105. public OnPlayerDisconnect(playerid, reason)
  106. {
  107. for(new i;i<MAX_PLAYERS;i++)
  108. {
  109. if(IsPlayerConnected(i) && Spectating[i] == playerid)
  110. {
  111. TogglePlayerSpectating(i, 0);
  112. GameTextForPlayer(i, " ", 10, 4);
  113. SendClientMessage(i,0xFFFFFFFF,"The player you was watching has disconnected");
  114. }
  115. }
  116. return 1;
  117. }
  118.  
  119. public OnPlayerSpawn(playerid)
  120. {
  121. for(new i;i<MAX_PLAYERS;i++)
  122. {
  123. if(IsPlayerConnected(i) && Spectating[i] == playerid)
  124. {
  125. TogglePlayerSpectating(i,0);
  126. TogglePlayerSpectating(i,1);
  127. if(!IsPlayerInAnyVehicle(playerid)) PlayerSpectatePlayer(i, playerid);
  128. else PlayerSpectateVehicle(i,GetPlayerVehicleID(playerid));
  129. SetPlayerInterior(i,GetPlayerInterior(playerid));
  130. Spectating[i] = playerid;
  131. new name[30],str[100];
  132. GetPlayerName(playerid, name, 30);
  133. format(str,65,"~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~%s (ID: %d)",name,playerid);
  134. GameTextForPlayer(i,str,99999,4);
  135. }
  136. }
  137. return 1;
  138. }
  139. public OnPlayerCommandText(playerid, cmdtext[])
  140. {
  141. if(!strcmp("/pspec", cmdtext, true, 3))
  142. {
  143. if(!strlen(cmdtext[5])) SendClientMessage(playerid,0xEE2222FF,"[ERROR] Usage: /pspec <id>");
  144. else
  145. {
  146. new id;
  147. id = strval(cmdtext[5]);
  148. if (CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
  149. else if(id > MAX_PLAYERS || id < 0 || !IsPlayerConnected(id)) SendClientMessage(playerid,0xEE2222FF,"Invalid Player ID");
  150. else
  151. {
  152. if(Spectating[playerid] == -1)
  153. {
  154. GetPlayerPos(playerid,coords[playerid][0],coords[playerid][1],coords[playerid][2]);
  155. Interior[playerid] = GetPlayerInterior(playerid);
  156. TogglePlayerSpectating(playerid, 1);
  157. }
  158. if(!IsPlayerInAnyVehicle(id)) PlayerSpectatePlayer(playerid, id);
  159. else PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));
  160. SetPlayerInterior(playerid,GetPlayerInterior(id));
  161. Spectating[playerid] = id;
  162. new name[30],str[100];
  163. GetPlayerName(id, name, 30);
  164. format(str,65,"~w~%s (ID: %d)~n~",name,id);
  165. GameTextForPlayer(playerid,str,99999,4);
  166. }
  167. }
  168. return 1;
  169. }
  170. else if(!strcmp("/pspecoff", cmdtext, true))
  171. {
  172. if(CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
  173. else
  174. {
  175. if(Spectating[playerid] == -1) SendClientMessage(playerid,0xEE2222FF,"You aren't watching anyone");
  176. else
  177. {
  178. TogglePlayerSpectating(playerid, 0);
  179. GameTextForPlayer(playerid, " ", 10, 4);
  180. }
  181. return 1;
  182. }
  183. }
  184. else if(!strcmp("/weapons", cmdtext, true,7))
  185. {
  186. if(!strlen(cmdtext[9])) SendClientMessage(playerid,0xEE2222FF,"[ERROR] Usage: /weapons <id>");
  187. else
  188. {
  189. new id;
  190. id = strval(cmdtext[9]);
  191. if(!IsPlayerAdmin(playerid) && CallRemoteFunction("GetPlayerLevel","i",playerid) < 2) return 0;
  192. else if(id > MAX_PLAYERS || id < 0 || !IsPlayerConnected(id)) SendClientMessage(playerid,0xEE2222FF,"Invalid Player ID");
  193. else
  194. {
  195. new weapons[13][2];
  196. for (new i;i<13;i++)
  197. {
  198. GetPlayerWeaponData(id,i,weapons[i][0],weapons[i][1]);
  199. }
  200. new str[3][256],strtmp,strindex;
  201. str[0] = "-";
  202. str[1] = "-";
  203. str[2] = "-";
  204. for(new i;i<13;i++)
  205. {
  206. if(weapons[i][0] != 0)
  207. {
  208. format(str[strtmp],256,"%s %s(%d ammo) -",str[strtmp],aWeaponNames[weapons[i][0]],weapons[i][1]);
  209. strindex++;
  210. if(strindex == 4 && strtmp < 2)
  211. {
  212. strindex = 0;
  213. strtmp++;
  214. }
  215. }
  216. }
  217. new string[200],Float:hp,Float:armour;
  218. GetPlayerHealth(id,hp);
  219. GetPlayerArmour(id,armour);
  220. format(string,200,"%.2f health, %.2f armour; Weapons:",hp, armour);
  221. SendClientMessage(playerid,0x339933FF,string);
  222. for(new i;i<3;i++) if(strcmp("-", str[i], true)) SendClientMessage(playerid,0x995555FF,str[i]);
  223. }
  224. }
  225. return 1;
  226. }
  227. return 0;
  228. }
  229.  
  230. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  231. {
  232. for(new i;i<MAX_PLAYERS;i++)
  233. {
  234. if(IsPlayerConnected(i) && Spectating[i] == playerid)
  235. {
  236. SetPlayerInterior(i,newinteriorid);
  237. }
  238. }
  239. return 1;
  240. }
  241.  
  242.  
  243. public OnPlayerStateChange(playerid, newstate, oldstate)
  244. {
  245. if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
  246. {
  247. for(new i;i<MAX_PLAYERS;i++)
  248. {
  249. if(IsPlayerConnected(i) && Spectating[i] == playerid)
  250. {
  251. PlayerSpectateVehicle(i,GetPlayerVehicleID(playerid));
  252. }
  253. }
  254. }
  255. else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
  256. {
  257. for(new i;i<MAX_PLAYERS;i++)
  258. {
  259. if(IsPlayerConnected(i) && Spectating[i] == playerid)
  260. {
  261. PlayerSpectatePlayer(i,playerid);
  262. }
  263. }
  264. }
  265. if (oldstate == PLAYER_STATE_SPECTATING)
  266. {
  267. SetPlayerPos(playerid,coords[playerid][0],coords[playerid][1],coords[playerid][2]);
  268. SetPlayerInterior(playerid,Interior[playerid]);
  269. Spectating[playerid] = -1;
  270. }
  271. return 1;
  272. }
Advertisement
Add Comment
Please, Sign In to add comment