Got one error on a return statement
#1

Hello to all, after 2 years of good pause i'm here again improving my skills. This is a simple code of a simple anticheat made by me. I got only a problem here:

Код:
SendClientMessage(playerid, 0xFFFFFFFF, s);
	if(GetPlayerWeapon(playerid) == 38) Ban(playerid); //Ban if they have a minigun
	SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
	if(GetPlayerWeapon(playerid) == 35) Ban(playerid); //Ban if they have a RPG
	SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
	if(GetPlayerWeapon(playerid) == 36) Ban(playerid); //Ban if they have a HEAT SEEKER
	SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
	
}

	return 1;
}
Line 295

Pastebin link:
Pastebin Code



I'm getting crazy about the error, someone can kindly help me out?
Reply
#2

Really messy, man. And use a timer instead of OnPlayerUpdate(...).
pawn Код:
#include <a_samp>
#define COLOR_GREEN 0x33AA33AA

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] ANTICHEAT SYSTEM IS ON. I'M WATCHING YOU ;)");
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerWeapon(killerid) == 38) Ban(killerid); //Ban if they have a minigun
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
    if(GetPlayerWeapon(killerid) == 35) Ban(killerid); //Ban if they have a RPG
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
    if(GetPlayerWeapon(killerid) == 36) Ban(killerid); //Ban if they have a HEAT SEEKER
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
    return 1;
}

public OnPlayerUpdate(playerid)
{
    // ---------------- ANTI HEALTH HACK --------------------------------------------
    new Float:fHealth;

    GetPlayerHealth(playerid, fHealth);

    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {
        // Player health has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
        {
            Ban(playerid);
            SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEALTH HACK");
            /* He has gained health! Cheating? Write your own scripts here to figure how a player
            gained health! */

        }
        else
        {
            /* He has lost health! */
        }

        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
        return 1;
    }

    // ---------------- ANTI ARMOUR HACK --------------------------------------------
    new Float:fArmour;

    GetPlayerArmour(playerid, fArmour);

    if(fArmour != GetPVarFloat(playerid, "faPlayerArmour"))
    {
        // Player armour has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fArmour > GetPVarFloat(playerid, "faPlayerArmour"))
        {
            Ban(playerid);
            SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: ARMOUR HACK");
            /* He has gained armour! Cheating? Write your own scripts here to figure how a player
            gained health! */

        }
        else
        {
            /* He has lost armour! */
        }

        SetPVarFloat(playerid, "faPlayerArmour", fArmour);
        return 1;
    }


    //------------------------- ANTI WEAPON HACK --------------------------------------------------------------
    new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon
    if(iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
    {
        // Lets call a callback named OnPlayerChangeWeapon
        OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), iCurWeap);
        SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
    }
    return 1; // Send this update to other players.
}

stock OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
    new     s[128],
        oWeapon[24],
        nWeapon[24];

    GetWeaponName(oldweapon, oWeapon, sizeof(oWeapon));
    GetWeaponName(newweapon, nWeapon, sizeof(nWeapon));

    format(s, sizeof(s), "You changed weapon from %s to %s!", oWeapon, nWeapon);

    SendClientMessage(playerid, 0xFFFFFFFF, s);
    if(GetPlayerWeapon(playerid) == 38) Ban(playerid); //Ban if they have a minigun
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
    if(GetPlayerWeapon(playerid) == 35) Ban(playerid); //Ban if they have a RPG
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
    if(GetPlayerWeapon(playerid) == 36) Ban(playerid); //Ban if they have a HEAT SEEKER
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
    return 1;
}
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Really messy, man. And use a timer instead of OnPlayerUpdate(...).
pawn Код:
#include <a_samp>
#define COLOR_GREEN 0x33AA33AA

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Blank Filterscript by your name here");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] ANTICHEAT SYSTEM IS ON. I'M WATCHING YOU ;)");
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerWeapon(killerid) == 38) Ban(killerid); //Ban if they have a minigun
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
    if(GetPlayerWeapon(killerid) == 35) Ban(killerid); //Ban if they have a RPG
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
    if(GetPlayerWeapon(killerid) == 36) Ban(killerid); //Ban if they have a HEAT SEEKER
    SendClientMessage(killerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
    return 1;
}

