1
0

chat.inc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. forward NewProxDetector(playerid, Float:range, statictext[], msg[], colour);
  2. forward GetColorValue(colour, mode);
  3. forward SetRGB(colour, mode, value);
  4. //used for testing
  5. //#define coords 1555.08, -1675.55, 16.19
  6. public NewProxDetector(playerid, Float:range, statictext[], msg[], colour) {
  7. //Get individual colour values
  8. new red = GetColorValue(colour, 'r');
  9. new green = GetColorValue(colour, 'g');
  10. new blue = GetColorValue(colour, 'b');
  11. //Keep original for chat bubble
  12. new original[144];
  13. format(original, sizeof(original), "%s%s", statictext, msg);
  14. //Add in accents, statictext is now neglected
  15. new staticstr[MAX_PLAYER_NAME+50];
  16. format(staticstr, sizeof(staticstr), "%s", statictext); // accent is already set
  17. //if(strcmp(Accent[playerid], "none", true, 3)) format(staticstr, sizeof(staticstr), "%s[%s Accent] ", statictext, Accent[playerid]);
  18. //else format(staticstr, sizeof(staticstr), "%s", statictext);
  19. new string[144];
  20. format(string, sizeof(string), "%s%s", staticstr, msg);
  21. SendClientMessage(playerid, colour, string);
  22. new Float:tarx, Float:tary, Float:tarz;
  23. GetPlayerPos(playerid, tarx, tary, tarz);
  24. new vw = GetPlayerVirtualWorld(playerid);
  25. foreach(new pid: Player) {
  26. if(pid == playerid) continue;
  27. if(!IsPlayerConnected(playerid)) continue;
  28. if(GetPlayerVirtualWorld(pid) != vw) continue;
  29. //Is player in range?
  30. new Float:x, Float:y, Float:z;
  31. GetPlayerPos(pid, x, y, z);
  32. new Float:dist = GetPointDistanceToPointExMorph(x, y, z, tarx, tary, tarz);
  33. if(dist <= range) {
  34. //Get individual colours, decrease by some dependent scalar
  35. new pr = red, pg = green, pb = blue;
  36. new scalar = floatround(140/range); //140 RGB values
  37. pr -= scalar*floatround(dist);
  38. pg -= scalar*floatround(dist);
  39. pb -= scalar*floatround(dist);
  40. //Jumble the text message up.
  41. /* if(dist >= 0.8*floatround(range)) {
  42. new step = 4 + floatround(range-dist);
  43. new i;
  44. while(i < strlen(msg)) {
  45. msg[i] = random(255);
  46. if(msg[i] > 190) i++;
  47. else i += step;
  48. }
  49. }
  50. */
  51. new col;
  52. //Set the colours
  53. col = SetRGB(colour, 'r', pr);
  54. col = SetRGB(col, 'g', pg);
  55. col = SetRGB(col, 'b', pb);
  56. //Send it
  57. format(string, sizeof(string), "%s%s", staticstr, msg);
  58. SendClientMessage(pid, col, string);
  59. }
  60. }
  61. //Finally, show chat bubble
  62. if(ThiefText[playerid] != Text3D:INVALID_3DTEXT_ID) return 1;
  63. if(nametagText[playerid] != Text3D:INVALID_3DTEXT_ID) return 1;
  64. SetPlayerChatBubble(playerid, original, colour, 0.3*floatround(range), 10000);
  65. return 1;
  66. }
  67. public GetColorValue(colour, mode) {
  68. switch(mode) {
  69. case 'r', 'R':
  70. return (colour & 0xFF000000) >>> 24;
  71. case 'g', 'G':
  72. return (colour & 0x00FF0000) >>> 16;
  73. case 'b', 'B':
  74. return (colour & 0x0000FF00) >>> 8;
  75. }
  76. return 0xFF;
  77. }
  78. public SetRGB(colour, mode, value) {
  79. switch(mode) {
  80. case 'r', 'R':
  81. return (colour & 0x00FFFFFF | (0xFF000000 & (value) << 24));
  82. case 'g', 'G':
  83. return (colour & 0xFF00FFFF | (0x00FF0000 & (value) << 16));
  84. case 'b', 'B':
  85. return (colour & 0xFFFF00FF | (0x0000FF00 & (value) << 8));
  86. }
  87. return colour;
  88. }
  89. //=============[ Commands ]=============
  90. //To be optimized later
  91. CMD:s(playerid, params[]) return cmd_shout(playerid, params);
  92. CMD:shout(playerid, params[])
  93. {
  94. if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "You havent logged in yet.");
  95. if(pDeathState[playerid] == PLAYER_STATE_INHOSP || WatchingTV[playerid] == true) return 1;
  96. if(pDeathState[playerid] == PLAYER_STATE_REVIVE) //injured players cannot speak
  97. {
  98. SendClientMessage(playerid, -1, "You're too tired to say anything.");
  99. new str[128];
  100. format(str, sizeof(str), "* %s tries to mumble something", PlayerICName(playerid));
  101. SetPlayerChatBubble(playerid, str, COLOR_PURPLE, 20.0, 15000);
  102. return 0;
  103. }
  104. if(pDeathState[playerid] == PLAYER_STATE_REVIVE){
  105. }
  106. if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't use this whilst muted.");
  107. new result[128];
  108. new str[144];
  109. if(sscanf(params, "s[128]", result)) return SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} (/s)hout [local chat]");
  110. // Gagged
  111. if(IsPlayerGagged(playerid)) {
  112. SendClientMessage(playerid, COLOR_GREY, "The gag in your mouth makes you unable to speak...");
  113. new gagStr[128];
  114. format(gagStr, sizeof(gagStr), "* %s tries to mumble something loudly.", PlayerICName(playerid));
  115. SetPlayerChatBubble(playerid, gagStr, COLOR_PURPLE, 20.0, 15000);
  116. return 1;
  117. }
  118. /*foreach( new i: Player )
  119. {
  120. if(PlayerInfo[i][pWire] == 1 && !CheckForJammer(playerid) && !CheckForJammer(i))
  121. {
  122. new Float: x[3];
  123. GetPlayerPos(playerid, x[0], x[1], x[2]);
  124. if(IsPlayerInRangeOfPoint(i, 30.0, x[0], x[1], x[2]))
  125. {
  126. if(i == playerid)
  127. {
  128. if(strcmp(Accent[i], "none", true, 3)) format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s: [%s Accent] %s!", PlayerICName(i), Accent[i], result);
  129. else format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s: %s!", PlayerICName(i), result);
  130. }
  131. else
  132. {
  133. if(strcmp(Accent[playerid], "none", true, 3)) format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings: [%s Accent] %s!", PlayerICName(i), Accent[playerid], result);
  134. else format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings: %s!", PlayerICName(i), result);
  135. }
  136. foreach( new fbi: Player )
  137. {
  138. if(PlayerInfo[fbi][pMember] == 2 || PlayerInfo[fbi][pMember] == 11)
  139. {
  140. if(IsPlayerInAnyVehicle(fbi))
  141. {
  142. if(sVehicleInfo[GetDynamicVehicleID(GetPlayerVehicleID(fbi))][v_faction] == 2 || sVehicleInfo[GetDynamicVehicleID(GetPlayerVehicleID(fbi))][v_faction] == 11 && GetVehicleModel(GetPlayerVehicleID(fbi)) == 482)
  143. {
  144. SendClientMessage(fbi, COLOR_ORANGE, str);
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }*/
  152. foreach( new i: Player )
  153. {
  154. if(PlayerInfo[i][pWire] == 1 && !CheckForJammer(playerid) && !CheckForJammer(i))
  155. {
  156. new Float: x[3];
  157. GetPlayerPos(playerid, x[0], x[1], x[2]);
  158. if(IsPlayerInRangeOfPoint(i, 20.0, x[0], x[1], x[2]))
  159. {
  160. if(i == playerid)
  161. {
  162. if(strcmp(Accent[i], "none", true, 3)) format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s: [%s Accent] %s!", PlayerICName(i), Accent[i], result);
  163. else format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s: %s!", PlayerICName(i), result);
  164. }
  165. else
  166. {
  167. if(strcmp(Accent[playerid], "none", true, 3)) format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings: [%s Accent] %s!", PlayerICName(i), Accent[playerid], result);
  168. else format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings: %s!", PlayerICName(i), result);
  169. }
  170. if(PlayerInfo[i][pMember] != 2) // if player isn't FBI, send to both FBI and S9
  171. {
  172. SendBuggedMessage(COLOR_ORANGE, str);
  173. SendS9BuggedMessage(COLOR_ORANGE, str);
  174. }
  175. else SendS9BuggedMessage(COLOR_ORANGE, str); // if player is FBI, send to S9 only, this is to avoid FBI figuring out
  176. // that s9 bugged them
  177. }
  178. }
  179. }
  180. new string[MAX_PLAYER_NAME+10];
  181. format(string, sizeof(string), "%s shouts: ", PlayerICName(playerid));
  182. NewProxDetector(playerid, 30.0, string, result, COLOR_FADE1);
  183. return 1;
  184. }
  185. CMD:l(playerid, params[]) return cmd_low(playerid, params);
  186. CMD:low(playerid, params[])
  187. {
  188. new msg[128];
  189. new str[144];
  190. if(!sscanf(params, "s[128]", msg))
  191. {
  192. if(gPlayerLogged[playerid] == 0)
  193. {
  194. SendClientMessage(playerid, COLOR_GREY, "You havent logged in yet.");
  195. return 1;
  196. }
  197. if(pDeathState[playerid] == PLAYER_STATE_INHOSP || ThiefText[playerid] != Text3D:INVALID_3DTEXT_ID || WatchingTV[playerid] == true) return 1;
  198. if(PlayerInfo[playerid][pMuted] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't use this whilst muted.");
  199. // Gagged
  200. if(IsPlayerGagged(playerid)) {
  201. SendClientMessage(playerid, COLOR_GREY, "The gag in your mouth makes you unable to speak...");
  202. new gagStr[128];
  203. format(gagStr, sizeof(gagStr), "* %s tries to mumble something quietly.", PlayerICName(playerid));
  204. SetPlayerChatBubble(playerid, gagStr, COLOR_PURPLE, 20.0, 15000);
  205. return 1;
  206. }
  207. /*foreach( new i: Player )
  208. {
  209. if(PlayerInfo[i][pWire] == 1 && !CheckForJammer(playerid) && !CheckForJammer(i))
  210. {
  211. new Float: x[3];
  212. GetPlayerPos(playerid, x[0], x[1], x[2]);
  213. if(IsPlayerInRangeOfPoint(i, 5.0, x[0], x[1], x[2]))
  214. {
  215. if(i == playerid)
  216. {
  217. format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s [low]: %s", PlayerOOCName(i), msg);
  218. }
  219. else
  220. {
  221. format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings [low]: %s", PlayerOOCName(i), msg);
  222. }
  223. foreach( new fbi: Player )
  224. {
  225. if(PlayerInfo[fbi][pMember] == 2 || PlayerInfo[fbi][pMember] == 11)
  226. {
  227. if(IsPlayerInAnyVehicle(fbi))
  228. {
  229. if(sVehicleInfo[GetDynamicVehicleID(GetPlayerVehicleID(fbi))][v_faction] == 2 || sVehicleInfo[GetDynamicVehicleID(GetPlayerVehicleID(fbi))][v_faction] == 11 && GetVehicleModel(GetPlayerVehicleID(fbi)) == 482)
  230. {
  231. SendClientMessage(fbi, COLOR_ORANGE, str);
  232. }
  233. }
  234. }
  235. }
  236. }
  237. }
  238. }*/
  239. foreach( new i: Player )
  240. {
  241. if(PlayerInfo[i][pWire] == 1 && !CheckForJammer(playerid) && !CheckForJammer(i))
  242. {
  243. new Float: x[3];
  244. GetPlayerPos(playerid, x[0], x[1], x[2]);
  245. if(IsPlayerInRangeOfPoint(i, 20.0, x[0], x[1], x[2]))
  246. {
  247. if(i == playerid)
  248. {
  249. format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s [low]: %s", PlayerOOCName(i), msg);
  250. }
  251. else
  252. {
  253. format(str, sizeof(str), "{8D8DFF}(BUGGED){AFAFAF} %s's surroundings [low]: %s", PlayerOOCName(i), msg);
  254. }
  255. if(PlayerInfo[i][pMember] != 2) // if player isn't FBI, send to both FBI and S9
  256. {
  257. SendBuggedMessage(COLOR_ORANGE, str);
  258. SendS9BuggedMessage(COLOR_ORANGE, str);
  259. }
  260. else SendS9BuggedMessage(COLOR_ORANGE, str); // if player is FBI, send to S9 only, this is to avoid FBI figuring out
  261. // that s9 bugged them
  262. }
  263. }
  264. }
  265. if(!IsPlayerInAnyVehicle(playerid))
  266. {
  267. format(str, sizeof(str), "%s [low]: ", PlayerICName(playerid));
  268. NewProxDetector(playerid, 5.0, str, msg, COLOR_GREY);
  269. }
  270. else
  271. {
  272. if(VehicleHasWindows(GetPlayerVehicleID(playerid)))
  273. {
  274. if(windowsDown[GetPlayerVehicleID(playerid)] == false)
  275. {
  276. format(str, sizeof(str), "(vehicle) %s [low]: %s", PlayerICName(playerid), msg);
  277. CarMessage(playerid, COLOR_GREY, str);
  278. }
  279. else
  280. {
  281. format(str, sizeof(str), "%s [low]: ", PlayerICName(playerid));
  282. NewProxDetector(playerid, 5.0, str, msg, COLOR_GREY);
  283. }
  284. }
  285. else
  286. {
  287. format(str, sizeof(str), "%s [low]: ", PlayerICName(playerid));
  288. NewProxDetector(playerid, 5.0, str, msg, COLOR_GREY);
  289. }
  290. }
  291. }
  292. else
  293. {
  294. SendClientMessage(playerid, COLOR_GREY, "{00BFFF}Usage:{FFFFFF} (/l)ow [local chat]");
  295. }
  296. return 1;
  297. }