Guest User

Untitled

a guest
Oct 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.09 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4. #define ISeeThisGuy(%0,%1) MyFriends[%0][showing][%1]
  5.  
  6. enum friendsinfo
  7. {
  8. bool:iknow[MAX_PLAYERS],
  9. bool:showing[MAX_PLAYERS]
  10. }
  11.  
  12. new MyFriends[MAX_PLAYERS][friendsinfo];
  13.  
  14. /*Comentarios
  15.  
  16. Na OnPlayerLogin:
  17. LoadMyFriendsInGame(playerid);
  18.  
  19. Na pInfo (PlayerInfo
  20. FriendRequest,
  21.  
  22. No /sms
  23. if(IsMyFriend(playerid, giveplayerid)) format(string, sizeof(string), "SMS: %s, de: %s (%d)", result,sendername,PlayerInfo[playerid][pPnumber]);
  24. else format(string, sizeof(string), "SMS: %s, de: Desconhecido (%d)", result,PlayerInfo[playerid][pPnumber]);
  25.  
  26. no /aceitar (comando /recusar abaixo)
  27. else if(strcmp(x_job,"amizade",true) == 0)
  28. {
  29. new str[128];
  30. if(!IsPlayerConnected(PlayerInfo[playerid][FriendRequest])) return SendClientMessage(playerid, COLOR_YELLOW, "{FF4040}[ERRO]{FFFFFF} Você não tem um pedido de amizade válido.");
  31.  
  32. MyNewFriend(playerid, PlayerInfo[playerid][FriendRequest]);
  33. MyNewFriend(PlayerInfo[playerid][FriendRequest], playerid);
  34. GetPlayerName(PlayerInfo[playerid][FriendRequest], str, MAX_PLAYER_NAME);
  35. format(str, sizeof str, "[AMIZADE] Você aceitou %s como seu amigo.", str);
  36. SendClientMessage(playerid, COLOR_YELLOW, str);
  37. GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  38. format(str, sizeof str, "[AMIZADE] %s te aceitou como amigo.", str);
  39. SendClientMessage(PlayerInfo[playerid][FriendRequest], COLOR_YELLOW, str);
  40. PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
  41. return 1;
  42. }
  43.  
  44. No OnPlayerText, na parte de ligações
  45. if(IsMyFriend(playerid, Mobile[playerid]))
  46. {
  47. format(string, sizeof(string), "%s fala (ao celular): %s", sendername, text);
  48. ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
  49. }
  50. else
  51. {
  52. ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
  53. format(string, sizeof(string), "Desconhecido fala (ao celular): %s", sendername, text);
  54. }
  55.  
  56.  
  57.  
  58. */
  59.  
  60. //esse é o para aparecer Desconhecido no ProxDectector
  61. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  62. {
  63. if(IsPlayerConnected(playerid))
  64. {
  65. new str[256], pos, Float:posx, Float:posy, Float:posz, Float:oldposx,
  66. Float:oldposy, Float:oldposz, Float:tempposx, Float:tempposy,
  67. Float:tempposz;
  68.  
  69. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  70.  
  71. pos = strfind(string, GetNick(playerid));
  72. strcat(str, string, 256);
  73.  
  74. if(pos != -1)
  75. {
  76. strdel(str, pos, pos + strlen(GetNick(playerid)));
  77. strins(str, "Desconhecido", pos, 256);
  78. }
  79. else
  80. {
  81. pos = strfind(string, NomeEx(playerid));
  82. if(pos != -1)
  83. {
  84. strdel(str, pos, pos + strlen(NomeEx(playerid)));
  85. strins(str, "Desconhecido", pos, 256);
  86. }
  87. }
  88. //radi = 2.0; //Trigger Radius
  89. for(new i = 0; i < MAX_PLAYERS; i++)
  90. {
  91. if(IsPlayerConnected(i))
  92. {
  93. GetPlayerPos(i, posx, posy, posz);
  94. tempposx = (oldposx -posx);
  95. tempposy = (oldposy -posy);
  96. tempposz = (oldposz -posz);
  97. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  98. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  99. {
  100. if(IsMyFriend(playerid, i)) SendClientMessage(i, col1, string);
  101. else
  102. {
  103. if(i != playerid) SendClientMessage(i, col1, str);
  104. else SendClientMessage(i, col1, string);
  105. }
  106. }
  107. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  108. {
  109. if(IsMyFriend(playerid, i)) SendClientMessage(i, col2, string);
  110. else
  111. {
  112. if(i != playerid) SendClientMessage(i, col2, str);
  113. else SendClientMessage(i, col2, string);
  114. }
  115. }
  116. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  117. {
  118. if(IsMyFriend(playerid, i)) SendClientMessage(i, col3, string);
  119. else
  120. {
  121. if(i != playerid) SendClientMessage(i, col3, str);
  122. else SendClientMessage(i, col3, string);
  123. }
  124. }
  125. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  126. {
  127. if(IsMyFriend(playerid, i)) SendClientMessage(i, col4, string);
  128. else
  129. {
  130. if(i != playerid) SendClientMessage(i, col4, str);
  131. else SendClientMessage(i, col4, string);
  132. }
  133. }
  134. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  135. {
  136. if(IsMyFriend(playerid, i)) SendClientMessage(i, col5, string);
  137. else
  138. {
  139. if(i != playerid) SendClientMessage(i, col5, str);
  140. else SendClientMessage(i, col5, string);
  141. }
  142. }
  143. }
  144. else
  145. {
  146. if(IsMyFriend(playerid, i)) SendClientMessage(i, col1, string);
  147. else
  148. {
  149. if(i != playerid) SendClientMessage(i, col1, str);
  150. else SendClientMessage(i, col1, string);
  151. }
  152. }
  153. }
  154. }//not connected
  155. return 1;
  156. }
  157.  
  158. IsMyFriend(playerid, thisguy)
  159. {
  160. if(MyFriends[playerid][iknow][thisguy])
  161. {
  162. MyFriends[playerid][showing][thisguy] = true;
  163. return true;
  164. }
  165. MyFriends[playerid][showing][thisguy] = false;
  166. return false;
  167. }
  168.  
  169. LoadMyFriendsInGame(playerid)
  170. {
  171. new str[64];
  172. GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  173. format(str, sizeof str, "FriendsOf/%s.ini", str);
  174. if(dini_Exists(str))
  175. {
  176. for(new i = 0; i < MAX_PLAYERS; i++)
  177. {
  178. if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
  179. format(str, sizeof str, "FriendsOf/%s.ini", GetNick(playerid));
  180. if(dini_Isset(str, GetNick(i)))
  181. {
  182. MyFriends[playerid][iknow][i] = true;
  183. MyFriends[playerid][showing][i] = true;
  184. MyFriends[i][iknow][playerid] = true;
  185. MyFriends[i][showing][playerid] = true;
  186. ShowPlayerNameTagForPlayer(playerid, i, true);
  187. ShowPlayerNameTagForPlayer(i, playerid, true);
  188. }
  189. }
  190. }
  191. return 1;
  192. }
  193.  
  194. MyNewFriend(playerid, otherplayer)
  195. {
  196. if(!IsPlayerConnected(otherplayer) || !IsPlayerConnected(playerid)) return 1;
  197. new str[64];
  198. GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  199. format(str, sizeof str, "FriendsOf/%s.ini", str);
  200. if(dini_Exists(str)) dini_IntSet(str, GetNick(otherplayer), 1);
  201. else
  202. {
  203. dini_Create(str);
  204. dini_IntSet(str, GetNick(otherplayer), 1);
  205. return 1;
  206. }
  207. MyFriends[playerid][iknow][otherplayer] = true;
  208. MyFriends[playerid][showing][otherplayer] = true;
  209. MyFriends[otherplayer][iknow][playerid] = true;
  210. MyFriends[otherplayer][showing][playerid] = true;
  211. ShowPlayerNameTagForPlayer(playerid, otherplayer, true);
  212. ShowPlayerNameTagForPlayer(otherplayer, playerid, true);
  213. return 1;
  214. }
  215.  
  216. public OnPlayerConnect(playerid)
  217. {
  218. PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
  219. return 1;
  220. }
  221.  
  222. public OnPlayerDisconnect(playerid, reason)
  223. {
  224. for(new i = 0; i < MAX_PLAYERS; i++)
  225. {
  226. if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  227. {
  228. MyFriends[i][iknow][playerid] = false;
  229. MyFriends[i][showing][playerid] = false;
  230. }
  231. }
  232. return 1;
  233. }
  234.  
  235. public OnPlayerCommandText(playerid, cmdtext[])
  236. {
  237. if(!strcmp("/solicitaramizade", cmd, true))
  238. {
  239. new str[128];
  240. tmp = strtok(cmdtext, idx);
  241.  
  242. if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "{00ca3e}USE:{FFFFFF} /solicitaramizade [playerid/parte do nome]");
  243.  
  244. new newfriend = ReturnUser(tmp);
  245.  
  246. if(!IsPlayerConnected(newfriend)) return SendClientMessage(playerid, COLOR_GREY, "{FF4040}[ERRO]{FFFFFF} O jogador está desconectado.");
  247. if(IsMyFriend(playerid, newfriend)) return SendClientMessage(playerid, COLOR_GREY, "{FF4040}[ERRO]{FFFFFF} O jogador já é seu amigo.");
  248.  
  249. GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  250. PlayerInfo[newfriend][FriendRequest] = playerid;
  251. format(str, sizeof str, "[AMIZADE] %s quer ser seu amigo, para aceitar o pedido use /Aceitar [Amizade].", str);
  252. SendClientMessage(newfriend, COLOR_YELLOW, str);
  253. SendClientMessage(newfriend, COLOR_YELLOW, "[AMIZADE] Para recusar o convite use /Recusar [Amizade].");
  254. GetPlayerName(newfriend, str, MAX_PLAYER_NAME);
  255. format(str, sizeof str, "[AMIZADE] Você enviou um pedido de amizade para %s.", str);
  256. SendClientMessage(playerid, COLOR_YELLOW, str);
  257. return 1;
  258. }
  259.  
  260. if(strcmp(cmd,"/recusar",true)==0)
  261. {
  262. new item[256];
  263. item = strtok(cmdtext, idx);
  264. if(!strlen(item))
  265. {
  266. SendClientMessage(playerid, COLOR_BRANCO, "|__________________ Recusar __________________|");
  267. SendClientMessage(playerid, COLOR_BRANCO, "{00ca3e}USE:{FFFFFF} /recusar [nome]");
  268. SendClientMessage(playerid, COLOR_GREY, "Nomes disponiveis: amizade");
  269. SendClientMessage(playerid, COLOR_BRANCO, "|____________________________________________|");
  270. return 1;
  271. }
  272. else if(strcmp(item,"amizade",true) == 0)
  273. {
  274. new str[128];
  275. if(!IsPlayerConnected(PlayerInfo[playerid][FriendRequest])) return SendClientMessage(playerid, COLOR_YELLOW, "{FF4040}[ERRO]{FFFFFF} O pedido expirou.");
  276. GetPlayerName(PlayerInfo[playerid][FriendRequest], str, MAX_PLAYER_NAME);
  277. format(str, sizeof str, "[AMIZADE] Você recusou o pedido de amizade de %s.", str);
  278. SendClientMessage(playerid, COLOR_YELLOW, str);
  279. GetPlayerName(playerid, str, MAX_PLAYER_NAME);
  280. format(str, sizeof str, "[AMIZADE] %s recusou seu pedido de amizade.", str);
  281. SendClientMessage(PlayerInfo[playerid][FriendRequest], COLOR_YELLOW, str);
  282. PlayerInfo[playerid][FriendRequest] = INVALID_PLAYER_ID;
  283. return 1;
  284. }
  285. return 1;
  286. }
  287.  
  288. if(!strcmp("/nametags", cmd, true))
  289. {
  290. if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "{FF4040}[ERRO]{FFFFFF} Você não pode usar este comando.");
  291.  
  292. tmp = strtok(cmdtext, idx);
  293.  
  294. if(!strlen(tmp)) return SendClientMessage(playerid, -1, "{00ca3e}USE:{FFFFFF} /nametags [on] ou [off].");
  295.  
  296. if(strfind(cmdtext, "/nametags on") == 0)
  297. {
  298. for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, true);
  299. SendClientMessage(playerid, -1, "{00ca3e}[INFO]{FFFFFF} Agora você pode ver todos os nomes.");
  300. return 1;
  301. }
  302. else if (strfind(cmdtext, "/nametags off") == 0)
  303. {
  304. for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(playerid, i, false);
  305. LoadMyFriendsInGame(playerid);
  306. SendClientMessage(playerid, -1, "{00ca3e}[INFO]{FFFFFF} Modo de ver todos os nomes desativado.");
  307. return 1;
  308. }
  309. return SendClientMessage(playerid, -1, "{00ca3e}USE:{FFFFFF} /nametags [on] ou [off].");
  310. }
  311. return 0;
  312. }
  313.  
  314. public OnPlayerStreamIn(playerid, forplayerid)
  315. {
  316. if(IsMyFriend(forplayerid, playerid))
  317. {
  318. ShowPlayerNameTagForPlayer(forplayerid, playerid, true);
  319. ShowPlayerNameTagForPlayer(playerid, forplayerid, true);
  320. return 1;
  321. }
  322. ShowPlayerNameTagForPlayer(forplayerid, playerid, false);
  323. ShowPlayerNameTagForPlayer(playerid, forplayerid, false);
  324. return 1;
  325. }
Add Comment
Please, Sign In to add comment