AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fvault code (https://forums.alliedmods.net/showthread.php?t=213549)

ironskillz1 04-16-2013 06:26

Fvault code
 
What does this code do.
And when can you use it?

i didnt found anything about it

Code:

// Pruning player agree/decline after 15 days of not being updated

// 15 days * 24 hours * 60 minutes * 60 seconds = 15 days in seconds
new end_prune_time = get_systime() - (15 * 24 * 60 * 60);

fvault_prune("player_agree", _, end_prune_time);


hornet 04-16-2013 07:15

Re: Fvault code
 
It checks the time stamp of all player_agree entries, and removes them after 15 days. You can use it whenever you want, buy it'll only have the effect if this plugin has been running for more than 15 days.
It could be used in the case that you want players to regularly read and accept the rules, shall they be updated. Or, perhaps if you change the time stamp by touching the entry it could be used to make players read and accept if they haven't p[layed in 15 days. Im not 100% sure since I've never actually used FVault.

ironskillz1 04-16-2013 09:08

Re: Fvault code
 
Quote:

Originally Posted by hornet (Post 1933546)
It checks the time stamp of all player_agree entries, and removes them after 15 days. You can use it whenever you want, buy it'll only have the effect if this plugin has been running for more than 15 days.
It could be used in the case that you want players to regularly read and accept the rules, shall they be updated. Or, perhaps if you change the time stamp by touching the entry it could be used to make players read and accept if they haven't p[layed in 15 days. Im not 100% sure since I've never actually used FVault.


Okay but what is the best way to do it?

in Vault
or nVault
or fVault
or SQL?

hornet 04-16-2013 09:17

Re: Fvault code
 
You never said what your doing.

ironskillz1 04-16-2013 09:40

Re: Fvault code
 
Quote:

Originally Posted by hornet (Post 1933602)
You never said what your doing.

Okay so i need this
When a user joins the server and write /hello a command are executed
and then he needs to wait 24 hours before he can write can write /hello again

Podarok 04-16-2013 10:21

Re: Fvault code
 
I suggest you using mysql.

ironskillz1 04-16-2013 10:28

Re: Fvault code
 
I Solved it

i did it with fVault becuse that was easier :)

Edit: here is the code if anyone needs it
Code:

/*
CODE FROM JUMPSTATS BY EXOLENT EDIT IRONSKILLZ1(SNUSMUMRIKEN)
*/
#include <amxmodx>
#include <fvault>
new cvar_save_prune;
new const g_agree_vault[] = "hello";
new bool:g_agreed[33];
public plugin_init()
{
 
 cvar_save_prune = register_cvar("js_save_prune", "1");  // 1 day
 register_clcmd( "say /hello", "Hello" );
 
 Check()
 
}
public Hello(client)
{
 static authid[35];
 get_user_authid(client, authid, sizeof(authid) - 1);
 
 g_agreed[client] = true;
 
 fvault_set_data(g_agree_vault, authid, "1");
}

public client_authorized(client)
{
 if( !is_user_bot(client) )
 {
  static authid[35];
  get_user_authid(client, authid, sizeof(authid) - 1);
 
  if( fvault_get_keynum(g_agree_vault, authid) == -1 )
  {
  g_agreed[client] = false;
  }
  else
  {
  g_agreed[client] = true;
 
  }
 }
}
public Check()
{
 static bool:bAlreadyExecuted;
 if( !bAlreadyExecuted )
 {
  new iDays = get_pcvar_num( cvar_save_prune );
  if( iDays )
  {
  fvault_prune( g_agree_vault, _, get_systime( ) - ( iDays * 60 * 60 ) );
  }
 
  bAlreadyExecuted = true;
 }
}


guipatinador 04-16-2013 17:23

Re: Fvault code
 
plugin_init is called once a map. You don't need this bool -> bAlreadyExecuted

You can use fvault_get_data instead of fvault_get_keynum

This,

PHP Code:

fvault_pruneg_agree_vault_get_systime( ) - ( iDays 60 60 ) ); 

Should be,

PHP Code:

fvault_pruneg_agree_vault_get_systime( ) - ( iDays 24 60 60 ) ); 



All times are GMT -4. The time now is 10:51.

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