Advertisement
arturo24

Anti TP To Avoid Death

Jun 27th, 2022
804
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include a_samp
  2.  
  3. new LastDamaeTime[MAX_PLAYERS], lastdamager[MAX_PLAYERS char], LastPCarDamage[MAX_PLAYERS];
  4.  
  5. stock SetPlayerPosX(playerid, Float:X, Float:Y, Float:Z)
  6. {
  7.     new timez = gettime();
  8.     if(( timez - LastDamaeTime[playerid] ) < 4)
  9.     {
  10.         new string[150];
  11.         if(IsPlayerConnected(lastdamager{playerid}))
  12.         {
  13.             new pnamez[MAX_PLAYER_NAME];
  14.             GetPlayerName(lastdamager{playerid}, pnamez, sizeof pnamez);
  15.             format(string, sizeof string,"System tried to teleport to you to another area, while you've just took damage from %s(%d) and we prevent that.",
  16.             pnamez, lastdamager{playerid});
  17.         }
  18.         else
  19.         {
  20.             format(string, sizeof string,"System tried to teleport to you to another area, while you've just took damage from Unknown(idk) and we prevent that.");
  21.         }
  22.         SendClientMessage(playerid, -1, string);
  23.     }
  24.     else if(( timez - LastPCarDamage[playerid] ) < 4)
  25.     {
  26.         new string[150];
  27.         if(IsPlayerConnected(lastdamager{playerid}))
  28.         {
  29.             new pnamez[MAX_PLAYER_NAME];
  30.             GetPlayerName(lastdamager{playerid}, pnamez, sizeof pnamez);
  31.             format(string, sizeof string,"System tried to teleport to you to another area, while your vehicle just took damage from %s(%d) and we prevent that.",
  32.             pnamez, lastdamager{playerid});
  33.         }
  34.         else
  35.         {
  36.             format(string, sizeof string,"System tried to teleport to you to another area, while your vehicle just took damage from Unknown(idk) and we prevent that.");
  37.         }
  38.         SendClientMessage(playerid, -1, string);
  39.     }
  40.     else
  41.     {
  42.         SetPlayerPos(playerid, X, Y, Z);
  43.     }
  44.     return 1;
  45. }
  46.  
  47. #define SetPlayerPos SetPlayerPosX
  48.  
  49. public OnPlayerConnect(playerid)
  50. {
  51.     LastDamaeTime[playerid] = 0;
  52.     lastdamager{playerid} = INVALID_PLAYER_ID;
  53.     LastPCarDamage[playerid] = 0;
  54. }
  55.  
  56.  
  57. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
  58. {
  59.     if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
  60.     {
  61.         LastDamaeTime[playerid] = gettime();
  62.         lastdamager{playerid} = issuerid;
  63.     }
  64.     return 1;
  65. }
  66.  
  67. public OnVehicleDamageStatusUpdate(vehicleid, playerid)
  68. {
  69.     for(new i = 0; i < MAX_PLAYERS; i++)
  70.     {
  71.         if(IsPlayerConnected(i) && GetPlayerVehicleID(i) == vehicleid)
  72.         {
  73.             LastPCarDamage[i] = gettime();
  74.             lastdamager{i} = playerid;
  75.         }
  76.     }
  77.     return 1;
  78. }
Advertisement
RAW Paste Data Copied
Advertisement