Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums



(Advanced Search)

Forum Statistics
» Members: 6,503
» Latest member: tdtcrocks
» Forum threads: 2,240
» Forum posts: 12,046

Full Statistics

Online Users
There are currently 485 online users.
» 1 Member(s) | 482 Guest(s)
Bing, Google, uzi

Latest Threads
Rosalife Gamemode [openMP...
Forum: Gamemodes
Last Post: vactidylee
11 hours ago
» Replies: 5
» Views: 4,524
White Screen
Forum: Support
Last Post: Phat202146_real
Yesterday, 02:50 PM
» Replies: 0
» Views: 24
Offensive-Core: TDM
Forum: Gamemodes
Last Post: threezhang.cn
Yesterday, 09:54 AM
» Replies: 5
» Views: 934
Outstanding Customer Serv...
Forum: Chat
Last Post: va6220902
Yesterday, 07:52 AM
» Replies: 0
» Views: 29
New place
Forum: Life
Last Post: sjaardamilly
Yesterday, 06:58 AM
» Replies: 0
» Views: 23
How Zhewitra Oral Jelly W...
Forum: General Discussions
Last Post: erctilenovus
2024-11-20, 08:39 AM
» Replies: 0
» Views: 27
Cenforce 100 Mg Medicine ...
Forum: Chat
Last Post: ezraallen45ea
2024-11-19, 10:00 AM
» Replies: 0
» Views: 36
I get error 021 using y_h...
Forum: Pawn Scripting
Last Post: daniscript18
2024-11-18, 11:34 PM
» Replies: 0
» Views: 41
What is the use of Wakler...
Forum: Other
Last Post: allencooper
2024-11-18, 10:37 AM
» Replies: 0
» Views: 24
Il reste des français sur...
Forum: French/Fran?ais
Last Post: tysanio
2024-11-18, 05:39 AM
» Replies: 2
» Views: 441

 
  Post your Setup Megathread
Posted by: GlorifiedPig - 2019-04-14, 12:49 PM - Forum: Chat - Replies (1)

Here's mine. It's a very old picture, looks different now. Ignore the low brightness and odd wallpaper.

[Image: 20181111_223948.jpg]



Here's my specs:

[Image: PWL00C1.png]


  Forum games section
Posted by: GlorifiedPig - 2019-04-14, 12:46 PM - Forum: Chat - Replies (1)

Add a forum games section. Would be useful in numerous ways.


  qualcuno mi spiega la differenza tra samp e open.mp
Posted by: ronfino - 2019-04-14, 12:21 PM - Forum: Italian/Italiano - Replies (11)

tipo le features


Thumbs Up [Servidor] Nova RolePlay ?Actualizado!
Posted by: Marg - 2019-04-14, 12:19 PM - Forum: Discusi?n GTA SA Multijugador - Replies (30)

[Image: Sin-titulo-1.png]

Servidor?de?SAMP 0.3.7 ,?Contamos con una variedad de sistemas que te gustaran , tambien variedad de mappeos ,mappeos que te encantaran , trabajos que pronto mostraremos , lo que nos basamos en hacer un mundo mas abierto , con una economia mucho mas amplia con gran variedad de productos y haciendo que la?jugabilidad sea la mas comoda para el usuario , con eso me refiero a usar la menor?cantidad de comandos.

Sistema de reloj

con 15 tipos de relojes diferentes y pronto relojes digitales o?SmartWatch.

[Image: RelojAzul.PNG][Image: RelojORO.PNG][Image: RelojPlata.PNG]

Sistema de celular

muchos tipos diferentes.

[Image: Verde.PNG][Image: Rosa.PNG][Image: Gris.PNG]

Sistema de TV

podras ver la TV.



[Image: TVS.PNG?width=400&height=190]


Mapas

Contamos con gran variedad de mappeos nuevos.

NovaNet

[Image: NovaNet3.PNG]

LSTV

[Image: LSTV.PNG]







Discord de facciones :?https://discord.gg/cRF4b48

Discord del servidor :?https://discord.gg/mq242XC


  Indonesian
Posted by: X337 - 2019-04-14, 12:09 PM - Forum: Other - Replies (8)

hai semuanya o/


Exclamation Agregar mas categorias
Posted by: Marg - 2019-04-14, 12:00 PM - Forum: Spanish/Espa?ol - Replies (19)

Categorias

Pienso que deberian agregar ya mas categorias a la secci?n espa?ol , portugues , rusa y otros... , en especial espa?ol ya que es la secci?n que tiene actualmente mas actividad y mas conocen sobre la existencia de?este proyecto.

Ejemplo:

>Informaci?n

>Sugerencias

>Ayuda

>Pedidos

>Mapas

>Scripts


  Samp 'unofficial discord'
Posted by: Syed - 2019-04-14, 11:48 AM - Forum: Chat - Replies (1)

Yo,? can anyone pass me the link to samp unofficial discord, thanks in advance!


  SmartCMD: a fast and feature rich command processor
Posted by: Yashas - 2019-04-14, 11:43 AM - Forum: Libraries - Replies (1)

Smart Command Processor BETA

Latest Version: 0.3.2 beta (25th December 2017)



Important Issues:

  1. YSI related includes must be included before SmartCMD for it to work.


What is SmartCMD?

SmartCMD is a fast feature rich command processor which simplifies the creation and handling of commands. SmartCMD (known as iZCMD in its initial days), is iZCMD loaded with new features but ironically, it is faster than iZCMD. SmartCMD works on the same principle which iZCMD/ZCMD works on, i.e: create commands as public functions and call the public function when the command is used. However, there are few subtle changes in the core algorithm to make allowances for the new features.



What's new?
  • Command IDs

    SmartCMD assigns a unique ID number to each command to enhance the overall performance. By using command ids instead of command names, costly string comparisons can be avoided.





  • Delete/Undelete commands

    Delete and un-delete commands at runtime.





  • Command Flags

    A command flag is just a variable associated with each command. You can store crucial information about each command in its flag. Flags are optional. Unlike most command processors, command flags can be assigned right next to the command declaration during compile time.





  • Alternate Command Names

    Unlike iZCMD/ZCMD, creating alternate command names does not take any extra CPU. Using the alternate command is as fast as using the parent command. The include provides a simple one liner method to set alternate commands. It also allows you to customize these commands like normal commands.





  • Command Modes/States

    You can have more than one command function associated with each command.





  • Iterating through commands

    Given that the command ids are continuous and the include stockpiles information about every command, it allows iterating through all commands with specific properties. If you'd ever need to implement per-player command permissions or need to store special information specific to each command, it'll take you less than 5 minutes to set things up using this include.





  • Reassign Command Functions

    You can modify command behavior at runtime! The include provides facilities to change a command's function at runtime.





  • Super-friendly include

    SmartCMD allows you to set command properties such as flags, alternate names during compile time while declaring/defining the command itself so that you don't have to fill your OnGameModeInit/OnFilterScriptInit with trash. You can also access command ids and command flags by a simple variable fetch; no need to bloat your code with GetCommandID or Get/SetCommandFlags function calls.





  • Extensible

    The include provides several low level functions which allows anyone to customize the include without directly editing the include. This makes updating easier as your customized functionality is not a part of the include: you won't have to tweak your custom feature code when you update SmartCMD and no code copy-pasting is required.





  • Documentation

    Detailed documentation (with example cod) for every function is present in the include itself. Other aspects of the include have been covered in detail in this topic with several examples.




How to install?

SmartCMD is available as a PAWN include. Download the include from one of the download sources mentioned at the 'download' section of this topic and place it in your "pawno/include" folder.



To add SmartCMD to your script, include 'smartcmd' anywhere in your script (as long as it is included before it's use) using the following code:

Code:
#include <smartcmd>



If you are using a filterscript, ensure that you have FILTERSCRIPT defined before including SmartCMD.



Code:
#define FILTERSCRIPT



How to upgrade to SmartCMD from iZCMD/ZCMD?

Changing commands:

  1. Open Find & Replace Dialog (Ctrl H)

  2. Provide search term as "(playerid, params[])"

  3. Set the replacement text to "(cmdid, playerid, params[])"

  4. Click on Replace All


Changing callbacks:

  1. Go to your OnPlayerCommandReceived declaration if it exists

  2. Change the declaration to "OnPlayerCommandReceived(cmdid, playerid, cmdtext[])"

  3. Go to your OnPlayerCommandPerformed declaration if it exists

  4. Change the declaration to "OnPlayerCommandPerformed(cmdid, playerid, cmdtext[], success)"


Converting iZCMD/ZCMD alternate commands to SmartCMD alternate commands:

  1. Add "ALT:alternate_name = CMD:original_name;" anywhere in your script outside executable blocks (functions).

  2. Remove the old iZCMD/ZCMD type alternate command


Replacing manual command function calls:

  1. Open Find Dialog (Ctrl F)

  2. Search for "cmd_"

  3. Replace "cmd_urcmd(playerid, params)" with "cmd_urcmd(cid_urcmd, playerid, params)".


You can upgrade your code using SmartCMD features as you like. For example, you can assign admin levels to command using flags and check the sender's admin level in OnPlayerCommandReceived. You can do the same for other class specific commands. You can do a lot with this include. It is up to you to decide how you'll make the best use of this include.



Creating commands

You can create commands in four different ways. All the forms of command declarations are functionally identical.



For every command you create, SmartCMD creates a public function with the command's code (check Technical Details section to know more). This public function is known as the command('s) function. SmartCMD also assigns a unique number to each command which is known as command id. An invalid command id is identified with INVALID_COMMAND_ID.



Code:
COMMAND:yourcommand(cmdid, playerid, params[])

{

????? return CMD_SUCCESS;

}

CMD:yourcommand(cmdid, playerid, params[])

{

????? return CMD_SUCCESS;

}

command(yourcommand, cmdid, playerid, params[])

{

????? return CMD_SUCCESS;

}

cmd(yourcommand, cmdid, playerid, params[])

{

????? return CMD_SUCCESS;

}



When a player types "/yourcommand parameters", the command function will be called. The 'cmdid' parameter gives you the unique command id which you can use to manipulate the command and its properties. The 'playerid' parameter will have the id of the player who used the command. The 'params' array will have the text which the player typed after the command (in the given example, params will have "parameters"). If any leading spaces were present in the parameters, they will be absent in 'params' array.



You must return CMD_SUCCESS (or 1) if the command was executed successfully and CMD_FAILURE (or 0) if the command failed to execute properly. If there is no return statement in your command or if the command crashes during execution, CMD_FAILURE will be returned by default.



You can return '1' in place of CMD_SUCCESS and return '0' in place of CMD_FAILURE if you wish to.



Adding default flags

Unlike other command processors, SmartCMD allows you to give default flags for commands while writing the command itself. It is 'optional', you can write a command without providing default flags and it will still compile. The flags of such commands will be initialized with zero (the default value for default flags can be changed by defining CMD_DEFAULT_FLAG).



Code:
enum (*=2)

{

???? ADMIN_COMMAND = 1,

???? VIP_COMMAND,

???? DEBUG_COMMAND

}

COMMAND<ADMIN_COMMAND>:ban(cmdid, playerid, params[])

{

? return CMD_SUCCESS;

}

CMD<ADMIN_COMMAND>:ban(cmdid, playerid, params[])

{

? return CMD_SUCCESS;

}

command<ADMIN_COMMAND>(ban, cmdid, playerid, params[])

{

? return CMD_SUCCESS;

}

cmd<ADMIN_COMMAND>(ban, cmdid, playerid, params[])

{

? return CMD_SUCCESS;

}



That's it! No junk in OnGameModeInit or OnFilterScriptInit or anywhere else.



The flags are stored in a hidden variable which identifies itself with the command name prefixed with 'flg_'. This variable can be accessed and modified by you at runtime.



Code:
CMD:test(cmdid, playerid, params[])

{

???? printf("This command's flags variable has the value: %d", flg_test);

???? flg_test = ADMIN_COMMAND; //You can even change the flags by directly assigning values to the flag variable

???? return CMD_SUCCESS;

}



When you don't know the command's name beforehand or when you are dealing with a general case where the command could be any command, you can obtain/modify the flags using GetCommandFlags(cmdid) and SetCommandFlags(cmdid, flags) functions.



As the name suggests, GetCommandFlags(cmdid) is used to access a command's flags and SetCommandFlags(cmdid, flags) is used to set a command's flags.



In an earlier example, flags was used as a bitmask. However, you have all the freedom to use it in whatever way you want as the flags is essentially a cell/variable associated with each command. It can be used to store an integer, float, etc.



Adding alternate command names:

SmartCMD introduces a new syntax for adding alternate names to commands. Calling the alternate command is as good as calling the actual command itself performance-wise.



Code:
CMD:spectate(cmdid, playerid, params[])

{

??? //even when you use spec, sp, the cmdid passed to spectate function will always be that of the spectate command

??? return 1;

}

ALT:spec = CMD:spectate;

ALT:sp = CMD:spectate;



ALT:alternate_name = CMD:original_name;



When a player uses an alternate command, SmartCMD directly calls the parent command, unlike iZCMD/ZCMD where the alternate command is first called which then calls the parent command.



The command function of the parent command which the alternate command points to (spectate in the above case), when called via an alternate command (spec, sp, view in the above case), will receive the command id of the parent command. There is no way the command function can find out if the alternate command was used or if the parent command was used. However, you must note that the alternate commands do have their own unique command id. This allows you to modify properties of an alternate command without affecting it's parent command. The alternate command also has it's own flags variable. The flags variable is initialized with the flags of it's parent command just once during initialization. Any change made to the flags of any alternate command won't affect the parent command or vice versa.



You can make two separate distinguishable commands which share the same code using the function reassignment feature. When a reassigned command is called, the parent command will be called with the alternate command's command id (you can't call it an alternate command anymore; it is just a command which has its command function assigned to another function).



In such cases, you can either use GetCommandID or use the scripter-friendly command id variables to check which command was actually used by the player.



Code:
//abc is not an alternate command to xyz but has it's command function reassigned to that of xyz

CMD:xyz(cmdid, playerid, params[])

{

????? if(cmdid == cid_xyz) //directly using variables is faster than using GetCommandID

????? {

????????????? //player used /xyz

????? }

????? else if(cmdid == cid_abc) //cid_xyz and cid_abc are defined by SmartCMD

????? {

???????????? //player used /abc

????? }

????? return CMD_SUCCESS;

}



Every command has an id variable which is identified as command name prefixed with "cid_". These are fixed constants which cannot be modified.



Code:
CMD:xyz(cmdid, playerid, params[])

{

????? printf("The command id of xyz is %d", cid_xyz);

????? cid_xyz = 123; // error - you cannot modify a constant variable

????? return CMD_SUCCESS;

}



Adding additional command functions

You can create any number of additional functions for a command. These are also known as command modes or command states.



The syntax for creating an additional command function is as follows:



Code:
CMD:ban[params](cmdid, playerid, params[]) //Flags for additional command functions are redundant.

??????? return SendClientMessage(playerid, -1, "/ban [playerid/name] [reason]");

CMD<ACMD>:ban[help](cmdid, playerid, params[]) //You can still provide the flag if you want. It has no meaning however, i.e: it wont be used.

