Raised This Month: $12 Target: $400
 3% 

[ANY] ASteambot - Create your own modules !


Post New Thread Reply   
 
Thread Tools Display Modes
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 !
__________________

Last edited by Arkarr; 06-06-2019 at 03:20.
Arkarr is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 05-30-2018 , 09:40   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #2

I made several updates since I wrote that post.
I need to do updates but firstly, I want to know if it has helped someone or not at all.
If not, then I won't continue updating this post.
Just send me a PM or leave a reply here.
__________________
Arkarr is offline
extremeg
Senior Member
Join Date: Dec 2012
Old 05-31-2018 , 12:23   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #3

yeah this post was for me very helpfull then you documented it well
extremeg is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 05-31-2018 , 13:15   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #4

Quote:
Originally Posted by extremeg View Post
yeah this post was for me very helpfull then you documented it well
Okay, I will update it then.
__________________
Arkarr is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 02-01-2022 , 22:02   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #5

I managed to setup the bot and all but I when I want to send a message, it simply doesn't work

AS_NOT_FRIENDS is not triggered and no message it sent.
ASteambot_Message isn't even called

The debug option from the core plugin shows the TCP password and the message but nothing happens

the bot claims to be connected

is Arkarr's API key needed? the main thread claims not, and the website isn't available
__________________
GitHub | Discord: @azalty | Steam
azalty is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 02-02-2022 , 17:02   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #6

Found a solution for my problem
First of all, my "hostip" cvar wasn't set to anything, so I rewrote a part of ASteambot_Core to add a cvar to manually write the IP of my server

Then, the password I chose was 30 characters, and the max amount of characters we can enter is 24 (string size 25). For some reason, the TCP password on the website has no limits so it didn't work
__________________
GitHub | Discord: @azalty | Steam
azalty is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 02-07-2022 , 10:03   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #7

Quote:
Originally Posted by azalty View Post
Found a solution for my problem
First of all, my "hostip" cvar wasn't set to anything, so I rewrote a part of ASteambot_Core to add a cvar to manually write the IP of my server

Then, the password I chose was 30 characters, and the max amount of characters we can enter is 24 (string size 25). For some reason, the TCP password on the website has no limits so it didn't work
It's weird that ASteambot said that it was connected, even more weirder that "hostip" wasn't set. Isn't that CVAR mandatory ?

Also, I'd like to add you on Steam in order to discuss about those things, as I plan to actively continue ASteambot and release a somewhat developper-friendly version, with more debug features and more logging.

Also, fix huge mess inside ASteambot (+ ASteambot Core AM Plugin), WebSocket communication (instead of simple TCP socket) and much more connectivity feature.

Also get ride of MarketScan dependencies, as people don't seem to understand why they require an API key for my server.
__________________
Arkarr is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 02-08-2022 , 06:34   Re: [ANY] ASteambot - Create your own modules !
Reply With Quote #8

Quote:
Originally Posted by Arkarr View Post
It's weird that ASteambot said that it was connected, even more weirder that "hostip" wasn't set. Isn't that CVAR mandatory ?
Doesn't seem like it is. I mean, my server always worked with that configuration, so :shrug:
I'm using the +ip parameter, maybe it does the same job as the "hostip" convar?

Quote:
Originally Posted by Arkarr View Post
Also, I'd like to add you on Steam in order to discuss about those things, as I plan to actively continue ASteambot and release a somewhat developper-friendly version, with more debug features and more logging.
https://steamcommunity.com/id/azalty/
Discord: azalty#9721
__________________
GitHub | Discord: @azalty | Steam
azalty is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:57.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode