My 1st Include Attempt Results In Epic Fail :(
#1

Ok due to the failure of tested anti cheat's i decided to make my own,I used this tutorial here:

http://forum.sa-mp.com/showthread.ph...ght=Anti+Cheat

Now i want it to be a include ive saved it to a .inc and include it to my GM,I get errors with the callbacks,Im sure a include is laid out diffrently can someone show me how to change it into a include so i can use it in my GM and FS's

Code Here:

pawn Код:
//By Weponz For Vegas CNR Server
//Full Credits To: Kwarde //Complete Tutorial

#include <a_samp>

#define WHITE     0xFFFFFFAA

new pMoney[MAX_PLAYERS];
new ForbiddenWeapons[][] = {
16, //Grenades
34, //Sniper Rifle
37, //Flamethrower
38, //Minigun
39, //Satchel
35, //RPG
36, //Heatseeking RPG
44, //Nightvision Goggles
45 //Thermal Goggles
};

public OnPlayerConnect(playerid)
{
    pMoney[playerid] = 0;
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    pMoney[playerid] = 0;
    return 1;
}
public OnPlayerUpdate(playerid)
{
    new pName[MAX_PLAYER_NAME], w = 0, string[128];

    if(GetPlayerMoney(playerid) > pMoney[playerid]){
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
        SendClientMessageToAll(WHITE, string);
        BanEx(playerid, "[Cheats Detected]: Money Hax");
    }
    while(w < (sizeof(ForbiddenWeapons))){
        if(GetPlayerWeapon(playerid) == w){
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
            SendClientMessageToAll(WHITE, string);
            BanEx(playerid, "[Cheats Detected]: Weapon Hax");
        }
    }
    return 1;
}
stock a_GivePlayerMoney(playerid, money)
{
    pMoney[playerid] += money;
    GivePlayerMoney(playerid, money);
}
stock a_SetPlayerMoney(playerid, money)
{
    pMoney[playerid] = money;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid);
}
Errors on my GM when i include it:

Код:
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(1195) : error 021: symbol already defined: "OnPlayerUpdate"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(1941) : error 021: symbol already defined: "OnPlayerDisconnect"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(1970) : error 021: symbol already defined: "OnPlayerConnect"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4184) : warning 203: symbol is never used: "ForbiddenWeapons"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Thanks in advanced!
Reply
#2

Search for y_hooks.
Reply
#3

pawn Код:
AC_OnPlayerConnect(playerid)
{
    pMoney[playerid] = 0;
    return 1;
}
AC_OnPlayerDisconnect(playerid, reason)
{
    pMoney[playerid] = 0;
    return 1;
}
AC_OnPlayerUpdate(playerid)
{
    new pName[MAX_PLAYER_NAME], w = 0, string[128];

    if(GetPlayerMoney(playerid) > pMoney[playerid]){
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
        SendClientMessageToAll(WHITE, string);
        BanEx(playerid, "[Cheats Detected]: Money Hax");
    }
    while(w < (sizeof(ForbiddenWeapons))){
        if(GetPlayerWeapon(playerid) == w){
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
            SendClientMessageToAll(WHITE, string);
            BanEx(playerid, "[Cheats Detected]: Weapon Hax");
        }
    }
    return 1;
}
I havnt tested it although use that then put the functions in the callbacks
Reply
#4

@ Lorenc_

I get these warnings now:

Код:
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4184) : warning 203: symbol is never used: "AC_OnPlayerConnect"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4184) : warning 203: symbol is never used: "AC_OnPlayerDisconnect"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4184) : warning 203: symbol is never used: "AC_OnPlayerUpdate"
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4184) : warning 203: symbol is never used: "ForbiddenWeapons"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Warnings.
Reply
#5

Ok, Go on your script you want to implement the include on and on the callback Onplayerconnect add:
AC_OnPlayerConnect(playerid);

