27.12.2012, 22:40
Hello, this is my first Filterscript, a Friend and i made this, it should fix some SAMP Things like Anti Bunnyhopping (usefull for some Servers, where Bunnyhopping is not allowed) or Anti Knifebugging (Killing a Guy from behind with a Knife). But we have it not tested yet. But whatever, here is it:
Код:
#include <a_samp> #define FREEZE_TIME 3000 //This is a Filterscript, to fix some SA-MP Bugs, like the Knifebug or Anti Bunnyhopping. // Bunnyhop Fix // SpawnMoney Fix // DialogCrush Fix // DialogColor Fix // +C Fix // Slide Fix // Sprint Fix // Knifebugging Fix // KnifeKill Fix enum fixInfo { bool:fixBannyHop, bool:fixSpawnMoney, bool:fixDialogCrush, bool:fixDialogColor, bool:fixCBug, bool:fixSlideBug, bool:fixSprintBug, bool:fixKnifeBug, bool:fixKnifeKill } new FixInfo[fixInfo] = { true, //BunnyHop fix true, //SpawnMoney fix true, //DialogCrush fix true, //DialogColor fix true, //C Bug fix true, //Slide fix true, //Sprint Bug fix true, //KnifeBug fix true //KnifeKill fix }; public OnPlayerConnect(playerid) { SetPVarInt(playerid, "BHTime", -1); SetPVarInt(playerid, "MoneyTime", -1); SetPVarInt(playerid, "CBugTime", -1); SetPVarInt(playerid, "UnfreezeTime", -1); SetPVarInt(playerid, "SlideTime", -1); SetPVarInt(playerid, "SprintCount", -1); SetPVarInt(playerid, "SprintTime", -1); SetPVarInt(playerid, "KnifeTime", -1); SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID); return 1; } public OnPlayerSpawn(playerid) { if(FixInfo[fixSpawnMoney] && GetTickCount() > GetPVarInt(playerid, "MoneyTime")) { GivePlayerMoney(playerid, 100); } SetPVarInt(playerid, "MoneyTime", -1); return 1; } public OnPlayerDeath(playerid, killerid, reason) { if(FixInfo[fixSpawnMoney]) { SetPVarInt(playerid, "MoneyTime", GetTickCount() + 2000); } return 1; } stock BugFreezePlayer(playerid, time) { SetPVarInt(playerid, "UnfreezeTime", time); TogglePlayerControllable(playerid, 0); return true; } stock GetPlayerSpeed(playerid) { new Float:X, Float:Y, Float:Z; GetPlayerVelocity(playerid, X, Y, Z); return floatround( floatsqroot( X * X + Y * Y + Z * Z ) * 170.0 ); } stock CheckDialogColor(text[], first, end) { if(text[first] != '{' || text[end] != '}') return false; for(new i = first; i <= end; i ++) { if(text[i] >= '0' && text[i] <= '9') continue; if(text[i] >= 'a' && text[i] <= 'f') continue; if(text[i] >= 'A' && text[i] <= 'F') continue; return false; } strdel(text, first, end + 1); return true; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(FixInfo[fixBannyHop]) { new tick = GetTickCount(); if(oldkeys & KEY_SPRINT) { SetPVarInt(playerid, "BHTime", tick + 250); } if(newkeys & KEY_JUMP) { if(tick < GetPVarInt(playerid, "BHTime")) { ClearAnimations(playerid); BugFreezePlayer(playerid, tick + FREEZE_TIME); } SetPVarInt(playerid, "BHTime", -1); } } if(FixInfo[fixKnifeBug] || FixInfo[fixKnifeKill]) { if(newkeys & KEY_FIRE && oldkeys & 128) { if(GetPlayerWeapon(playerid) == 4) { if(GetPlayerAnimationIndex(playerid) == 747) { new knifeid = GetPlayerTargetPlayer(playerid); if(knifeid != INVALID_PLAYER_ID) { if(FixInfo[fixKnifeKill] && GetPlayerSpeed(playerid) > 10) { ClearAnimations(playerid); ClearAnimations(knifeid); } else if(FixInfo[fixKnifeBug]) { new time = GetPlayerPing(playerid) + GetPlayerPing(knifeid); SetPVarInt(knifeid, "KnifePlayer", playerid); SetPVarInt(knifeid, "KnifeTime", GetTickCount() + time); } } } } } } if(FixInfo[fixSprintBug]) { if(newkeys & KEY_SPRINT) { new tick = GetTickCount(); if(GetPVarInt(playerid, "SprintTime") == -1 || tick < GetPVarInt(playerid, "SprintTime")) { if(GetPlayerSpeed(playerid) > 15) { if(GetPVarInt(playerid, "SprintCount") >= 5) { SetPVarInt(playerid, "SprintCount", -1); SetPVarInt(playerid, "SprintTime", -1); BugFreezePlayer(playerid, tick + FREEZE_TIME); } else { SetPVarInt(playerid, "SprintCount", GetPVarInt(playerid, "SprintCount") + 1); SetPVarInt(playerid, "SprintTime", tick + 200); } } } else if(tick - GetPVarInt(playerid, "SprintTime") > 1000) { SetPVarInt(playerid, "SprintCount", -1); SetPVarInt(playerid, "SprintTime", -1); } } } if(FixInfo[fixCBug]) { if(GetPlayerWeapon(playerid) > 21) { new tick = GetTickCount(); if(oldkeys & KEY_FIRE) SetPVarInt(playerid, "CBugTime", tick + 500); if(newkeys & KEY_CROUCH) { if(tick < GetPVarInt(playerid, "CBugTime")) { SetPlayerArmedWeapon(playerid, 0); BugFreezePlayer(playerid, tick + FREEZE_TIME); } SetPVarInt(playerid, "CBugTime", -1); } } } if(FixInfo[fixSlideBug]) { new tick = GetTickCount(); new FIRE_WEAPON = GetPlayerWeapon(playerid) > 21; if(oldkeys & KEY_SPRINT && FIRE_WEAPON) { new keys, ud, lr; GetPlayerKeys(playerid, keys, ud, lr); if(ud != 0 || lr != 0) { SetPVarInt(playerid, "SlideTime", tick + 500); } } if( (newkeys & KEY_FIRE || newkeys & 128) && FIRE_WEAPON ) { if(tick < GetPVarInt(playerid, "SlideTime")) { SetPlayerArmedWeapon(playerid, 0); BugFreezePlayer(playerid, tick + FREEZE_TIME); } SetPVarInt(playerid, "SlideTime", -1); } } return 1; } public OnPlayerUpdate(playerid) { if(GetPVarInt(playerid, "UnfreezeTime") != -1) { if(GetTickCount() > GetPVarInt(playerid, "UnfreezeTime")) { SetPVarInt(playerid, "UnfreezeTime", -1); TogglePlayerControllable(playerid, 1); } } if(GetPVarInt(playerid, "KnifeTime") != -1) { if(GetPlayerAnimationIndex(playerid) == 745) { SetPVarInt(playerid, "KnifeTime", -1); SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID); } else if(GetTickCount() > GetPVarInt(playerid, "KnifeTime")) { SetPVarInt(playerid, "KnifeTime", -1); SetPVarInt(playerid, "KnifePlayer", INVALID_PLAYER_ID); ClearAnimations(playerid); } } return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { for(new i, s = strlen(inputtext); i < s; i ++) { if(FixInfo[fixDialogCrush] && inputtext[i] == '%') inputtext[i] = '#'; if(FixInfo[fixDialogColor] && inputtext[i] == '{') CheckDialogColor(inputtext, i, i + 7); } return 1; }