View Single Post
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen.
Old 09-03-2017 , 09:01   [ANY] ASteambot - Create your own modules !
Reply With Quote #1

ASteambot - Developper


Introduction

So... About a year ago, I made a steambot wich turned out to not be that usefull nor well made. I reprogrammed it, from scratch and ASteambot was "born". It's still an ugly undevelopped fetus, but it somehow work already [CLICK] .

But the interesting part about it is that I want to create a simple interface so anybody with basic knowledge about sourcepawn will be able to do his own plugins using ASteambot.

I have already mode two plugins using the interface and it works pretty well, I must say.
ASteambot Donation
ASteambot Chat

The point of this thread is to explain how my interface work and also to get returns from you, about what stops you from doing plugins with the interface, what could be improved or if I should keep it alive or not.

How does it work ?

Well, ASteambot have a TCP endpoint, where you can send some queries through it.
Wich means, Socket extension [CLICK] is required.

Enough speech, more actions

First of all, you will need the include file, you can grab it on Github [CLICK].
Let's take a look at it.

ASteambot.inc (06.06.2019)
PHP Code:
/*
*
*    Contains things for ASteambot plugin developpement
*
*/
#if defined _INCLUDE_ASteambot
 #endinput
#endif
#define _INCLUDE_ASteambot


enum AS_MessageType
{
    
AS_REGISTER_SERVER 0,
    
AS_HOOK_CHAT,
    
AS_UNHOOK_CHAT,
    
AS_SIMPLE,
    
AS_TRADEOFFER_SUCCESS,
    
AS_TRADEOFFER_DECLINED,
    
AS_SCAN_INVENTORY,
    
AS_CREATE_TRADEOFFER,
    
AS_NOT_FRIENDS,
    
AS_TRADE_TOKEN,
    
AS_FRIEND_INVITE,
    
AS_REPORT_PLAYER,
    
AS_INVITE_GROUP,
    
AS_SCAN_INVENTORY_IMG,
    
AS_EXECUTE_CMD,
    
AS_DISCONNECT,
    
AS_SG_ANNOUCEMENT
};

/** 
 * Find client by steamID64
 * 
 * @return          A client id.
 */ 
native int ASteambot_FindClientBySteam64(const char[] steamid64)

/** 
 * Register the plugin, required to receive and send messages.
 * 
 * @return          Nothing.
 */ 
native void ASteambot_RegisterModule(const char[] moduleName)

/** 
 * Remove the module from ASteambot_Core, the plugin won't be able to receive and send messages anymore.
 * 
 * @return          Nothing.
 */ 
native void ASteambot_RemoveModule()

/** 
 * Get the connection state to ASteambot
 * 
 * @return          true if connected and can receive/send messages, false otherwise. 
 */ 
native bool ASteambot_IsConnected() 

/** 
 * Send a message to ASteambot (Maximum char 900). 
 * 
 * @return          Nothing.
 */ 
