Console problem, printf
#1

Hey guys, so I'm making a FS to release on the SA-MP forums but experiencing some problems.

Well first, I tried making an anti-speed hack, if you speed hack, it will send a message to the console.
Problems that I found were:
If you hacked then you /q, it keeps saying: ID 0 is speed hacking, speed 0.
It doesn't stop saying that, according to the timer.
Same for money hacks, ID 1 is money hacking, money: 0, even if you're offline..

Second problem: If you were speed hacking let's say at 360 KMH, then you stopped speed hacking, according to the timer, it keeps showing you that he's hacking, but shows speed: 0.

Can I get some help?
Tell me what part of the scripts you wanna see so I can give it to you for some help..

Thank you!
Reply
#2

Let me add your code to the topic, this will allow people to help you easier

pawn Код:
public OnPlayerUpdate(playerid)
{
 
//Money hack checker
if(IsPlayerConnected(playerid))
{
        if(GetPlayerMoney(playerid) >= MAX_MONEY)
        {
                if(Check[playerid] == 0)
                {
                SetTimerEx("MoneyHackTimer", 60000, 1, "i", playerid);
                KillTimer(MoneyHackTimer(playerid));
                Check[playerid] = 1;
                }
               
        }
               
               
        if(GetPlayerSpeed(playerid) >= MAX_SPEED)
        {
                        if(Check1[playerid] == 0)
                        {
                        SetTimerEx("SpeedHackTimer", 30000, 1, "i", playerid);
                        KillTimer(SpeedHackTimer(playerid));
                        Check1[playerid] = 1;
                        }
                       
                }
               
       
        if(GetPlayerWeapon(playerid) == 38)
        {
                if(Check2[playerid] == 0)
                {
                                SetTimerEx("WeaponHackTimer", 30000, 1, "i", playerid);
                                KillTimer(WeaponHackTimer(playerid));
                                Check2[playerid] = 1;
                                }
                               
                }
               
}
return 1;
}
 
 
forward MoneyHackTimer(playerid);
public MoneyHackTimer(playerid)
{
new string[256], string2[256];
format(string, sizeof(string), " %s (ID: %d) is a possible money hacker!", GetName(playerid), playerid);
format(string2, sizeof(string2),"Money: $%d!", GetPlayerMoney(playerid));
printf(string);
printf(string2);
return 1;
}
 
forward SpeedHackTimer(playerid);
public SpeedHackTimer(playerid)
{
new string[256], string2[256];
format(string, sizeof(string), "%s (ID: %d) is a possible speed hacker!", GetName(playerid), playerid);
format(string2, sizeof(string2),"Speed: %d KMH!", GetPlayerSpeed(playerid));
printf(string);
printf(string2);
return 1;
}
 
forward WeaponHackTimer(playerid);
public WeaponHackTimer(playerid)
{
new string[256], string2[256];
format(string, sizeof(string), "%s (ID: %d) is a possible Minigun hacker!", GetName(playerid), playerid);
format(string2, sizeof(string2),"Ammo: %d bullets!", GetPlayerAmmo(playerid));
printf(string);
printf(string2);
return 1;
}
 
stock GetName(playerid)
{
 new pnameid[24];
 GetPlayerName(playerid,pnameid,24);
 return pnameid;
}
 
stock GetPlayerSpeed(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 179.28625;
    return floatround(ST[3]);
}
Reply
#3

The problem is your not actually killing the timer, if you kill the timer before it actually gets to the time you set it wont do anything then so no need to kill it.

Another thing is that if you dont want it to repeat just instead of 1 make it 0.

I think you should check the wiki for some additionall info about timers https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#4

What are you trying to achieve with:
pawn Код:
KillTimer(MoneyHackTimer(playerid));
?

First, set the timer to a global var:
pawn Код:
new timerMoneyHack[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...};

KillTimer(timerMoneyHack[playerid]); // Make sure you kill the timer first ( If it was already set )
timerMoneyHack[playerid] = SetTimer(...);
Reply
#5

I'm sorry, I'm not really following here..
So what exactly should I edit to fix BOTH of my problems?
((Kinda sleepy so ain't really functioning right xD))


I did repeat 1 so it keeps sending it every minute to the console.. Was on purpose(Gonna change it now though).
Would fix the problem to change it to 0?

And about the KillTimer, if I remove all the KillTimers, wouldn't there be ALOT of timers running after some time, which cause lag?

pawn Код:
SetTimerEx("MoneyHackTimer", 60000, 1, "i", playerid);
// my timer
want it like this to fix?
pawn Код:
SetTimerEx("MoneyHackTimer", 1000, 0, "i", playerid);
Am I right?
Reply
#6

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
I'm sorry, I'm not really following here..
So what exactly should I edit to fix BOTH of my problems?
((Kinda sleepy so ain't really functioning right xD))


I did repeat 1 so it keeps sending it every minute to the console.. Was on purpose(Gonna change it now though).
Would fix the problem to change it to 0?

And about the KillTimer, if I remove all the KillTimers, wouldn't there be ALOT of timers running after some time, which cause lag?
I wouldnt let it repeat ever 1 minute as its just going to spam A LOT.
Change the timer to not repeat and remove the killtimer.

if hes going to keep hacking it will repeat as it will detect him again(if your anti-cheat system is going to work right )
Reply
#7

My system is already bugged, even if you stop the speed hacking, it shows you're hacking.
So if you hacked at 350KMH, it will later show, if you've stopped: Player1 is hacking, speed: 0..

And when you /q, if you were detected as hacking, it keeps showing: ID 0 is hacking, etc..
But if you weren't hacking, doesn't show anything.
Reply
#8

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
My system is already bugged, even if you stop the speed hacking, it shows you're hacking.
So if you hacked at 350KMH, it will later show, if you've stopped: Player1 is hacking, speed: 0..

And when you /q, if you were detected as hacking, it keeps showing: ID 0 is hacking, etc..
But if you weren't hacking, doesn't show anything.
Is it after the fix I suggested?
Reply
#9

No, that was before the fix, let me try the new one with 1000 time and 0 for repeat.
I will edit my post for results.


EDIT: Well it worked, sends a message that a guy is hacking, then no spam.. But won't that cause many timers to be running at a same time and cause lag? That's the last question.
Reply
#10

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
No, that was before the fix, let me try the new one with 1000 time and 0 for repeat.
I will edit my post for results.


EDIT: Well it worked, sends a message that a guy is hacking, then no spam.. But won't that cause many timers to be running at a same time and cause lag? That's the last question.
Well the amount of timers running would be equal to the amount of hacks being used.
You shouldnt notice any lag unless a lot of hackers are hacking on your server.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)