Post by wbyokomo on Jun 17, 2016 9:03:53 GMT
Here i will teach you how to set steamid for bot, mean you can use it in plugin to save stats, data using steamid.
Code:
Hope you learn from it. Good luck.
Code:
#include <amxmodx>
//#include <amxmisc>
#define PLUGIN "BOT Steamid"
#define VERSION "0.0.1"
#define AUTHOR "wbyokomo"
//////////////////////////////////////////
#define Binary 2
#define Ternary 3
#define Trinary 3
#define Quintal 5
#define Oct 8
#define Octal 8
#define Dec 10
#define Decimal 10
#define Duodecimal 12
#define Dozenal 12
#define Hex 16
#define Hexadecimal 16
new ___key[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define ___ctod(%0) ('0' <= %0 <= '9' ? %0 - '0' : 'A' <= %0 <= 'Z' ? %0 -'A' + 10 : 'a' <= %0 <= 'z' ? %0 -'a' + 10 : 0)
stock itoa(val, out[], len, radix = Decimal)
{
if ( ! val ) { out[0] = '0'; out[1] = 0; return; }
if ( ! ( 2 <= radix <= 36 ) ) { out[0] = '0'; out[1] = 0; return; }
for ( new i = len ; i ; i-- ) { out[i] = 0; }
for ( new i = len - 1 ; val && i > -1 ; --i, val /= radix )
out[len-i-1] = ___key[val % radix];
new len2 = strlen(out);
new temp;
for ( new i = 0 ; i < len2 / 2 ; i++ )
{
temp = out[i];
out[i] = out[len2-i-1];
out[len2-i-1] = temp;
}
}
stock atoi(string[], radix = Decimal)
{
if ( ! ( 2 <= radix <= 36 ) ) { return 0; }
new result, mult = 1;
for ( new i = strlen(string) - 1 ; i > - 1 ; i-- )
{
result += ___ctod(string[i]) * mult;
mult *= radix
}
return result;
}
//////////////////////////////////////////
new szSteamid[33][35]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
}
public client_putinserver(id)
{
new szName[32]
get_user_info(id, "name", szName, charsmax(szName))
if(is_user_bot(id))
{
new iNum, szNum[32]
replace_all(szName, charsmax(szName), " ", "n4D") //replace space with any chars, example: n4D
iNum = atoi(szName, Hex) //convert string to init, in this case i use Hex (16)
num_to_str(iNum, szNum, charsmax(szNum)) //convert back init to string
replace_all(szNum, charsmax(szNum), "-", "9") //replace -ve value with any numbers, example 9
formatex(szSteamid[id], charsmax(szSteamid[]), "STEAM_7:0:%s", szNum) //STEAM_7:0:12345678
//so anytime you want to use bot steamid, the value is stored in szSteamid[id]
//this useful when you want save stats, data using steamid.
}
else
{
//human player no need to set steamid, engine already set to them.
get_user_authid(id, szSteamid[id], charsmax(szSteamid[]))
}
client_print(id, print_chat, "*** %s :: %s has joined the server!", szName, szSteamid[id])
}
public client_disconnect(id)
{
new szName[32]
get_user_info(id, "name", szName, charsmax(szName))
client_print(id, print_chat, "*** %s :: %s has left the server!", szName, szSteamid[id])
}
Hope you learn from it. Good luck.