??????? return SendClientMessage(playerid, -1, "Bans the player.");

CMD<ACMD>:ban(cmdid, playerid, params[]) //all the additional command function use the flags

{

???? //ban code

???? return CMD_SUCCESS;

}



The flags of an additional command function have no meaning, they are redundant. They are there for the sake of providing the choice of readability, it matters for those who would prefer to keep the flags in additional command functions for consistency.



There must always be a command function without any specific mode. This will be the command function executed when the player types the command.



Each additional command mode/state is given a unique name inside the square brackets ([ ]). To execute an additional command function, use have to use ExecuteCommand function.



Code:
ExecuteCommand("ban", state_name, playerid, "params");




Callbacks

When a player sends a command, SmartCMD calls OnPlayerCommandReceived (if you have defined it in your script) before executing the command where you can decide if the command has to be executed or not. If the command function is allowed to execute in OnPlayerCommandReceived, SmartCMD will call the command function. After the command function finishes executing, SmartCMD will call OnPlayerCommandPerformed (if you have defined it in your script) with necessary details including the return value of the command function.



OnPlayerCommandReceived

Arguments:
  • cmdid: Command ID of the command used by the player. If the entered command does not exist, cmdid will be set to INVALID_COMMAND_ID.

  • playerid: ID of the player who used the command

  • cmdtext: The exact text which the player had typed in the message bar (for example, "/ban 0 test")


Return Values:

1 - Will allow the execution of the command function if it exists. If the command does not exist, OnPlayerCommandPerformed will be called with the "success" parameter as CMD_FAILURE.

0 - Will prevent the execution of the command function.



Code:
public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

{

??????? if(cmdid == INVALID_COMMAND_ID)

??????? {

??????????????? SendClientMessage(playerid, RED, "You typed an invalid command.");

??????????????? //return 1; //will call OnPlayerCommandPerformed with success value as CMD_FAILURE.

??????????????? return 0; //won't call OnPlayerCommandPerformed

??????? }???? ?

?? ?return 1;

}



OnPlayerCommandPerformed

Arguments:
  • cmdid: Command ID of the command used by the player. If the entered command does not exist, cmdid will be set to INVALID_COMMAND_ID.

  • playerid: ID of the player who used the command

  • cmdtext: The exact text which the player had inputted into the message bar (for example, "/ban 0 test")

  • success: The value returned by the command function if it was existed. If it did not exist, success will be set to CMD_FAILURE by default.


Return Values:

0 or CMD_FAILURE - passes the command to other scripts for processing. If all the scripts return CMD_FAILURE or 0,? the player will see the default error message, i.e "Unknown command".

1 or CMD_SUCCESS - stops the processing (does not pass the command to the next script in line)



Code:
public OnPlayerCommandPerformed(cmdid, playerid, cmdtext[], success)

{

??????? //a valid command but failed to complete? maybe it crashed?

??????? if(cmdid != INVALID_COMMAND_ID && !success) return SendClientMessage(playerid, RED," Oops! The command failed to execute properly."), 1; //write to the crash log?

?? ?return 1; //won't send the default error message

}



If you are not using OnPlayerCommandPerformed then what you return in your command function will decide if the error message will be sent or not.



Returning 0 or CMD_FAILURE in the command function means the error message will be sent.

Returning 1 or CMD_SUCCESS in the command function means the error message won't be sent.



Defines & Macros



Defines



The defines marked with an asterisk ( '*' ) can be defined by you before including if you wish to (if not defined, the default value will be assumed). If you are defining any of them yourself, they must be done before including SmartCMD so that SmartCMD is aware of the change.



MAX_PUBLIC_FUNCTIONS*

1024

Maximum number of public functions. If you script contains more public functions than the value set to MAX_PUBLIC_FUNCTIONS, SmartCMD will send an error message in the console in runtime. In that case, increase the value of this define.[/td]



MAX_COMMANDS*

500

Maximum number of commands. If you script contains more commands than the value set to MAX_COMMANDS, SmartCMD will send error messages in the console. In that case, increase the value of this define.



MAX_CLIENT_MSG_LENGTH

144

Maximum length of client message.



MAX_FUNC_NAME

32

Maximum length of a PAWN function identifier (including null terminator).



MAX_COMMAND_NAME

28

Maximum length of a command name (including null terminator).



INVALID_COMMAND_ID

-1

Used to refer to an invalid command.



IZCMD_ENABLE_CASE_SENSITIVITY*

not defined

Defining IZCMD_ENABLE_CASE_SENSITIVITY will make commands case-sensitive ("/pm" and "/PM" will be considered as different commands).



CMD_DEFAULT_FLAG*

not defined

By default, the flags will be initialized to zero if they are not specified for the command. This define lets you change the default value of default flags.



CMD_SUCCESS

1



CMD_FAILURE

0



Macros

isnull

Checks if a string is empty/null.



Parameters:

string: The string which has to be checked

Returns:

true - if the string is null ("" or "\1")

false - if the string is not empty



Code:
CMD:pm(cmdid, playerid, params[])

