Guest User

Untitled

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