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

Best method to saving player data?


Post New Thread Reply   
 
Thread Tools Display Modes
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 08-07-2013 , 03:32   Re: Best method to saving player data?
Reply With Quote #11

Quote:
Originally Posted by ShufflexDD View Post
if u need to ban them in the same round, use bool arrays(or datapacks), if no, so use sql database.
No, I need the ability to ban them regardless if they disconnect or not with a timer. The idea is that, they get flagged and a bool is set to true for their ID, a timer is called which bans them at the end of the timer or if they disconnect.

- Jack
Drixevel is offline
Doodil
Senior Member
Join Date: Mar 2012
Old 08-07-2013 , 04:28   Re: Best method to saving player data?
Reply With Quote #12

Then create 2 global arrays (you can also do it with just one, but no need to be greedy here), one is an MAXPLAYER-sized array of bools, indicating if a player should be banned when he disconnects right now, the other is an MAXPLAYER-sized array of timers, holding the timer (if one exists) for each client.

The ban command sets the clients bool to True and starts a timer with the client-id as a parameter. The timer is saved to the timer-array. OnDisconnect you check if the clients bool is set to true, if so ban him, delete the timer and set the bool to false again. At the end of the timer, ban the client and set the bool to false.

I'm not sure if it's still possible to get the steam-id in OnPlayerDisconnect(), if not you might have to create a third array saving the steam-id and fill it with data once you want to ban a client.
Doodil is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 08-07-2013 , 05:00   Re: Best method to saving player data?
Reply With Quote #13

Quote:
Originally Posted by Doodil View Post
Then create 2 global arrays (you can also do it with just one, but no need to be greedy here), one is an MAXPLAYER-sized array of bools, indicating if a player should be banned when he disconnects right now, the other is an MAXPLAYER-sized array of timers, holding the timer (if one exists) for each client.

The ban command sets the clients bool to True and starts a timer with the client-id as a parameter. The timer is saved to the timer-array. OnDisconnect you check if the clients bool is set to true, if so ban him, delete the timer and set the bool to false again. At the end of the timer, ban the client and set the bool to false.

I'm not sure if it's still possible to get the steam-id in OnPlayerDisconnect(), if not you might have to create a third array saving the steam-id and fill it with data once you want to ban a client.
You are a brilliant man, thank you for the tips!

- Jack
Drixevel is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-07-2013 , 06:42   Re: Best method to saving player data?
Reply With Quote #14

That's over complicating things. This will ensure the client is banned, either by client or steam. The whole g_hArray_Pending was a random idea to track pending bans, but I'm not sure if the method works.

PHP Code:
//Outside Scope
new Handle:g_hArray_Pending INVALID_HANDLE;
new 
Float:g_fBanDuration 60.0;
new 
g_iBanDuration 60;

//OnPluginStart
g_hArray_Pending CreateArray();

//Within Desired Code
decl String:sAuth[24];
if(!
GetClientAuthString(targetsAuthsizeof(sAuth[]))
{
    
ReplyToCommand(client"Client failed to auth, delayed ban not possible.");
    return;
}
else
{
    new 
Handle:hPack;
    new 
Handle:hTimer CreateDataTimer(g_fBanDurationTimer_BanClienthPack);
    
WritePackCell(hPacktarget);
    
WritePackCell(hPackGetClientUserId(target));
    
WritePackString(hPacksAuth);
    
PushArrayCell(hPackhTimer);
}

//Callback
public Action:Timer_BanClient(Handle:timerHandle:pack)
{
    
//I doubt this works; it's 5:40 am and it sounds great.
    // If it doesn't, oh well, g_hArray_Pending isn't necessary.
    
new iPosition;
    if((
iPosition FindValueInArray(g_hArray_Pendingtimer) != -1))
        
RemoveFromArray(g_hArray_PendingiPosition);

    
ResetPack(pack);
    new 
client ReadPackCell(hPack);
    new 
userid ReadPackCell(hPack);
    new 
String:sAuth[24];
    
ReadPackString(hPacksAuthsizeof(sAuth));
    
    if(!
GetClientOfUserId(userid))
        
BanIdentity(sAuthg_iBanDurationBANFLAG_AUTHID"Delayed Ban");
    else
        
BanClient(clientg_iBanDurationBANFLAG_AUTHID"Delayed Ban""Delayed Ban");

__________________

Last edited by thetwistedpanda; 08-07-2013 at 06:44.
thetwistedpanda is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 08-07-2013 , 09:34   Re: Best method to saving player data?
Reply With Quote #15

Quote:
Originally Posted by thetwistedpanda View Post
That's over complicating things. This will ensure the client is banned, either by client or steam. The whole g_hArray_Pending was a random idea to track pending bans, but I'm not sure if the method works.

PHP Code:
//Outside Scope
new Handle:g_hArray_Pending INVALID_HANDLE;
new 
Float:g_fBanDuration 60.0;
new 
g_iBanDuration 60;

//OnPluginStart
g_hArray_Pending CreateArray();

//Within Desired Code
decl String:sAuth[24];
if(!
GetClientAuthString(targetsAuthsizeof(sAuth[]))
{
    
ReplyToCommand(client"Client failed to auth, delayed ban not possible.");
    return;
}
else
{
    new 
Handle:hPack;
    new 
Handle:hTimer CreateDataTimer(g_fBanDurationTimer_BanClienthPack);
    
WritePackCell(hPacktarget);
    
WritePackCell(hPackGetClientUserId(target));
    
WritePackString(hPacksAuth);
    
PushArrayCell(hPackhTimer);
}

//Callback
public Action:Timer_BanClient(Handle:timerHandle:pack)
{
    
//I doubt this works; it's 5:40 am and it sounds great.
    // If it doesn't, oh well, g_hArray_Pending isn't necessary.
    
new iPosition;
    if((
iPosition FindValueInArray(g_hArray_Pendingtimer) != -1))
        
RemoveFromArray(g_hArray_PendingiPosition);

    
ResetPack(pack);
    new 
client ReadPackCell(hPack);
    new 
userid ReadPackCell(hPack);
    new 
String:sAuth[24];
    
ReadPackString(hPacksAuthsizeof(sAuth));
    
    if(!
GetClientOfUserId(userid))
        
BanIdentity(sAuthg_iBanDurationBANFLAG_AUTHID"Delayed Ban");
    else
        
BanClient(clientg_iBanDurationBANFLAG_AUTHID"Delayed Ban""Delayed Ban");

That's exactly what I needed, thanks.

- Jack
Drixevel is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 08-08-2013 , 03:03   Re: Best method to saving player data?
Reply With Quote #16

A timer isn't always going to work, should your server(s) encounter issues after a ban is initiated and awaiting the timer to complete, the ban in question will be lost.
I would create a pre-ban list with a time stamp that would be checked OnMapStart to determine who hasn't been banned yet.
The list would also be referred to in order to ban those who've left the server.

Being that the timer data will only be available so long as it's in ram makes it susceptible to data loss (In the event of a server crash or other similar issues)

Last edited by TheGodKing; 08-08-2013 at 03:05.
TheGodKing is offline
Reply



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 11:10.


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