{

????? if(isnull(params)) return SendClientMessage(playerid, YELLOW, "/pm [playerid/name]");



????? //you can also use the following

????? if(params[0] == 0) return SendClientMessage(playerid, YELLOW, "/pm [playerid/name]");



????? return CMD_SUCCESS;

}



Functions

Detailed description of each function can be found inside the include.



Code:
?? ?native DoesCommandExist(cmdid)

?? ?native GetCommandID(const cmd[])

?? ?native GetCommandName(cmdid, cmd[], len = sizeof(cmd))

?? ?native GetAlternateCommands(cmdid, cmdidlist[])

?? ?native IsCommandAlternate(cmdid)

?? ?native GetCommandFunctionID(cmdid)

?? ?native GetPointingCommandFunctionID(cmdid)

?? ?native GetPointingCommandID(cmdid)

?? ?native GetCommandFunctionName(dest[], cmdid, len = sizeof(dest))

?? ?native GetEnabledCommandCount()

?? ?native GetDisabledCommandCount()

?? ?native GetTotalCommandCount()

?? ?native EnableCommand(cmdid)

?? ?native DisableCommand(cmdid)

?? ?native IsCommandEnabled(cmdid)

?? ?native SetCommandFlags(cmdid, flags)

?? ?native GetCommandFlags(cmdid)

??????? native SetPointingCommandIDToSelf(cmdid)

?? ?native ReassignCommandFunction(cmdid, const funcname[], bool:updateCID = false, bool:updatePFT = false)

?? ?native EmulateCommandEx(cmdid, playerid, params[])

?? ?native EmulateCommand(playerid, cmdtext[])

?? ?native ExecuteCommand(const cmd[], command_mode, playerid, &success, params[]="")



