Guest User

PJER-AC 0.2.2

a guest
Feb 13th, 2020
155
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #define YSI_YES_HEAP_MALLOC
  3. #include <YSI_Coding\y_timers>
  4. #include <YSI_Coding\y_hooks>
  5. #include <YSI_Coding\y_iterate>
  6.  
  7. #define MSG SendClientMessage
  8. #define DYNAMIC_MEMORY_IS_DYN 32
  9. #define MSGE SendClientMessageToAll
  10.  
  11. #if !defined MAX_PLAYER_NAME
  12. #define MAX_PLAYER_NAME 24
  13. #endif
  14.  
  15. #if !defined MAX_PLAYERS
  16. #define MAX_PLAYERS 1000
  17. #endif
  18.  
  19. hook OnGameModeInit()
  20. {
  21.     printf("PJER-AC LOADED.");
  22.     LocUpdate();
  23.     return 1;
  24. }
  25.  
  26. hook OnGameModeExit()
  27. {
  28.     printf("PJER-AC UNLOADED.");
  29.     return 1;
  30. }
  31.  
  32. forward [MAX_PLAYER_NAME+1]imeigraca(playerid);
  33. stock imeigraca(playerid)
  34. {
  35. #assert MAX_PLAYER_NAME + 1 == 25
  36. #emit PUSH.C 25
  37. #emit PUSH.S 16
  38. #emit PUSH.S playerid
  39. #emit PUSH.C 12
  40. #emit SYSREQ.C GetPlayerName
  41. #emit STACK 16
  42. #emit RETN
  43. }
  44.  
  45. stock Float:udaljenost(Float:x1,Float:y1,Float:z1, Float:x2,Float:y2,Float:z2)
  46. {
  47.     return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
  48. }
  49.  
  50. new Float:_LOKACIJA__x[MAX_PLAYERS];
  51. new Float:_LOKACIJA__y[MAX_PLAYERS];
  52. new Float:_LOKACIJA__z[MAX_PLAYERS];
  53. new igracstvoren[MAX_PLAYERS];
  54. new igrac_desync[MAX_PLAYERS];
  55.  
  56. stock pac_SetPlayerPos(playerid, Float:x, Float:y, Float:z)
  57. {
  58.     _LOKACIJA__x[playerid] = x;
  59.     _LOKACIJA__y[playerid] = y;
  60.     _LOKACIJA__z[playerid] = z;
  61.     return SetPlayerPos(playerid, x, y, z);
  62. }
  63.  
  64. #if defined _ALS_SetPlayerPos
  65.     #undef SetPlayerPos
  66. #else
  67.     #define _ALS_SetPlayerPos
  68. #endif
  69. #define SetPlayerPos pac_SetPlayerPos
  70.  
  71. task LocUpdate[270](){
  72.     foreach(new i : Player)
  73.         GetPlayerPos(i, _LOKACIJA__x[i], _LOKACIJA__y[i], _LOKACIJA__z[i]);
  74. }
  75.  
  76. hook OnPlayerConnect(playerid)
  77. {
  78.     igrac_desync[playerid] = 0;
  79.     igracstvoren[playerid] = 0;
  80.     return 1;
  81. }
  82.  
  83. forward OnPlayerTeleport(playerid, Float:daljina);
  84. public OnPlayerTeleport(playerid, Float:daljina)
  85. {
  86.     new string[DYNAMIC_MEMORY_IS_DYN+0];// dynamic safe string
  87.     MSG(playerid,-1,"Vi ste kikovani zbog citovanja #00.");
  88.     format(string,DYNAMIC_MEMORY_IS_DYN,"%s je kikovan (#00).", imeigraca(playerid));
  89.     MSGE(-1, string);
  90.     printf(string);
  91.     igrac_desync[playerid] = 1;
  92.     SetTimerEx("Handle_Kick", 1000, false, "i", playerid);
  93.     return 1;
  94. }
  95.  
  96. forward Handle_Kick(playerid);
  97. public Handle_Kick(playerid){
  98.     igracstvoren[playerid] = 0;
  99.     Kick(playerid);
  100.     return 1;
  101. }
  102.  
  103. hook OnPlayerSpawn(playerid)
  104. {
  105.     igracstvoren[playerid] = 1;
  106.     return 1;
  107. }
  108.  
  109. hook OnPlayerDeath(playerid, killerid, reason)
  110. {
  111.     igracstvoren[playerid] = 0;
  112.     return 1;
  113. }
  114.  
  115. hook OnPlayerUpdate(playerid)
  116. {
  117.     new Float:dist = 0.0;
  118.     new Float:xplayer[3];
  119.     foreach(new i : Player){
  120.         if(igrac_desync[i] == 1) continue;
  121.         GetPlayerPos(i,xplayer[0],xplayer[1],xplayer[2]);
  122.         if(igracstvoren[i]==0) continue;
  123.         if(udaljenost(xplayer[0],xplayer[1],xplayer[2],_LOKACIJA__x[i],_LOKACIJA__y[i],_LOKACIJA__z[i]) > 25.0)
  124.             OnPlayerTeleport(i,dist);
  125.     }
  126.     return 1;
  127. }
RAW Paste Data