Anti C-bug help rep++
#1

Код:
if ((oldkeys & KEY_FIRE) && (newkeys & KEY_CROUCH)&& GetPlayerWeapon(playerid)==24)
{
SetPlayerHealth(playerid,0); GameTextForPlayer(playerid, "~r~ C Bug not allowed.", 3000, 1);
}
how to add warnings Don't c-bug 1/5 - Don't c-bug 2/5 - Don't c-bug 3/5 -Don't c-bug 4/5 -Don't c-bug 5/5

and kill

message to all player name Is killed Reason c-bug
Reply
#2

Add this some where at the top,
pawn Код:
new CBugWarnings[MAX_PLAYERS];
Add this onplayerconnect
pawn Код:
CBugWarnings[playerid] = 0;
This is your keying.
pawn Код:
if ((oldkeys & KEY_FIRE) && (newkeys & KEY_CROUCH)&& GetPlayerWeapon(playerid)==24)
{
    if(CBugWarnings[playerid] >= 5)
    {
        SendClientMessage(playerid, -1, "You've been killed for Cbugging.");
        CBugWarnings[playerid] = 0;
        SetPlayerHealth(playerid,0);
                GameTextForPlayer(playerid, "~r~ C Bug not allowed.", 3000, 1);
        return 1;
    }
    new string[129];
    CBugWarnings[playerid] += 1;
    format(string, sizeof(string), "[WARNING] C-Bugging is not allowed! (%d/5)",CBugWarnings[playerid]);
    SendClientMessage(playerid, -1, string);
}
Something like that. I obviously didn't test it.
Reply
#3

man it is slow i cbug 1000 times and it give me warning so slow

and

he kill me and give me warning like 1/5 and kill me i want when player have 5/5 then kill
Reply
#4

like :

Reply
#5

bump!
Reply
#6

OnPlayerKeyStateChange is called depends on how the internet speed of that player (or at least in my opinion).

You do not just make it like "Click & Call Fast function", specially if you have tons of key function on that callback. Why don't you just make it like give him a warning for the first time, and if he do C-Bug again, Kill or do whatever you want towards the player.

Do not rely on my messages about OnPlayerKeyStateChange though as this is an opinion only.
Reply
#7

Something like this:
pawn Код:
CBugWarnings[playerid] ++; // Increases an array by 1, we'll call it "CBugWarnings"
format(string, sizeof(string), "Do not C-Bug [%i/5]", CBugWarnings[playerid]); // Formats an array we'll call "string", and sends it with SendClientMessage
SendClientMessage(playerid, -1, string);
if(CBugWarnings[playerid] == 5) // If the warnings are 5
{
    CBugWarnings[playerid] = 0; // Reset CBugWarnings
    SetPlayerHealth(playerid, 0); // And kill the player
}
Reply
#8

Quote:

#include <a_samp>
#define RED 0xFF0000AA
forward OnPlayerMakeCBug(playerid);

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
CBugWarnings[playerid] ++; // Increases the Warning array by 1
format(string, sizeof(string), "Do not C-Bug [%i/5]", CBugWarnings[playerid]); // Formats the string, and sends it with SendClientMessage
SendClientMessage(playerid, -1, string);
if(CBugWarnings[playerid] == 5) // If the warnings are 5
{
CBugWarnings[playerid] = 0; // Reset CBugWarnings
SetPlayerHealth(playerid, 0); // And kill the player
return 1;
}

Код:
pwn(8) : error 017: undefined symbol "CBugWarnings"
pwn(8) : warning 215: expression has no effect
pwn(8) : error 001: expected token: ";", but found "]"
pwn(8) : error 029: invalid expression, assumed zero
pwn(8) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
line 8 : CBugWarnings[playerid] ++; // Increases the Warning array by 1
Reply
#9

You didn't define it?
I was just showing you the structure of how you could do it, i expect that you know how to use variables/arrays.
You have to declare it by using "new", like so:
pawn Код:
new CBugWarnings[MAX_PLAYERS];
Or by using an enumerator, which i would recommend, as you can easily loop through it and set all the values to 0 on connect, so you don't accidentally give other players warning 2/5 when the player before them c-bugged once.
Reply
#10

Quote:

.pwn(16) : warning 217: loose indentation
.pwn(17) : warning 217: loose indentation
.pwn(20) : error 030: compound statement not closed at the end of file (started at line 10)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
line 10 :
Quote:

format(string, sizeof(string), "Do not C-Bug [%i/5]", CBugWarnings[playerid]); // Formats the string, and sends it with SendClientMessage

Код:
new string [MAX_PLAYERS];
Код:
#include <a_samp>
#define RED       0xFF0000AA
forward OnPlayerMakeCBug(playerid);
new CBugWarnings[MAX_PLAYERS];
new string[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
CBugWarnings[playerid] ++; // Increases the Warning array by 1
format(string, sizeof(string), "Do not C-Bug [%i/5]", CBugWarnings[playerid]); // Formats the string, and sends it with SendClientMessage
SendClientMessage(playerid, -1, string);
if(CBugWarnings[playerid] == 5) // If the warnings are 5
{
CBugWarnings[playerid] = 0; // Reset CBugWarnings
 SetPlayerHealth(playerid, 0); // And kill the player
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)