public OnPlayerUpdate(playerid)
{
    // ---------------- ANTI HEALTH HACK --------------------------------------------
    new Float:fHealth;

    GetPlayerHealth(playerid, fHealth);

    if(fHealth != GetPVarFloat(playerid, "faPlayerHealth"))
    {
        // Player health has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fHealth > GetPVarFloat(playerid, "faPlayerHealth"))
        {
            Ban(playerid);
            SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEALTH HACK");
            /* He has gained health! Cheating? Write your own scripts here to figure how a player
            gained health! */

        }
        else
        {
            /* He has lost health! */
        }

        SetPVarFloat(playerid, "faPlayerHealth", fHealth);
        return 1;
    }

    // ---------------- ANTI ARMOUR HACK --------------------------------------------
    new Float:fArmour;

    GetPlayerArmour(playerid, fArmour);

    if(fArmour != GetPVarFloat(playerid, "faPlayerArmour"))
    {
        // Player armour has changed since the last update -> server, so obviously thats the thing updated.
        // Lets do further checks see if he's lost or gained health, anti-health cheat? ;)

        if(fArmour > GetPVarFloat(playerid, "faPlayerArmour"))
        {
            Ban(playerid);
            SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: ARMOUR HACK");
            /* He has gained armour! Cheating? Write your own scripts here to figure how a player
            gained health! */

        }
        else
        {
            /* He has lost armour! */
        }

        SetPVarFloat(playerid, "faPlayerArmour", fArmour);
        return 1;
    }


    //------------------------- ANTI WEAPON HACK --------------------------------------------------------------
    new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon
    if(iCurWeap != GetPVarInt(playerid, "iCurrentWeapon")) // If he changed weapons since the last update
    {
        // Lets call a callback named OnPlayerChangeWeapon
        OnPlayerChangeWeapon(playerid, GetPVarInt(playerid, "iCurrentWeapon"), iCurWeap);
        SetPVarInt(playerid, "iCurrentWeapon", iCurWeap);//Update the weapon variable
    }
    return 1; // Send this update to other players.
}

stock OnPlayerChangeWeapon(playerid, oldweapon, newweapon)
{
    new     s[128],
        oWeapon[24],
        nWeapon[24];

    GetWeaponName(oldweapon, oWeapon, sizeof(oWeapon));
    GetWeaponName(newweapon, nWeapon, sizeof(nWeapon));

    format(s, sizeof(s), "You changed weapon from %s to %s!", oWeapon, nWeapon);

    SendClientMessage(playerid, 0xFFFFFFFF, s);
    if(GetPlayerWeapon(playerid) == 38) Ban(playerid); //Ban if they have a minigun
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
    if(GetPlayerWeapon(playerid) == 35) Ban(playerid); //Ban if they have a RPG
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
    if(GetPlayerWeapon(playerid) == 36) Ban(playerid); //Ban if they have a HEAT SEEKER
    SendClientMessage(playerid, COLOR_GREEN, "[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
    return 1;
}
Thanx a lot man, that done the trick
Reply
#4

Got another little bothering issue. Everytime i swap a weapon i got this messages:

[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN
[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG
[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER

ELSE IF I SWAP FROM FIST TO BASEBALL BAT!

WELL I DON'T GET BANNED BUT THESE MESSAGES CONTINUE SPAMMING ALL THE WAY OUT. CAN SOMEONE KINDLY HELP ME OUT FINDING WHY IT HAPPEN? THANX
Reply
#5

You should use brackets, with your current code it takes only the Ban line with the if statement and the message will be sent it gets executed before the ban line.

Though you have to delay the kick/ban to show the messages so:
PHP код:
switch (GetPlayerWeapon(killerid))
{
    case 
38:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
    case 
35:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
    case 
36:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
}
// somewhere else (outside of any function):
forward PlayerBan(playerid);
public 
PlayerBan(playerid)
{
    
Ban(playerid);
    return 
1;

Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You should use brackets, with your current code it takes only the Ban line with the if statement and the message will be sent it gets executed before the ban line.

Though you have to delay the kick/ban to show the messages so:
PHP код:
switch (GetPlayerWeapon(killerid))
{
    case 
38:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: MINIGUN");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
    case 
35:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: RPG");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
    case 
36:
    {
        
SendClientMessage(killeridCOLOR_GREEN"[VANILLA-ANTICHEATS] YOU HAVE BEEN AUTO-BANNED FOR REASON: HEAT SEEKER");
        
SetTimerEx("PlayerBan"1000false"i"killerid);
    }
}
// somewhere else (outside of any function):
forward PlayerBan(playerid);
public 
PlayerBan(playerid)
{
    
Ban(playerid);
    return 
1;

It woks gr8 man
Reply
#7

This method is not effective at all. The moment a player with the fake-kill cheat comes along all your legitimate players will get banned.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)