Then go on the OnPlayerDisconnect(playerid, reason) callback and add AC_OnPlayerDisconnect(playerid, reason);
Finally go on the OnPlayerUpdate(playerid) callback and add AC_OnPlayerUpdate(playerid);

-Lorenc

Edit: Or you can add the stock Keyword on each on those functions

pawn Код:
stock AC_OnPlayerDisconnect(playerid, reason) {
...}

stock AC_ OnPlayerConnect(playerid) {
...}

stock AC_OnPlayerUpdate(playerid){
...}
Reply
#6

In includes you can't use the callbacks that are used in the main script you need to use callback hooking. As mentioned earlier look for y_hooks its easy to use and works a treat.

Or do what lorenc said.
Reply
#7

Its works fine now but when i try to add to a FS i get errors does it need to be a seprate FS version of the include?

Please help
Reply
#8

Just incase your interested this is how it would be with y_hooks, see if this works better for what you want (without errors hopefully). I'v not tested it but should work.
pawn Код:
//By Weponz For Vegas CNR Server
//Full Credits To: Kwarde //Complete Tutorial

#include <a_samp>
#include <YSI/y_hooks>

#define WHITE     0xFFFFFFAA

new pMoney[MAX_PLAYERS];
new ForbiddenWeapons[][] = {
    16, //Grenades
    34, //Sniper Rifle
    37, //Flamethrower
    38, //Minigun
    39, //Satchel
    35, //RPG
    36, //Heatseeking RPG
    44, //Nightvision Goggles
    45 //Thermal Goggles
};

Hook:FSinit_OnPlayerConnect(playerid)//you can swap "FSinit" for whatever name you like (no keywords obviously)
{
    pMoney[playerid] = 0;
    return 1;
}
Hook:PlayerDc_OnPlayerDisconnect(playerid, reason)//you can swap all these names just not the callback part (after the underscore)
{
    pMoney[playerid] = 0;
    return 1;
}
Hook:PlayerUpdate_OnPlayerUpdate(playerid)
{
    new pName[MAX_PLAYER_NAME], w = 0, string[128];

    if(GetPlayerMoney(playerid) > pMoney[playerid]){
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
        SendClientMessageToAll(WHITE, string);
        BanEx(playerid, "[Cheats Detected]: Money Hax");
    }
    while(w < (sizeof(ForbiddenWeapons))){
        if(GetPlayerWeapon(playerid) == w){
            GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
            format(string, sizeof(string), "[VEGAS-BOT]: %s Has Been Banned From The Server! [Cheats Detected]", pName);
            SendClientMessageToAll(WHITE, string);
            BanEx(playerid, "[Cheats Detected]: Weapon Hax");
        }
    }
    return 1;
}
stock a_GivePlayerMoney(playerid, money)
{
    pMoney[playerid] += money;
    GivePlayerMoney(playerid, money);
}
stock a_SetPlayerMoney(playerid, money)
{
    pMoney[playerid] = money;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid);
}
Reply
#9

@ ******

Thanks for helping

BTW I added it and get this warning

Код:
C:\Users\Weponz\Desktop\Server Files\gamemodes\vegascnr.pwn(4185) : warning 203: symbol is never used: "a_OnPlayerUpdate"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
I added a_OnPlayerUpdate(playerid); under the callback and get these errors:

Код:
C:\Users\Weponz\Desktop\Server Files\pawno\include\wepzcheat.inc(28) : error 017: undefined symbol "pMoney"
C:\Users\Weponz\Desktop\Server Files\pawno\include\wepzcheat.inc(28) : warning 215: expression has no effect
C:\Users\Weponz\Desktop\Server Files\pawno\include\wepzcheat.inc(28) : error 001: expected token: ";", but found "]"
C:\Users\Weponz\Desktop\Server Files\pawno\include\wepzcheat.inc(28) : error 029: invalid expression, assumed zero
C:\Users\Weponz\Desktop\Server Files\pawno\include\wepzcheat.inc(28) : fatal error 107: too many error messages on one line

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


4 Errors.
Any help :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)