how can i set the tickcount 1 time, and other things multiple times?
#1

hey everyone,

im working in an anticheat system for my server, and now i wanna ban players who teleport players to them with cleo/******

now my beta tester/******, cleo hacker, told me that a player goes 3 times in a vehicle in less then a second to teleport someone to him, meaning that manually with cmds this is almost IMPOSSIBLE.

so now i wanna get the tickcount of when someone goes in a car, and then another array, saying the player went into a vehicle ++. but how can i make it that onplayerstatechange only does the tickcount 1 time, and the array multiple times, untill it has reached 3, and then ill make a check in onplayerupdate to see when he has entered 3 cars, and the tickcount is LESS then a second, then he gets banned.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        PlayerInfo[playerid][TickCount] = GetTickCount(); // i want this one to only call 1 time.
        PlayerInfo[playerid][GoesInVehicle]++; // this one must keep continueing and counting.
    }
    return 1;
}
so is there a way to let the gettickcount do it once, and the goesinvehicle++ just keeps contineuing when he enters a new car.

greets niels
Reply
#2

pawn Код:
if(PlayerInfo[playerid][TickCount] != 0 && (GetTickCount() - PlayerInfo[playerid][TickCount]) < YourTimeMS)
{
        // It won't read anything after this statement.
        return true;
}
Reply
#3

thnx, i already found another way with some variables and other arrays:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        if(PlayerInfo[playerid][EnteredCar] == 0)
        {
            PlayerInfo[playerid][TickCount] = GetTickCount();
            PlayerInfo[playerid][EnteredCar] = 1;
            PlayerInfo[playerid][GoesInVehicle]++;
            SetTimerEx("ResetEnteredCar", 2000, 0, "d", playerid);
        }
        else if(PlayerInfo[playerid][EnteredCar] == 1)
        {
            PlayerInfo[playerid][GoesInVehicle]++;
        }
    }
    return 1;
}
onplayerupdate >>
pawn Код:
if(PlayerInfo[playerid][GoesInVehicle] >= 3)
    {
        new interval = GetTickCount() - PlayerInfo[playerid][TickCount];
        if(interval < 1)
        {
            new string[100], pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, pName, sizeof(pName));
            format(string, sizeof(string), "SERVER-BAN: %s got banned by the anticheat, Reason: ******/cleo Teleport Hacks detected", pName);
            SendClientMessageToAll(BANNEDMESSAGE, string);
            ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Ban Information", "{FF0000}You are banned from this server!\nReason: ******/cleo Teleport Hack Detected\nif you are banned innocently, then make a screenshot of this(F8), and place a unban apply at our forums:\n{00FF00}www.streetrodzracers.tk\n\nGoodbye\n\n{0000FF}Server Owners:\n{FF0000}Niels\n{00FF00}Ruben", "Okay", "");
            BanEx(playerid, "SERVER-BAN: Teleport Hacks detected");
        }
    }
thats how i did it, untested yet, but should work . anyways thnx for your help
Reply
#4

suggestion:
make the interval variable global, and add a command to set the interval - sometimes the runtimes are jittery, maybe you never/rarely get a result by comparing interval<1 ?
also add some debug, as gametextforall maybe...
Reply
#5

Why use a timer anyway? That's counter productive. Just reset their variable when the time between entering vehicles is more than 2 or 3 seconds (as opposed to < 1 second, when it is incremented). Also why the OnPlayerUpdate? You can just check in OnPlayerStateChange if the value has reached 3 already.
Reply
#6

hmm ye thats both true, but i dont really get it wut babul says, and onplayerupdate keeps checking it, onplayerstatechange only when entering vehicle.

anyways can you explain with some code wut you mean babul? also im stuck on this /givecar cmd... it says it must be indexed, and i tried some things but none of them worked

pawn Код:
CMD:givecar(playerid, params[])
{
    new targetid, tname[MAX_PLAYER_NAME], VehID[256], targetcar;
    new name[MAX_PLAYER_NAME], string[128], string2[128];
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(targetid, tname, sizeof(tname));
    if(sscanf(params, "us", targetid, VehID)) return SendClientMessage(playerid, COLOR_YELLOW, "Correct Usage: /givecar [playerid] [car name/id]");
    new Float:x, Float:y, Float:z, Float: Angle;
    GetPlayerPos(targetid, x, y, z);
    GetPlayerFacingAngle(targetid, Angle);
    targetcar = ReturnVehicleID(VehID);
    if(VehID < 400 || VehID > 611) return  SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Vehicle Model");
    new VehicleID = CreateVehicle(targetcar, x,y,z, Angle, -1, -1, -1);
    PutPlayerInVehicle(targetid, VehicleID, 0);
    format(string, sizeof(string), "%s has given you a %s", name, VehID);
    format(string2, sizeof(string2), "you have given %s a %s", tname, VehID);
    SendClientMessage(targetid, COLOR_ORANGE, string);
    SendClientMessage(playerid, COLOR_ORANGE, string2);
    return 1;
}
pawn Код:
new
    vNames[212][] =
    {
        "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus",
        "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat", "Mr Whoopee", "BF Injection",
        "Hunter", "Premier", "Enforcer", "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie",
        "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer", "Turismo", "Speeder",
        "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy", "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider",
        "Glendale", "Oceanic", "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "Walton", "Regina",
        "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick", "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood",
        "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B",
        "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropdust", "Stunt", "Tanker", "RoadTrain",
        "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck",
        "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet", "Clover",
        "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster A",
        "Monster B", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito", "Freight", "Trailer",
        "Kart", "Mower", "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "Newsvan", "Tug", "Trailer A", "Emperor",
        "Wayfarer", "Euros", "Hotdog", "Club", "Trailer B", "Trailer C", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)",
        "Police Car (LVPD)", "Police Ranger", "Picador", "S.W.A.T. Van", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer A", "Luggage Trailer B",
        "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
    }
;
ReturnVehicleID(vName[])
{
    for(new x; x != 211; x++) if(strfind(vNames[x], vName, true) != -1) return x + 400;
    return INVALID_VEHICLE_ID;
}
greets niels
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)