Applications of SmartCMD features
  • command which creates a list of commands which updates itself when a command is added or removed

    It is a boon for all of us if we had a /cmds command which updates itself when a new command is added. You can make such smart commands with SmartCMD. The /acmds command is supposed to list all administrative commands available in the server. We mark all administrative commands with the ACMD flag which /acmds uses to prepare a list of all admin commands.



    Code:
    #define ACMD 1

    CMD<ACMD>:ban(cmdid, playerid, params[])

    {

    ????? //Ban Code

    ????? return CMD_SUCCESS;

    }

    CMD<ACMD>:kick(cmdid, playerid, params[])

    {

    ????? //Kick Code

    ????? return CMD_SUCCESS;

    }

    CMD<ACMD>:acmds(cmdid, playerid, params[])

    {

    ???? static str[512], bool:need_frmt = true;

    ???? if(need_frmt)

    ???? {

    ????????? new altlist[32]; //A command can have a maxiumum of 32 alternate names? it is your script and you know it!

    ????????? for(new i = 0, j = GetTotalCommandCount(); i < j; i)

    ????????? {

    ??????????????? if(i == cmdid || IsCommandAlternate(i)) continue; //Lets not add /acmds itself to the list. And also let us not add alternate commands as separate commands.

    ??????????????? if(GetCommandFlags(i) == ACMD)

    ??????????????? {

    ????????????????????? new cmd[MAX_COMMAND_NAME];

    ????????????????????? GetCommandName(i, cmd);

    ????????????????????? strcat(str, cmd);

    ????????????????????? for(new j = GetAlternateCommands(i, altlist); j; j--)

    ????????????????????? {

    ??????????????????????????? strcat(str, ",");

    ??????????????????????????? GetCommandName(altlist[j], cmd);

    ??????????????????????????? strcat(str, cmd);

    ????????????????????? }

    ????????????????????? strcat(str, "\n");

    ??????????????? } ?

    ????????? }

    ????????? need_frmt = false;

    ???? }

    ???? return ShowPlayerDialog(playerid, ACMDS_DIALOG, DIALOG_STYLE_LIST, "Admin Commands", str, "Select", "Cancel");

    }





  • Restricting access to administrative commands

    This is another boon to all of us. You don't have to check the player's admin level in each and every admin command. You need to do just one check in OnPlayerCommandReceived. We mark all admin commands with the ACMD flag. When a player sends a command, OnPlayerCommandReceived is called before the command function is executed. Therefore, we check the flags of the command to see if it is an admin command in OnPlayerCommandReceived. If it is an admin command, we then check if the player is an admin. If the player is an admin, we let the command function to execute. If the player isn't an administrator, we send an error message informing the player that he cannot use the command.



    This is faster as the command function won't even be called if the player is not an administrator unlike other command processors where the admin level checks are done inside the command function. Moreover, it keeps your code neat.



    Code:
    enum (*=2)

    {

    ????? ACMD = 1

    }

    CMD<ACMD>:ban(cmdid, playerid, params[])

    {

    ????? Ban(playerid);

    ????? return CMD_SUCCESS;

    }

    public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

    {

    ???? if(GetCommandFlags(cmdid) == ACMD)

    ????????? if(!IsPlayerAdmin(playerid))

    ????????? {

    ?????????????? SendClientMessage(playerid, RED, "You are not allowed to use this command.");

    ?????????????? return 0; //Do not execute the admin command

    ????????? }

    ??? return 1; //Execute the command

    }





  • Disabling commands in-game (Error message for disabled commands)

    By using the DisableCommand function, you are essentially deleting the command.



    Code:
    CMD<ACMD>:disablecmd(cmdid, playerid, params[])

    {

    ????? switch(DisableCommand(GetCommandID(params)))

    ????? {

    ???????????? case -1: return SendClientMessage(playerid, RED, "The entered command does not exist.");

    ???????????? case 0: return SendClientMessage(playerid, RED, "The entered command is already disabled.");

    ???????????? case 1: return SendClientMessage(playerid, RED, "The entered command has been disabled.");

    ????? }

    }

    CMD<ACMD>:enablecmd(cmdid, playerid, params[])

    {

    ????? switch(EnableCommand(GetCommandID(params)))

    ????? {

    ???????????? case -1: return SendClientMessage(playerid, RED, "The entered command does not exist.");

    ???????????? case 0: return SendClientMessage(playerid, RED, "The entered command is already enabled.");

    ???????????? case 1: return SendClientMessage(playerid, RED, "The entered command has been enabled.");

    ????? }

    }





  • Disabling commands in-game (Disabled message for disabled commands)

    In the previous example, by disabling the command, you were deleting it. When a player uses the command, it will treated as if he typed an invalid command. This example is more user friendly. Instead of deleting the command, we change the command function of the command. We first create a dummy command function which sends a message to the player informing him that the command has been disabled. We then assign the dummy command function to the command that has to be disabled. Hence, whenever a player uses the disabled command, the dummy command function will be called, which sends the disabled message.

    Code:
    forward disabled(cmdid, playerid, params[])

    public disabled(cmdid, playerid, params[])

    {

    ????? return SendClientMessage(playerid, RED, "The command has been disabled.");

    }

    CMD<ACMD>:disablecmd(cmdid, playerid, params[])

    {

    ????? switch(ReassignCommandFunction(GetCommandID(params), "disabled"))

    ????? {

    ???????????? case -1: return SendClientMessage(playerid, RED, "The entered command does not exist.");

    ???????????? case 0: return SendClientMessage(playerid, RED, "The entered command is already disabled.");

    ???????????? case 1: return SendClientMessage(playerid, RED, "The entered command has been disabled.");

    ????? }

    ????? return CMD_SUCCESS;

    }

    CMD<ACMD>:enablecmd(cmdid, playerid, params[])

    {

    ????? new cmd_func[MAX_FUNC_NAME], cid = GetCommandID(params);

    ????? GetCommandFunctionName(cid, cmd_func);



    ????? switch(ReassignCommandFunction(cid, cmd_func))

    ????? {

    ???????????? case -1: return SendClientMessage(playerid, RED, "The entered command does not exist.");

    ???????????? case 0: return SendClientMessage(playerid, RED, "The entered command is already enabled.");

    ???????????? case 1: return SendClientMessage(playerid, RED, "The entered command has been enabled.");

    ????? }

    ????? return CMD_SUCCESS;

    }





  • Custom Invalid Command Message

    Since SmartCMD lets you know if a command is invalid in OnPlayerCommandReceived itself, some processing time is saved since attempting to call the command function and then calling OnPlayerCommandPerformed is avoided.



    Code:
    public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

    {

    ???? if(cmdid == INVALID_COMMAND_ID)

    ???? {

    ?????????? SendClientMessage(playerid, RED, "The command you entered does not exist. Use /cmds to obtain a list of commands");

    ?????????? return 0; //No need to call OnPlayerCommandPerformed.

    ???? }?????? ?

    ???? return 1; //Execute the command

    }





  • Logging command crashes & player-friendly crash messages

    You can use SmartCMD to log command function failures, crashes, etc with essential information such as date/time, command name, player name and the exact command text. By saving the player's name, you can talk to the player next time you meet to collect more information.



    Code:
    public OnPlayerCommandPerformed(cmdid, playerid, cmdtext[], success)

    {

    ???? if(cmdid != INVALID_COMMAND_ID && !success) //command exists but it failed

    ???? {

    ?????????? new str[256], cmd[MAX_COMMAND_NAME], day, month, year, second, minute, hour;

    ?????????? GetCommandName(cmdid, cmd);

    ?????????? getdate(year, month, day);

    ?????????? gettime(hour, minute, second);

    ?????????? format(str, sizeof(str), "[%d:%d:%d - :%d:%d:%d][COMMAND CRASH] Command Name:%s Player:%s(%d) Cmdtext:%s", day, month, year, hour, minute, second, cmd, PlayerInfo[playerid][Name], cmdtext);



    ?????????? new File:crashlog = fopen("cmd_crashes.txt", io_append);

    ?????????? fwrite(crashlog, str);

    ?????????? fclose(crashlog);



    ?????????? SendClientMessage(playerid, YELLOW, "Oops! Sorry! The requested command failed to execute properly.");

    ?????????? return 1;

    ???? }?????? ?

    ???? return 1;

    }





  • Per-player command permissions

    Code:
    new PlayerDefaultCommandPermission[MAX_COMMANDS]; //Default permissions - note that even this can be edited in-game

    new PlayerCommandPermission[MAX_PLAYERS][MAX_COMMANDS]; //true = allowed, false = not allowed



    pubic OnPlayerConnect(playerid)

    {

    ???? memcpy(PlayerCommandPermission[playerid], PlayerDefaultCommandPermission, MAX_COMMANDS*4); //Set player command permissions to default command permissions

    ???? return 1;

    }

    CMD<ACMD>:disablepcmd(cmdid, playerid, params[])

    {

    ????? new pid, cid, cmd[MAX_COMMAND_NAME];

    ????? if(sscanf(params, "us["#MAX_COMMAND_NAME"]", pid, cmd)) return SendClientMessage(playerid, GREY, "Correct Usage: /disablepcmd [playerid/name] [command name]");



    ????? cid = GetCommandID(cmd);

    ????? if(cid == INVALID_COMMAND_ID) return SendClientMessage(playerid, RED, "The command you wished to disable for the player does not exist.");



    ????? PlayerCommandPermission[pid][cid] = false;

    ????? return SendClientMessage(playerid, GREEN, "The given command has been disabled for the given player.);

    }

    CMD<ACMD>:enablepcmd(cmdid, playerid, params[])

    {

    ????? new pid, cid, cmd[MAX_COMMAND_NAME];

    ????? if(sscanf(params, "us["#MAX_COMMAND_NAME"]", pid, cmd)) return SendClientMessage(playerid, GREY, "Correct Usage: /enablepcmd [playerid/name] [command name]");



    ????? cid = GetCommandID(cmd);

    ????? if(cid == INVALID_COMMAND_ID) return SendClientMessage(playerid, RED, "The command you wished to enable for the player does not exist.");



    ????? PlayerCommandPermission[pid][cid] = true;

    ????? return SendClientMessage(playerid, GREEN, "The given command has been enabled for the given player.");

    }

    public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

    {??? ?

    ???? if(cmdid != INVALID_COMMAND_ID && !PlayerCommandPermission[playerid][cmdid])

    ???? {

    ?????????? SendClientMessage(playerid, RED, "You are not allowed to use this command.");

    ?????????? return 0;

    ???? }

    ???? return 1;

    }





  • Making a /help [cmd] command

    Code:
    CMD:report[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Reports the player to an administrator.");

    CMD:report(cmdid, playerid, params[]) {...}



    CMD:pm[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Sends a private message to the given player.");

    CMD:pm(cmdid, playerid, params[]) {...}



    CMD:help[help](cmdid, playerid, params[]) return SendClientMessage(playerid, -1, "Access server help topics.");

    CMD:help(cmdid, playerid, params[])

    {

    ????? new success;

    ????? ExecuteCommand(params, help, playerid, success, "");

    ????? switch(success)

    ????? {

    ?????????? case INVALID_COMMAND_ID: return SendClientMessage(playerid, RED, "The specified command does not exist.");

    ?????????? case 0:? return SendClientMessage(playerid, RED, "The specified command does not have a help description.");

    ?????????? case 2: return SendClientMessage(playerid, RED, "The specified command does not exist."); //command was deleted

    //case 1: handled by the command which was executed, i.e: a description message was sent to the player

    ????? }

    ????? return CMD_SUCCESS;

    }



  • Using flags as bitmask

    As said earlier, the flags are just variables/cells like any other. You can store anything in the flags in any fashion.



    Code:
    enum (*=2)

    {

    ??? CFLAG_ACMD = 1,

    ??? CFLAG_VIP,

    ??? ADMIN_LEVEL_0,

    ??? CALEVEL_1,

    ??? CALEVEL_2,

    ??? CALEVEL_3,

    ??? //store admin level of the admin command in these 3 bits; admin level can start from 0 and go upto 7

    ??? .

    ??? .

    ??? .

    ??? //total number should not exceed 32

    }



    //we will use CALEVEL_1, CALEVEL_2, CALEVEL_3 to store the admin level as a number

    //if you understand how to write a decimal number in binary form, the following defines must be self explainatory

    #define ADMIN_LEVEL_1 CALEVEL_1 //1<<3

    #define ADMIN_LEVEL_2 CALEVEL_2 //2<<3

    #define ADMIN_LEVEL_3 CALEVEL_2 | CALEVEL_1 //3<<3

    #define ADMIN_LEVEL_4 CALEVEL_3 //4<<3

    #define ADMIN_LEVEL_5 CALEVEL_3 | CALEVEL_1 //5<<3

    #define ADMIN_LEVEL_6 CALEVEL_3 | CALEVEL_2 //6<<3

    //and so on



    stock GetAdminLevel(flags)

    {

    ?????? return ((flags & (CALEVEL_1 | CALEVEL_2 | CALEVEL_3))>>>3);

    }

    CMD<ADMIN_LEVEL_2 | CFLAG_ACMD | CFLAG_VIP>:nitros(cmdid, playerid, params[])

    {

    ????? //add nos code

    ????? return CMD_SUCCESS;

    }

    stock IsVIPCommand(cmdid)

    {

    ????? if(GetCommandFlags(cmdid) & CFLAG_VIP) return true;

    ????? return false;

    }



    In this way, you can store more than one information in flags.





  • Restricting access to administrative commands based on the player's admin level

    For those who are completely new to bit manipulation, here is a simple way to use the command id system to associate every administrative command with an administrative level. If you are not using flags for any other purpose, you can use the flags itself as a access level indicator (i.e: use flags of every command to store the admin level as an integer).



    Code:
    flg_kick = ADMIN_LEVEL_2;

    flg_ban = ADMIN_LEVEL_3;



    but using the above method wont allow you to use the flags for any other purpose. Therefore, it is advisable not to use the whole flags to store the admin level as an integer so as to future proof your code.



    So here is another way.



    Code:
    enum (*=2)

    {

    ??? VIP_CMD = 1,

    ??? RCON_CMD,

    ??? ACMD1,

    ??? ACMD2,

    ??? ACMD3,

    ??? ACMD4,

    ??? ACMD5

    }



    new AdminLevel[MAX_COMMANDS] = {0,0 ,0, ...};



    CMD<ACMD1>:spectate(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD2>:kick(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD3>:ban(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD4>:banip(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD5>:setlevel(cmdid, playerid, params[])

    {

    ????? return 1;

    }



    public OnGameModeInit()

    {

    ????? for(new i = GetTotalCommandCount()-1; i >= 0; i--)

    ????? {

    ???????????? new flags = GetCommandFlags(i);

    ???????????? if(flags & ACMD1) AdminLevel[i] = 1;

    ???????????? else if(flags & ACMD2) AdminLevel[i] = 2;

    ???????????? else if(flags & ACMD3) AdminLevel[i] = 3;

    ???????????? else if(flags & ACMD4) AdminLevel[i] = 4;

    ???????????? else if(flags & ACMD5) AdminLevel[i] = 5;

    ????? }

    }



    public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

    {

    ??????? if(cmdid == INVALID_COMMAND_ID) return SendClientMessage(playerid, RED, "You typed an invalid command. Use /cmds to obtain a list of commands.");



    ??????? if(PlayerAdminLevel[playerid] < AdminLevel[cmdid]) return SendClientMessage(playerid, RED, "You are not allowed to use this command."), 0;

    }





    Here is another way to do the same. (the best method in my opinion)

    Code:
    enum (*=2)

    {

    ??? VIP_CMD = 1,

    ??? RCON_CMD,

    ??? PLAYER_CMD.

    ??? ACMD1,

    ??? ACMD2,

    ??? ACMD3,

    ??? ACMD4,

    ??? ACMD5

    }



    #define



    CMD<ACMD1>:spectate(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD2>:kick(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD3>:ban(cmdid, playerid, params[])

    {

    ????? return 1;

    }

    CMD<ACMD4>:banip(cmdid, playerid, params[])

    {

    ????? return 1;

    }



    CMD<ACMD5>:setlevel(cmdid, playerid, params[])

    {

    ????? return 1;

    }



    public OnPlayerCommandReceived(cmdid, playerid, cmdtext[])

    {

    ???????? static AdminLevelFlag[6] = {?? ?PLAYER_COMMAND, //normal player command

    ?? ? ?? ??? ??? ??? ??? ??? ??? ??? ?PLAYER_COMMAND | ACMD1,

    ?? ??? ??? ??? ??? ??? ??? ??? ??? ?PLAYER_COMMAND | ACMD1 | ACMD2, //allow level 2 admins to use level 1 commands

    ?? ??? ??? ??? ??? ??? ??? ??? ??? ?PLAYER_COMMAND | ACMD1 | ACMD2 | ACMD3, //allow level 3 admins to use level 1 and 2 commands as well

    ?? ??? ??? ??? ??? ??? ??? ??? ??? ?PLAYER_COMMAND | ACMD1 | ACMD2 | ACMD3 | ACMD4,

    ?? ??? ??? ??? ??? ??? ??? ??? ??? ?PLAYER_COMMAND | ACMD1 | ACMD2 | ACMD3 | ACMD4 | ACMD5};



    ??????? if(cmdid == INVALID_COMMAND_ID) return SendClientMessage(playerid, RED, "You typed an invalid command. Use /cmds to obtain a list of commands.");



    //Check if this particular admin level has access to the command

    ??????? if(!(GetCommandFlags(cmdid) & AdminLevelFlag[PlayerAdminLevel[playerid]])) return SendClientMessage(playerid, RED, "You are not allowed to use this command.") ,0



    ?????? return 1;

    }


Technical Details (Optional)

Anything which can be typed and prefixed with a '/' is known as a command. The commands which can be processed are known as valid commands and the ones which don't exist are known as invalid commands. By this definition, alternate names for commands are separate commands, i.e: if you had a /spectate command which has an alternate name as /spec then /spec would be a different command but it works as an alternate for the /spectate command.



Commands & Command ID:

Every command including alternate commands is assigned a unique number known as command id. If you had a spectate command which has alternate names such as spec, spectate and spec will have different command id. This allows you to modify properties (disable, reassign, etc) of alternate commands without affecting its parent command.



The command ids start from 0 and can go upto a maximum of MAX_COMMANDS. You can get the highest command id by subtracting one from GetTotalCommandCount().



Code:
for(new i = 0, j = GetTotalCommandCount(); i < j; i)

{

???? //Loop through all the commands

}



Every command has a public function associated with it known as command function. SmartCMD converts your code into proper PAWN code for compiling.



Code:
CMD:pm(cmdid, playerid, params[])

{

?????? return CMD_SUCCESS;

}

CMD<ACMD>:kick(cmdid, playerid, params[])

{

?????? return CMD_FAILURE;

}

ALT:kik = CMD:kick;



The above code translates to



Code:
forward _CCCM:tag@pm();

public flg_pm = CMD_DEFAULT_FLAG;

stock flg@pm=flg_pm; //To avoid unused symbol warnings

public stock const cid_pm = -1; //Yes, it is -1. SmartCMD will later initilize this variable with the correct command id.

forward cmd_pm(cmdid, playerid, params[]);

public cmd_pm(cmdid, playerid, params[]) <> return izcmd_cmd_handled:0;

public cmd_pm(cmdid, playerid, params[]) <cmdMode:normal>

{

???? return CMD_SUCCESS;

}



forward _CCCM:tag@kick();

public flg_kick = (ACMD);

stock flg@kick=flg_kick;

public stock const cid_kick = -1;

forward cmd_kick(cmdid, playerid, params[]);

public cmd_kick(cmdid, playerid, params[]) <> return izcmd_cmd_handled:0;

public cmd_kick(cmdid, playerid, params[]) <cmdMode:normal>

{

???? return CMD_SUCCESS;

}



public flg_kik = (CMD_DEFAULT_FLAG); //SmartCMD will later initilize this variable with the flags of its parent command, in this case, flags of kick.

stock flg@kik=flg_kik;

public stock const cid_kik = -1;

public alt_kik = -1;

stock alt@kik = alt_kik;

forward cmd_kik(cmdid, playerid, params[]);

public cmd_kik(cmdid, playerid, params[]) <> return izcmd_cmd_handled:0;

public cmd_kik(cmdid, playerid, params[]) <cmdMode:normal> //will be executed automatically during initilization

???????? return _izcmdp_register_alias(GetCommandID("kick"), cmdid);



If case-sensitivity is not enabled, all command names must be written in small caps.



There are two ways in which a command can call the command function of some other command.



Alternate Commands: These commands pretend to be the other command. Using /spec is identical to using /spectate. When a player uses the /spec command, the /spectate command will be called with command id that of /spectate. There is no way you can know if the player used /spectate or /spec.



Reassigned Commands: These commands call the command function of the other command but do not pretend to be that command. Suppose, /spec instead of being an alternate command to /spectate had itself reassigned to /spectate. When /spec is used by a player, the /spectate command function is called BUT "the command id passed to the /spectate command will be that of /spec".


  • Pointing command id: The id of the command to which the command points to. For example, the alternate command /spec points to /spectate. Note that reassignment of command function does not make it point to another command by default rather it just changes the command's command function.



  • Actual/original command id: This is the command id of the command itself and is no way related to what it points. For example, /spec has its own command id and this is called the actual/original command id but it points to the /spectate command.


The command id can be accessed directly by referencing the id variable. The id variable's identifier is the command name itself prefixed with "cid_", for example, "cid_spectate".



In cases where you do not know the command name beforehand, you can use GetCommandID function to obtain the command id from its name.



Function Index:

Every command has its own command function including alternate commands (command functions of alternate commands are defunct - they exist for initialization purposes only and cannot be used unless they are reassigned).



The command function identifies itself with the command name prefixed with "cmd_". You can call the command function directly as given below



Code:
cmd_test(cid_test, playerid, params[]); //calls test command



Using the above method will not trigger the OnPlayerCommandReceived or OnPlayerCommandPerformed callback. Use EmulateCommand(Ex) if you want the callbacks to be executed.


  • Pointing function index: The index of the function the command points to. Both alternate commands and reassigned commands point to the function which it executes when used.



  • Actual/original function index: This value is a number which gives the position of the command in a sorted list of commands. This function index is usually the index of the command function at startup. This is an intrinsic property of a command name and it never changed in run-time.


Command Flags:

Every command has its own flags, including alternate commands (flags are redundant in case of alternate commands). The alternate commands are an identical copy of their parent command except for their name. Therefore, the flags of an alternate command are initilized with that of its parent command but any changes made to the flags of the parent command wont cause any corresponding change in the flags of its alternate commands. For example, changing the flags of /spectate command does NOT alter the flags of its alternate /spec command.



These flags are essentially a tagged variable (tag of the variable is 'flags') which can store any data related to the command.



The command flags can be accessed and modified directly by referencing the flag variable. The flag variable's identifier is the command name itself prefixed with "flg_", for example, "flg_spectate".



In case you do not know the command name beforehand, you can use GetCommandFlags and SetCommandFlags to modify the flags of a command.



Command States/Modes:

SmartCMD uses the automata (state functions) feature provided in PAWN to implement command states/modes. The automata is named "cmdMode". The command function function without any mode is the default command which is executed every time a command is used unless explicitly mentioned. SmartCMD assigns the 'normal' state to the default command function.



You can change the command mode dynamically anywhere in the code using the following code,



Code:
state cmdMode:mode_name;



Whenever a command is executed, the state is set back to normal mode.



Performance Benchmarks

iZCMD Average (non-case sensitive): 1075ms

SmartCMD Average (non-case sensitive): 842ms



iZCMD Average (case-sensitive): 901ms

SmartCMD Average (case sensitive): 680ms



SmartCMD Benchmark Code: http://pastebin.com/x7tXAekb



Download



Github

Visit Github Repository



View the include



Credits

Yashas

Y_Less - #define tricks

Crayder - constructive talks

Zeex - the concept of making public functions


  Aimbot detector using Artifical Intelligence
Posted by: Yashas - 2019-04-14, 11:30 AM - Forum: Plugins - Replies (2)

AntiAimbot

Version: E1 (experimental version)

DISCLAIMER:
- the plugin is still experimental and has undergone rigorous testing on artificial servers but hasn't been tested on a real server with a large player base
- works for M4/AK47/MP5 only

AntiAimbot is an aimbot detector which uses a combination of empirical methods and artificial intelligence to accurately identify players using any form of aim assist. Empirical methods such as high ratio on moving players are used to efficiently suspect players of using aimbot. The samples of players suspected of using aim assist tools are forwarded to a combination of AI machinery consisting of mainly a neural network and a support vector machine for further detailed analysis. The AI machinery investigates the samples and decides if the feat achieved is humanly possible or not by "probably" (they are all black boxes) analyzing how quickly the aim moves, how synchronized the aim was with the motion of the victim, how fast the player reacts to changes and many such features.

The latest version is significantly more accurate than the version used in the vdeio.


Overview:

The entire process can be divided into two sections based on the type of used: empirical methods and artificial intelligence methods. The empirical methods are used to quickly suspect the possibility of an aim assist software being used while the artificial intelligence based methods are used to analyze the suspected samples more rigorously.

The AI-based detectors are trained to identify possible use of aim assist accurately when possible, i.e. they give negatives when they aren't sure. Given enough time, they will mostly detect the use of aim assist.

Quote:The submitted vectors go through a lot of stages.

stages of data flow:

data collection: a script collects shot vectors
pre-filter: carries out checks to eliminate unreliable shot vectors
transform: transforms shot vectors to a form suitable for feature extraction
pooling: pool together a variable number of transformed vectors to form a complete sample
extract features: extract features from the vector pool
post-filter: carry out basic empirical checks on the sample to check reliability and possible use of aim-assist; if suspicious, forward it to the AI machinery
detectors: run through different detectors and average the result


Some of the pre-filter conditions are:
- must use a M4/AK47/MP5 (other weapons are disabled because of their unreliability)
- the victim must be moving
- and many more

If a shot fails any of these conditions, the entire running pool is rejected and starts afresh.

After pooling many shots together, it goes through another filter. The filter decides if there is enough information that can be extracted from the pool; if not, it continues to collect more shot. Once there is enough useful information, it checks for reliability and estimates the use of aimbot, for example, by checking the pool's ratio (required to be high for last X number of shots where X is between 7 and 20).

It's only after this step the sample is said to be fully complete. This is when `submit_vector` returns 1. This sample is put in a queue for processing. The detectors are running in different threads. They pick a sample from the input queue, investigate it, dump it to the output queue. In the server's next tick cycle, results are pulled out of the output queue and the callback is triggered for each sample.

Hence, the callback is triggered only when there was enough suspicion and after it was processed by the AI machinery.

TL;DR:
- callback is triggered only when there is some suspicion, i.e. when the empirical methods suggest the use of aimbot
* however, the AI machinery can reverse the decision and say this may not have been an aimbot
- it's difficult to get the callback triggered without using an aimbot because most samples are rejected empirical methods
- callback is triggered every minute or so when an aimbot is used
* the callback being triggered does not imply that aimbot was used; you need to check the probabilities

Usage:

building plugin from source (Linux):
  1. install gcc-8, g, gcc-8-multilib, g8-multilib, cmake
  2. clone the sampml repository
  3. change directory to `examples/anti-aimbot/plugin`
  4. create and enter `build` directory
  5. generate build files using `cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g8`
  6. build plugin using `cmake --build . -- -j <number of threads>`
building plugin from source (Windows):
  1. clone the sampml repository
  2. open `examples/anti-aimbot/plugin` directory in Visual Studio 2017
  3. click on CMake->Build
installing:
  1. move the plugin binary to the `plugins` directory
  2. create a new directory `anti-aimbot` in the `plugins` directory
  3. create a new directory `models` in `plugins/anti-aimbot` directory
  4. copy three model files from `examples/anti-aimbot/training/models` to the models folder
  5. [optional] create config.cfg in the `anti-aimbot` directory
configuring the plugin:
thread_pool_size: number of threads that can be used for detectors (default: 4)
rf_model_file: random forest model file (default: plugins/anti-aimbot/models/rf_classifier.dat)
svm_model_file: svm model file (default: plugins/anti-aimbot/models/svm_classifier.dat)
dnn_model_file: dnn model file (default: plugins/anti-aimbot/models/dnn_classifier.dat)

Example `config.cfg`:
Code:
thread_pool_size 2
dnn_model_file plugins/anti-aimbot/models/dnn2_classifier.dat

submitting a shot vector:

Code:
stock CollectDataOPWS(data[E_SHOT_VECTOR], playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
native submit_vector(playerid, data[E_SHOT_VECTOR]);

Code:
#include <aimbot_dc.inc>
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
??????? new data[E_SHOT_VECTOR];
??????? CollectDataOPWS(data, playerid, weaponid, hittype, hitid, fX, fY, fZ);
?? ?submit_vector(playerid, data);
??? ?return 1;
}

obtaining results:

Code:
forward OnPlayerSuspectedForAimbot(playerid, Float:probabilities[3], time[3]);

Code:
#include <aimbot_dc.inc>
public OnPlayerSuspectedForAimbot(playerid, Float:probabilities[3], time[3])
{
??? /* results are sent after a few seconds; hence, check if the player is still connected */
??? if(!IsPlayerConnected(playerid))
??????? return 1;

??? static enum {
??????? COLOR_RED = 0xFF0000FF,
??????? COLOR_GREEN = 0x00FF00FF,
??? };

??? new str[144], name[MAX_PLAYER_NAME];
??? GetPlayerName(playerid, name, sizeof(name));

??? /*
??? ** there are three independent detectors
??? ** - random forest
??? ** - support vector machine
??? ** - deep neural network
??? **
??? ** `probabilities` contains the outputs of the detectors in the aforementioned order
??? ** `time` contains the CPU microseconds used by each of the detectors in the aforementioned order
??? **
??? ** the average of the probabilities can be used to get an overall estimate
??? ** choose a cutoff above which the result is considered to be an aimbot sample
??? ** the code below sends a message for all samples
??? */?? ?

??? const Float:cutoff = 0.6;
??? new Float:avg = (probabilities[0]  probabilities[1]  probabilities[2])/3;

??? format(str, sizeof(str), "%s(%d) >> RF: %.2f (%dus) SVM: %.2f (%dus), DNN: %.2f (%dus)",
?? ? ?? ??? ??? ??? ??? ??? ?name, playerid,
?? ? ?? ??? ??? ??? ??? ??? ?probabilities[0], time[0],
?? ? ?? ??? ??? ??? ??? ??? ?probabilities[1], time[1],
?? ? ??? ??? ??? ??? ??? ??? ?probabilities[2], time[2]);
?? ? ??? ??? ??? ??? ??? ??? ?
??? new color = ((avg > cutoff) ? COLOR_RED : COLOR_GREEN);
??? SendClientMessageToAll(color, str);
?? ?
??? format(str, sizeof(str), "Average: %.2f (%s)", avg, ((avg > cutoff) ? ("MOSTLY USING AIMBOT") : ("MAY NOT BE USING AIMBOT")));
??? SendClientMessageToAll(color, str);
}

Links:
GitHub Repository

Contributing & Support Requests
discord server for:
- research & development
- support requests
- contributing

Looking for people to test the plugin on real servers and provide feedback. Only three skin aimbots were used for training and hence the detectors might fail for specific cases which I expect to be reported. You can get the training summary on Travis or AppVeyor.

Credits:
Over dozen people were involved in testing an collecting data. I'd like to mention the top contributors:
  1. Helium
  2. Variable/H2O
  3. Luzziz


  Finnish
Posted by: yodawg - 2019-04-14, 11:15 AM - Forum: Other - Replies (5)

veli sano et t??l on suomalaisii