native void ASteambot_SendMesssage(AS_MessageType MessageType, const char[] message

/** 
 * Send a message to ASteambot (Maximum char 900). 
 * 
 * @return          Nothing.
 */ 
native void ASteambot_CreateTradeOffer(int clientHandle ArrayAssetIDHandle ArrayMyAssetID nullfloat fakeValue = -1.0

/** 
 * Fire when ever you get a message from ASteambot.
 * 
 * @return          Nothing.
 */ 
forward int ASteambot_Message(AS_MessageType MessageTypechar[] message, const int messageSize);

/**
Shared plugin information
**/
public SharedPlugin _pl_ASteambot 
{
    
name "[ANY] ASteambot Core",
    
file "ASteambot_Core.smx",
#if defined REQUIRE_PLUGIN
    
required 1
#else
    
required 0
#endif
}; 
AS_REGISTER_SERVER
This one should NEVER be usued by you. It's ASteambot_Core who use it and he should be the only one.
When ASteambot receive this type of message it will give the server an ID. It's like :
Server : "Hey, ASteambot, I want to connect to ya"
ASteambot : "Wait mate, I'll give you a number so I don't forget who you are, OK ?"
Server : "Okay, yeah."

AS_HOOK_CHAT
This message type means that you want to send everything that his written in the game server chat to the steambot.
If you receive this message, a friend of ASteambot have written "HOOKCHAT" in steamchat.
If you send a message with this message type, ASteambot will try to forward this message to all steam friends who are hooking this server chat.

AS_UNHOOK_CHAT
If you receive this message, a friend of ASteambot have written "STOPHOOK" in steamchat.
If you send a message with this message type, ASteambot will do nothing.

AS_SIMPLE
If you receive this message, ASteambot is trying to send you a message composed like this :
Arkarr : this is a test text

If you send a message with this message type, ASteambot will try to send a message through steam to the specified steamID.
Message you send must me composed like this :
ASteambot_SendMesssage(AS_SIMPLE, "STEAM_0:1:42047781/Hello world!");

AS_TRADEOFFER_SUCCESS
If you receive this message, ASteambot is trying to send you a message composed like this :
STEAM_0:1:42047781/523523634/45.10
This message can be subdivised in 3 parts.
STEAM_0:1:42047781 is the first part and the steam ID of the player who completed a trade offer.
523523634 is the trade ID.
45.10 is how much $ the trade was worth. In this exemple, I traded for 45.10$ worth of steam items.
It means a trade have successfully ended.
If you send a message with this message type, ASteambot will do nothing.

AS_TRADEOFFER_DECLINED
If you receive this message, ASteambot is trying to send you a message composed like this :
STEAM_0:1:42047781/523523634/45.10
This message can be subdivised in 3 parts.
STEAM_0:1:42047781 is the first part and the steam ID of the player who completed a trade offer.
523523634 is the trade ID.
45.10 is how much $ the trade was worth. In this exemple, I traded for 45.10$ worth of steam items.
It means a trade have been declined ended.
If you send a message with this message type, ASteambot will do nothing.

AS_SCAN_INVENTORY
If you receive this message, ASteambot is trying to send you a message composed like this :
STEAM_0:1:42047781/[TF2 items]/[CSGO items]/[DOTA 2 items]

Obviously, the first part is the steamID of the player's inventory.
[TF2 items], [CSGO items] and [DOTA 2 items] contains all the inventory that have a value in steam market higher than 0.00.
It's compossed like this :
item_id=item_name=item_value,item2_id=item2_n ame=item2_value,...

If you send a message with this message type, ASteambot will return AS_SCAN_INVENTORY as message type and will return the inventory as well, as explained just above.
Message you send must me composed like this :
ASteambot_SendMesssage(AS_SCAN_INVENTORY, "STEAM_0:1:42047781");

AS_CREATE_TRADEOFFER
You don't use it, because the message is a pain in the @S* to explain. Instend, you use the approriate function for that, check below.
You will receive this kind of message once a trade offer has been created. It return the trade offer id.

AS_NOT_FRIENDS
If you receive this message, it means that you tried to do something that require ASteambot and the player to be friend. For exemple, you need to be friend to send a trade offer (or use a token, but it's not implemented yet in ASteambot TCP interface).
The message is composed like this :
STEAM_0:1:42047781
It just contain the steamID of the one who tried to do something that is not allowed.
If you send that message to ASteambot, nothing happens.

AS_TRADE_TOKEN
Does nothing when you send, you will never receive it.

AS_FRIEND_INVITE
You will never receive this message type.
Ask ASteambot to add the following steamID to his friends through steam request.
Usage :
ASteambot_SendMesssage(AS_FRIEND_INVITE, "STEAM_0:1:42047781");

AS_INVITE_GROUP
Ask ASteambot to add the following steamID to the steam group.
Usage :
ASteambot_SendMesssage(AS_INVITE_GROUP, "STEAM_0:1:42047781/GROUP_ID");
GROUP_ID can be found here : http://steamcommunity.com/groups/YOU...listxml/?xml=1
it's the number in <groupID64>'s tag, for exemple :
http://steamcommunity.com/groups/ark...listxml/?xml=1 group's id is 103582791460339322
Keep in mind that the ASteambot need the right to invite people in the group...
If you receive this message, it means that someone have been invited to the steam group.
The message is composed like this :
STEAM_0:1:42047781

ASteambot_RegisterModule()
PHP Code:
/** 
 * Register the plugin, required to receive and send messages.
 * 
 * @return          Nothing.
 */ 
native bool ASteambot_RegisterModule(const char[] moduleName
It is required to register your module to ASteambot_Core in order to be able to receive and send message to ASteambot.

ASteambot_RemoveModule()
PHP Code:
/** 
 * Remove the module from ASteambot_Core, the plugin won't be able to receive and send messages anymore.
 * 
 * @return          Nothing.
 */ 
native void ASteambot_RemoveModule() 
Remove the module from the registery of ASteambot_Core. Do that in OnPluginEnd().

ASteambot_IsConnected()
PHP Code:
/** 
 * Get the connection state to ASteambot
 * 
 * @return          true if connected and can receive/send messages, false otherwise. 
 */ 
native bool ASteambot_IsConnected() 
This function is pretty explicit, it return true if the server is connected to ASteambot or not.

ASteambot_SendMesssage(int MessageType, const char[] message)
PHP Code:
/**  
 * Send a message to ASteambot (Maximum char 900).  
 *  
 * @return          Nothing. 
 */  
native void ASteambot_SendMesssage(int MessageType, const char[] message
This function allow you to send a message to ASteambot. That's it. Nothing more.
You should ALWAYS (do as I say, not as I do ) check if the server is connected to ASteambot before trying to send him anything.

ASteambot_CreateTradeOffer(int client, int gameID, Handle ArrayAssetID)
PHP Code:
/**  
 * Create a trade offer with ASteambot and the given client.  
 *  
 * @return          Nothing. 
 */  
native void ASteambot_CreateTradeOffer(int clientint gameIDHandle ArrayAssetID
gameID has to be valid.
TF2 = 440
CSGO = 730
DOTA2 = 570

ArrayAssetID is a arry wich contains valid assetID, assetID can be retrieved from ASteambot using the message type AS_SCAN_INVENTORY.

PHP Code:
/**  
 * Fire when ever you get a message from ASteambot. 
 *  
 * @return          Nothing. 
 */  
forward int ASteambot_Message(int MessageTypechar[] message, const int messageSize); 
Well, when you can get Message from ASteambot, it fire. I don't know what else to say.






Alright, that was boring. If you have any other questions, or want to request anything else, just do it !
__________________
Want to check my plugins ?

Last edited by Arkarr; 06-06-2019 at 03:20.
Arkarr is offline