Guest User

Conhecer Player

a guest
May 13th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sINI>
  3.  
  4. public OnGameModeInit()
  5. {
  6. file_OS();
  7. return 1;
  8. }
  9. public OnPlayerSpawn(playerid)
  10. {
  11. if(GetPVarInt(playerid,"primeiro_spawn") == 0)
  12. {
  13. new ficheiroc[40];
  14. format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(playerid));
  15. if(!fexist(ficheiroc))
  16. {
  17. file_Create(ficheiroc);
  18. file_Open(ficheiroc);
  19. file_SetVal(GetPlayerNameEx(playerid),1);
  20. file_Save(ficheiroc);
  21. file_Close();
  22. }
  23. for(new i = 0; i < MAX_PLAYERS; i++)
  24. {
  25. if(!IsPlayerNPC(playerid) && !IsPlayerNPC(i) && IsPlayerConnected(i))
  26. {
  27. format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(playerid));
  28. file_Open(ficheiroc);
  29. if(file_IsKey(GetPlayerNameEx(i)))
  30. {
  31. SetPVarInt(playerid,GetPlayerNameEx(i),file_GetVal(GetPlayerNameEx(i)));
  32. if(GetPVarInt(playerid,GetPlayerNameEx(i)) == 1)
  33. {
  34. ShowPlayerNameTagForPlayer(i, playerid, true);
  35. }
  36. else if(GetPVarInt(playerid,GetPlayerNameEx(i)) == 0)
  37. {
  38. ShowPlayerNameTagForPlayer(i, playerid, false);
  39. }
  40. }
  41. else
  42. {
  43. file_SetVal(GetPlayerNameEx(i),0);
  44. file_Save(ficheiroc);
  45. }
  46. file_Close();
  47. format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(i));
  48. file_Open(ficheiroc);
  49. if(file_IsKey(GetPlayerNameEx(playerid)))
  50. {
  51. SetPVarInt(i,GetPlayerNameEx(playerid),file_GetVal(GetPlayerNameEx(playerid)));
  52. if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 1)
  53. {
  54. ShowPlayerNameTagForPlayer(playerid, i, true);
  55. }
  56. else if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 0)
  57. {
  58. ShowPlayerNameTagForPlayer(playerid, i, false);
  59. }
  60. }
  61. else
  62. {
  63. file_SetVal(GetPlayerNameEx(playerid),0);
  64. file_Save(ficheiroc);
  65. }
  66. file_Close();
  67. }
  68. }
  69. SetPVarInt(playerid,"primeiro_spawn",1);
  70. }
  71. return 1;
  72. }
  73. public OnPlayerText(playerid, text[])
  74. {
  75. if(strfind(text, GetPlayerNameEx(playerid), true) == 0)
  76. {
  77. new ficheiroc[40];
  78. for(new i=0; i<MAX_PLAYERS; i++)
  79. {
  80. format(ficheiroc, sizeof(ficheiroc), "Conhecer/%s.ini",GetPlayerNameEx(i));
  81. file_Open(ficheiroc);
  82. if(i != playerid && IsPlayerConnected(i) && !IsPlayerNPC(i))
  83. {
  84. if(ProxDetectorS(5.0, playerid, i))
  85. {
  86. if(GetPVarInt(i,GetPlayerNameEx(playerid)) == 0)
  87. {
  88. file_SetVal(GetPlayerNameEx(playerid),1);
  89. SetPVarInt(playerid,GetPlayerNameEx(playerid),1);
  90. ShowPlayerNameTagForPlayer(i, playerid, true);
  91. }
  92. }
  93. }
  94. file_Save(ficheiroc);
  95. file_Close();
  96. }
  97. }
  98. return 1;
  99. }
  100. public OnPlayerConnect(playerid)
  101. {
  102. SetPVarInt(playerid,"primeiro_spawn",0);
  103. return 1;
  104. }
  105. public OnPlayerRequestClass(playerid)
  106. {
  107. if(GetPVarInt(playerid,"primeiro_spawn") == 0)
  108. {
  109. for(new i=0; i<MAX_PLAYERS; i++)
  110. {
  111. if(i != playerid && IsPlayerConnected(i) && !IsPlayerNPC(i))
  112. {
  113. SetPVarInt(playerid,GetPlayerNameEx(i),0);
  114. SetPVarInt(i,GetPlayerNameEx(playerid),0);
  115. ShowPlayerNameTagForPlayer(i, playerid, false);
  116. ShowPlayerNameTagForPlayer(playerid, i, false);
  117. }
  118. }
  119. }
  120. return 1;
  121. }
  122. stock GetPlayerNameEx(playerid)
  123. {
  124. new NomePlayer[MAX_PLAYER_NAME];
  125. GetPlayerName(playerid,NomePlayer,sizeof(NomePlayer));
  126. return NomePlayer;
  127. }
  128. forward ProxDetectorS(Float:radi, playerid, targetid);
  129. public ProxDetectorS(Float:radi, playerid, targetid)
  130. {
  131. if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
  132. {
  133. new Float:posx, Float:posy, Float:posz;
  134. new Float:oldposx, Float:oldposy, Float:oldposz;
  135. new Float:tempposx, Float:tempposy, Float:tempposz;
  136. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  137. //radi = 2.0; //Trigger Radius
  138. GetPlayerPos(targetid, posx, posy, posz);
  139. tempposx = (oldposx -posx);
  140. tempposy = (oldposy -posy);
  141. tempposz = (oldposz -posz);
  142. //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  143. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  144. {
  145. return 1;
  146. }
  147. }
  148. return 0;
Advertisement
Add Comment
Please, Sign In to add comment