Hi 
I try lot of ways to share object attached to a client. The goal its to take one time the steamidID64, WebID, Language, IP, etc.. after a OnClientPostAdminCheck
#First
Here I got for all players 1 to 64 the same steamid64 (mine)
player.inc
PHP Code:
methodmap Player < Dynamic
{
public Player(){
Dynamic myclass = Dynamic(64, 0);
myclass.SetString("SteamID64", "", 64);
return view_as<MyClass>(myclass);
}
}
drapi_users.sp
PHP Code:
Player player[MAXPLAYERS + 1];
public void OnClientPostAdminCheck(int client){
Player player[client] = Player();
char sSetName[32];
Format(sSetName, sizeof(sSetName), "drapi_users_%d", client);
player[player].SetName(sSetName);
//MY FUNCTION TO TAKE ALL DATA
}
drapi_users_bans.sp
I tried two syntax.
1 - Player player[i]= view_as<Player>(Dynamic.FindByName(sGetName));
2 - Dynamic player[i] = Dynamic.FindByName(sGetName);
PHP Code:
//when I Type test in console
public Action TimerCheckBans(Handle timer){
for(int i = 1 ; i <= MaxClients; i++){
Player player[MAXPLAYERS + 1];
char sGetName[32];
Format(sGetName, sizeof(sGetName), "drapi_users_%d", i);
Dynamic player[i] = Dynamic.FindByName(sGetName);
if (!player[i].IsValid){
}else{
char steamid[64];
player[i].GetSteamID64(steamid, sizeof(steamid));
PrintToServer("%s client %d GetSteamID64 %s", TAG, i, steamid);
}
}
}
#Second
Here I got the default value for all
player.inc
[/php]
#if defined _dynamic_class_player_
#endinput
#endif
#define _dynamic_class_player_
Dynamic myclass[MAXPLAYERS + 1];
methodmap Player < Dynamic
{
public Player(int client){
return view_as<Player>(myclass[client]);
}
public void init(int client){
//PrintToServer("%d init %d", client, myclass[client].IsValid);
myclass[client] = Dynamic(64, 0);
char sSetName[32];
Format(sSetName, sizeof(sSetName), "drapi_users_%d", client);
myclass[client].SetName(sSetName);
PrintToServer("%s SetName %d %s", TAG, client, sSetName);
//PrintToServer("%d init %d", client, myclass[client].IsValid);
}
public void clear(int client){
myclass[client].SetBool("isBan", false);
myclass[client].SetString("WebID", "none", 64);
myclass[client].SetString("SteamID64", "none", 64);
myclass[client].SetString("lastConnect", "", 64);
//PrintToServer("%d clear", client);
}
public void dispose(int client){
myclass[client].Dispose();
myclass[client] = INVALID_DYNAMIC_OBJECT;
//PrintToServer("%d Dispose", client);
}
}
[/php]
drapi_users.sp
PHP Code:
public void OnPluginStart() {
RegConsoleCmd("test", checkResponse, "");
for(int i = 1 ; i <= MaxClients; i++){
Player player = Player(i);
player.init(i);
player.clear(i);
}
}
public void OnPluginEnd() {
for(int i = 1 ; i <= MaxClients; i++){
//PrintToServer("%s OnPluginEnd %d %d", TAG, i, MaxClients);
Player player = Player(i);
player.dispose(i);
}
}
public Action checkResponse(int client, int args){
for(int i = 1 ; i <= MaxClients; i++){
Player player = Player(i);
if (!player.IsValid){
//PrintToServer("%s IsValid client %d", TAG, i);
}else{
char sSteamID64[32];
player.GetSteamID64(sSteamID64, sizeof(sSteamID64));
PrintToServer("%s client %d GetSteamID64 %s", TAG, i, sSteamID64);
char sWebID[32];
player.GetWebID(sWebID, sizeof(sWebID));
PrintToServer("%s client %d GetWebID %s", TAG, i, sWebID);
}
}
return Plugin_Handled;
}
public void OnClientPostAdminCheck(int client){
Player player = Player(client);
player.clear(client);
if(IsFakeClient(client)){
char webid[64];
Format(webid, sizeof(webid), "bot_%d", client);
player.SetWebID(webid);
char steamid[64];
Format(steamid, sizeof(steamid), "bot_%d", client);
player.SetSteamID64(steamid);
//PrintToServer("%s IsFakeClient %d SetWebID %s", TAG, client, webid);
}
if(!IsFakeClient(client)){
CreateTimer(5.0, Timer_PrepareRequest, client, TIMER_FLAG_NO_MAPCHANGE);
}
}
public void OnClientDisconnect(int client){
Player player = Player(client);
player.clear(client);
}
public Action Timer_PrepareRequest(Handle timer, int client){
if(!IsFakeClient(client)){
httpClient(client).Get("*****", OnReceived, client);
}
}
drapi_users_bans.sp
PHP Code:
bool drapi_users = false;
public Plugin myinfo ={
name = "drapi_users_bans",
author = "Dr. Api",
description = "",
version = PLUGIN_VERSION,
url = "https://csgo.devsapps.com"
}
public void OnMapStart(){
if(drapi_users){
CreateTimer(10.0, TimerCheckBans, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
}
public Action TimerCheckBans(Handle timer){
for(int i = 1 ; i <= MaxClients; i++){
char sGetName[32];
Format(sGetName, sizeof(sGetName), "drapi_users_%d", i);
Dynamic player = Dynamic.FindByName(sGetName);
//Player player = view_as<Player>(Dynamic.FindByName(sGetName));
PrintToServer("%s sGetName %d %s", TAG, i, sGetName);
if (!player.IsValid){
//PrintToServer("%s IsValid client %d", TAG, i);
}else{
//PrintToServer("%s client %d", TAG, i);
char steamid[64];
player.GetString("SteamID64", steamid, sizeof(steamid));
PrintToServer("%s client %d GetSteamID64 %s", TAG, i, steamid);
}
}
}
when I type test (drapi_users)
[USERS] - client 1 GetSteamID64 76561197969245555
[USERS] - client 1 GetWebID 1
[USERS] - client 2 GetSteamID64 bot_2
[USERS] - client 2 GetWebID bot_2
[USERS] - client 3 GetSteamID64 bot_3
[USERS] - client 3 GetWebID bot_3
[USERS] - client 4 GetSteamID64 bot_4
[USERS] - client 4 GetWebID bot_4
[USERS] - client 5 GetSteamID64 bot_5
[USERS] - client 5 GetWebID bot_5
[USERS] - client 6 GetSteamID64 bot_6
[USERS] - client 6 GetWebID bot_6
[USERS] - client 7 GetSteamID64 bot_7
[USERS] - client 7 GetWebID bot_7
[USERS] - client 8 GetSteamID64 bot_8
[USERS] - client 8 GetWebID bot_8
[USERS] - client 9 GetSteamID64 bot_9
[USERS] - client 9 GetWebID bot_9
[USERS] - client 10 GetSteamID64 bot_10
[USERS] - client 10 GetWebID bot_10
when the TimerCheckBans from drapi_users_bans
[BANS] - sGetName 1 drapi_users_1
[BANS] - client 1 GetSteamID64 none
[BANS] - sGetName 2 drapi_users_2
[BANS] - client 2 GetSteamID64 none
[BANS] - sGetName 3 drapi_users_3
[BANS] - client 3 GetSteamID64 none
[BANS] - sGetName 4 drapi_users_4
[BANS] - client 4 GetSteamID64 none
[BANS] - sGetName 5 drapi_users_5
[BANS] - client 5 GetSteamID64 none
[BANS] - sGetName 6 drapi_users_6
[BANS] - client 6 GetSteamID64 none
[BANS] - sGetName 7 drapi_users_7
[BANS] - client 7 GetSteamID64 none
[BANS] - sGetName 8 drapi_users_8
[BANS] - client 8 GetSteamID64 none
[BANS] - sGetName 9 drapi_users_9
[BANS] - client 9 GetSteamID64 none
[BANS] - sGetName 10 drapi_users_10
I tried others ways but still not working.
I don't want to create native to share data between plugin since dynamic is awesome.
How you would do a methodmap attache to a client and share between plugins?
Thx for your help