Advertisement
Guest User

Basic Protections

a guest
Nov 8th, 2013
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.43 KB | None | 0 0
  1. #include a_samp
  2. /* FS Basic Protections - Original: Proteções Básicas
  3.    By NicK - Brasil Mega Trucker
  4. */
  5.  
  6. new bool:CHECK_WEAPONS = true;
  7. /*
  8. If in 'true' will be active anti-guns. You can change weapons by default id 35,36,38 weapons are locked.
  9. http://wiki.sa-mp.com/wiki/Weapons
  10. */
  11.  
  12. public OnFilterScriptInit() {
  13.     return 1;
  14. }
  15. public OnFilterScriptExit() {
  16.     return 1;
  17. }
  18.  
  19. // Anti BOT
  20. public OnPlayerConnect(playerid) {
  21.     if(IsPlayerNPC(playerid)) return 1; .
  22.     new SAMP[50];
  23.     GetPlayerVersion(playerid, SAMP, sizeof(SAMP));
  24.     if(!strcmp(SAMP, "unknown", false)) return BanEx(playerid, "BOT");
  25.     return 1;
  26. }
  27.  
  28. // Anti Fake Kill
  29. public OnPlayerDeath(playerid, killerid, reason) {
  30.     if(killerid == INVALID_PLAYER_ID) return 1;
  31.     if(GetPVarInt(playerid, "Kill") > gettime()) return BanEx(playerid, "Fake Kill");
  32.     if(playerid == killerid) return BanEx(playerid, "Fake Kill");
  33.     if(!IsPlayerStreamedIn(killerid, playerid)) return Kick(playerid);
  34.     if(GetPlayerTeam(playerid) != NO_TEAM)
  35.         if(GetPlayerTeam(playerid) == GetPlayerTeam(killerid))
  36.             return BanEx(playerid, "Fake Kill");
  37.     switch(reason) {
  38.         case 0..46: if(GetPlayerWeapon(killerid) != reason) return Kick(playerid);
  39.     }
  40.     SetPVarInt(playerid, "Kill", gettime() + 2);
  41.     return 1;
  42. }
  43. public OnPlayerUpdate(playerid) {
  44.     /*
  45.         Anti Car Spam
  46.     */
  47.     if(GetPlayerVehicleID(playerid) != 0) {
  48.         if(GetPlayerVehicleID(playerid) != GetPVarInt(playerid, "Veiculo_Anterior")) {
  49.             if(GetPVarInt(playerid, "Troca_Veiculo") > gettime()) return BanEx(playerid, "Car Spam");
  50.             SetPVarInt(playerid, "Veiculo_Anterior", GetPlayerVehicleID(playerid));
  51.             SetPVarInt(playerid, "Troca_Veiculo", gettime() + 2);
  52.         }
  53.     }
  54.     /*
  55.         Anti Crash:
  56.         Credits: http://forum.sa-mp.com/showpost.php?p=2610650&postcount=1
  57.     */
  58.     if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  59.     {
  60.         new Float:vec[3];
  61.         GetPlayerCameraFrontVector(playerid, vec[0], vec[1], vec[2]);
  62.         new bool:possible_crasher = false;
  63.         for (new i = 0; !possible_crasher && i < sizeof(vec); i++)
  64.             if (floatabs(vec[i]) > 10.0)
  65.                 possible_crasher = true;
  66.  
  67.         if (possible_crasher)
  68.             return 0;
  69.     }
  70.     /*
  71.         Anti Weapons:
  72.     */
  73.     if(CHECK_WEAPONS == true) {
  74.         switch(GetPlayerWeapon(playerid)) {
  75.             case 35, 36, 38: return Kick(playerid);
  76.         }
  77.     }
  78.     /*
  79.         Anti Teleport by Click
  80.     */
  81.     if(GetPVarInt(playerid, "ClickMap") > gettime())
  82.         if(!IsPlayerInRangeOfPoint(playerid, 10.0, GetPVarFloat(playerid, "PX"), GetPVarFloat(playerid, "PY"), GetPVarFloat(playerid, "PZ"))) return BanEx(playerid, "Teleport");
  83.     new Float:Pos[3]; GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
  84.     SetPVarFloat(playerid, "PX", Pos[0]); SetPVarFloat(playerid, "PY", Pos[1]); SetPVarFloat(playerid, "PZ", Pos[2]);
  85.     return 1;
  86. }
  87. /*
  88.     Anti Teleport
  89. */
  90. public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
  91. {
  92.     SetPVarInt(playerid, "ClickMap", gettime() + 15);
  93.     return 1;
  94. }
  95. /*
  96.     Other Anti Crash
  97.     I could not find the creator code.
  98. */
  99. new legalmods[49][22] = {
  100.         {400, 1024,1021,1020,1019,1018,1013,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  101.         {401, 1145,1144,1143,1142,1020,1019,1017,1013,1007,1006,1005,1004,1003,1001,0000,0000,0000,0000},
  102.         {404, 1021,1020,1019,1017,1016,1013,1007,1002,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  103.         {405, 1023,1021,1020,1019,1018,1014,1001,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  104.         {410, 1024,1023,1021,1020,1019,1017,1013,1007,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000},
  105.         {415, 1023,1019,1018,1017,1007,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  106.         {418, 1021,1020,1016,1006,1002,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  107.         {420, 1021,1019,1005,1004,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  108.         {421, 1023,1021,1020,1019,1018,1016,1014,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  109.         {422, 1021,1020,1019,1017,1013,1007,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  110.         {426, 1021,1019,1006,1005,1004,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  111.         {436, 1022,1021,1020,1019,1017,1013,1007,1006,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000},
  112.         {439, 1145,1144,1143,1142,1023,1017,1013,1007,1003,1001,0000,0000,0000,0000,0000,0000,0000,0000},
  113.         {477, 1021,1020,1019,1018,1017,1007,1006,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  114.         {478, 1024,1022,1021,1020,1013,1012,1005,1004,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  115.         {489, 1024,1020,1019,1018,1016,1013,1006,1005,1004,1002,1000,0000,0000,0000,0000,0000,0000,0000},
  116.         {491, 1145,1144,1143,1142,1023,1021,1020,1019,1018,1017,1014,1007,1003,0000,0000,0000,0000,0000},
  117.         {492, 1016,1006,1005,1004,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  118.         {496, 1143,1142,1023,1020,1019,1017,1011,1007,1006,1003,1002,1001,0000,0000,0000,0000,0000,0000},
  119.         {500, 1024,1021,1020,1019,1013,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  120.         {516, 1021,1020,1019,1018,1017,1016,1015,1007,1004,1002,1000,0000,0000,0000,0000,0000,0000,0000},
  121.         {517, 1145,1144,1143,1142,1023,1020,1019,1018,1017,1016,1007,1003,1002,0000,0000,0000,0000,0000},
  122.         {518, 1145,1144,1143,1142,1023,1020,1018,1017,1013,1007,1006,1005,1003,1001,0000,0000,0000,0000},
  123.         {527, 1021,1020,1018,1017,1015,1014,1007,1001,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  124.         {529, 1023,1020,1019,1018,1017,1012,1011,1007,1006,1003,1001,0000,0000,0000,0000,0000,0000,0000},
  125.         {534, 1185,1180,1179,1178,1127,1126,1125,1124,1123,1122,1106,1101,1100,0000,0000,0000,0000,0000},
  126.         {535, 1121,1120,1119,1118,1117,1116,1115,1114,1113,1110,1109,0000,0000,0000,0000,0000,0000,0000},
  127.         {536, 1184,1183,1182,1181,1128,1108,1107,1105,1104,1103,0000,0000,0000,0000,0000,0000,0000,0000},
  128.         {540, 1145,1144,1143,1142,1024,1023,1020,1019,1018,1017,1007,1006,1004,1001,0000,0000,0000,0000},
  129.         {542, 1145,1144,1021,1020,1019,1018,1015,1014,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  130.         {546, 1145,1144,1143,1142,1024,1023,1019,1018,1017,1007,1006,1004,1002,1001,0000,0000,0000,0000},
  131.         {547, 1143,1142,1021,1020,1019,1018,1016,1003,1000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  132.         {549, 1145,1144,1143,1142,1023,1020,1019,1018,1017,1012,1011,1007,1003,1001,0000,0000,0000,0000},
  133.         {550, 1145,1144,1143,1142,1023,1020,1019,1018,1006,1005,1004,1003,1001,0000,0000,0000,0000,0000},
  134.         {551, 1023,1021,1020,1019,1018,1016,1006,1005,1003,1002,0000,0000,0000,0000,0000,0000,0000,0000},
  135.         {558, 1168,1167,1166,1165,1164,1163,1095,1094,1093,1092,1091,1090,1089,1088,0000,0000,0000,0000},
  136.         {559, 1173,1162,1161,1160,1159,1158,1072,1071,1070,1069,1068,1067,1066,1065,0000,0000,0000,0000},
  137.         {560, 1170,1169,1141,1140,1139,1138,1033,1032,1031,1030,1029,1028,1027,1026,0000,0000,0000,0000},
  138.         {561, 1157,1156,1155,1154,1064,1063,1062,1061,1060,1059,1058,1057,1056,1055,1031,1030,1027,1026},
  139.         {562, 1172,1171,1149,1148,1147,1146,1041,1040,1039,1038,1037,1036,1035,1034,0000,0000,0000,0000},
  140.         {565, 1153,1152,1151,1150,1054,1053,1052,1051,1050,1049,1048,1047,1046,1045,0000,0000,0000,0000},
  141.         {567, 1189,1188,1187,1186,1133,1132,1131,1130,1129,1102,0000,0000,0000,0000,0000,0000,0000,0000},
  142.         {575, 1177,1176,1175,1174,1099,1044,1043,1042,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  143.         {576, 1193,1192,1191,1190,1137,1136,1135,1134,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  144.         {580, 1023,1020,1018,1017,1007,1006,1001,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  145.         {585, 1145,1144,1143,1142,1020,1019,1017,1013,1007,1006,1005,1004,1003,1001,1018,1023,0000,0000},
  146.         {589, 1145,1144,1024,1020,1018,1017,1016,1013,1007,1006,1005,1004,1000,0000,0000,0000,0000,0000},
  147.         {600, 1022,1020,1018,1017,1013,1007,1006,1005,1004,0000,0000,0000,0000,0000,0000,0000,0000,0000},
  148.         {603, 1145,1144,1143,1142,1024,1023,1020,1019,1018,1017,1007,1006,1001,0000,0000,0000,0000,0000}
  149. };
  150.  
  151.  
  152. public OnVehicleMod(playerid, vehicleid, componentid) {
  153.     new vehicleide = GetVehicleModel(vehicleid);
  154.     new modok = islegalcarmod(vehicleide, componentid);
  155.     if (!modok)
  156.     {
  157.         BanEx(playerid, "Crash");
  158.         return 0;
  159.     }
  160.     return 1;
  161. }
  162. iswheelmodel(modelid) {
  163.     new wheelmodels[17] = {1025,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1096,1097,1098};
  164.     for(new i; i < sizeof(wheelmodels); i++)
  165.     {
  166.         if (modelid == wheelmodels[i])
  167.             return true;
  168.     }
  169.     return false;
  170. }
  171.  
  172. IllegalCarNitroIde(carmodel) {
  173.     new illegalvehs[29] = { 581, 523, 462, 521, 463, 522, 461, 448, 468, 586, 509, 481, 510, 472, 473, 493, 595, 484, 430, 453, 452, 446, 454, 590, 569, 537, 538, 570, 449 };
  174.     for(new i; i < sizeof(illegalvehs); i++) {
  175.         if (carmodel == illegalvehs[i])
  176.             return true;
  177.     }
  178.     return false;
  179. }
  180. stock illegal_nos_vehicle(PlayerID) {
  181.     new carid = GetPlayerVehicleID(PlayerID);
  182.     new playercarmodel = GetVehicleModel(carid);
  183.     return IllegalCarNitroIde(playercarmodel);
  184. }
  185.  
  186. stock islegalcarmod(vehicleide, componentid) {
  187.     new modok = false;
  188.     if ( (iswheelmodel(componentid)) || (componentid == 1086) || (componentid == 1087) || ((componentid >= 1008) && (componentid <= 1010))) {
  189.         new nosblocker = IllegalCarNitroIde(vehicleide);
  190.         if (!nosblocker)
  191.             modok = true;
  192.     } else {
  193.         for(new I; I < sizeof(legalmods); I++) {
  194.             if (legalmods[I][0] == vehicleide) {
  195.                 for(new J = 1; J < 22; J++) {
  196.                     if (legalmods[I][J] == componentid)
  197.                         modok = true;
  198.                 }
  199.             }
  200.         }
  201.     }
  202.     return modok;
  203. }
  204.  
  205. /*
  206.     Anti Floder Paint Vehicles
  207. */
  208. public OnVehicleRespray(playerid, vehicleid, color1, color2) {
  209.     if(GetPVarInt(playerid, "pintura_Recente") > gettime()) return Kick(playerid);
  210.     SetPVarInt(playerid, "pintura_Recente", gettime() + 1);
  211.     return 1;
  212. }
  213. /*
  214.     Anti Flooder Spawn
  215. */
  216. public OnPlayerRequestSpawn(playerid) {
  217.     if(GetPVarInt(playerid, "spawn_Tempo") > gettime()) return 0;
  218.     SetPVarInt(playerid, "spawn_Tempo", gettime() + 2);
  219.     return 1;
  220. }
  221.  
  222. /*
  223.     Found bugs? Please report!
  224.     http://forum.sa-mp.com/member.php?u=171517
  225.     By NicK - Brasil Mega Trucker
  226. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement