SA-MP Forums Archive
Warn - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Warn (/showthread.php?tid=578779)



Warn - STONEGOLD - 22.06.2015

Well, I'm using this script. I want to add a warning system. I mean, If player try to hack weapons at first time it should be restplayerweapons and if he try to hack again then it should ban player.

i have tried but idk what's wrong.

PHP код:
public BadCheck()
{
    new 
weapstring[228], string3[256], pname[MAX_PLAYER_NAME]; //  
    
for(new iGetMaxPlayers(); bi++) // 
    
{
        
GetPlayerName(ipnamesizeof(pname));
        
weap GetPlayerWeapon(i);
        for(new 
wsizeof(BadWeapons); w++)
        {
            if(
pInfo[i][pAdmin] < 1)
            {
                if(
weap == BadWeapons[w])
                   {
                   
format(string,sizeof(string),"SERVER ANTI-CHEAT: %s is trying to hack weapons."pname);
                   
SendMessageToAdmins(RED,string);
                   
ResetPlayerWeapons(i);
                }
            }
        }
    }
    return 
1;

Well, This work good but i want to add if player try to hack again which means 2nd time then it should kick player.


Re: Warn - AlonzoTorres - 22.06.2015

PHP код:

// top
new gTimesHacked[MAX_PLAYERS];
public 
BadCheck()
{
    new 
weapstring[228], string3[256], pname[MAX_PLAYER_NAME]; //  
    
for(new iGetMaxPlayers(); bi++) // 
    
{
        
GetPlayerName(ipnamesizeof(pname));
        
weap GetPlayerWeapon(i);
        for(new 
wsizeof(BadWeapons); w++)
        {
            if(
pInfo[i][pAdmin] < 1)
            {
                if(
weap == BadWeapons[w])
                   {
                                   
gTimesHacked[i]++;
                                   if(
gTimesHacked[i] > 1)
                                   {
                                        
Kick(i);
                                   }
                   
format(string,sizeof(string),"SERVER ANTI-CHEAT: %s is trying to hack weapons."pname);
                   
SendMessageToAdmins(RED,string);
                   
ResetPlayerWeapons(i);
                }
            }
        }
    }
    return 
1;

You can also put a variable in the player enum. Rememeber to reset at connection.


Re: Warn - STONEGOLD - 22.06.2015

What do you mean by reset at connection?

You mean

gTimesHacked[playerid] = 0; ?


Re: Warn - STONEGOLD - 22.06.2015

Well, it's not working. It stills kicking at first time.


Re: Warn - AlonzoTorres - 22.06.2015

Make sure you return after you've reset the weapons. Otherwise the loop will continue... Resulting in the variable getting added to multiple times. And then the user will be kicked.

Oh and yes, I mean like that.