It is currently 21 Nov 2018 23:05






Reply to topic  [ 10 posts ] 
 [TUT & INC] Nvault Easy 
Author Message
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
NVE ( Nvault Easy )

Descriere
Salut, tocmai ce m-am apucat de un proiect, un fisier .inc care te ajuta sa salvezi datele mult mai usor, te scuteste de anumite verificari .. e facut 100% pentru incepatori, daca stii cum functioneaza nvault ar trebui sa-l folosesti direct, dar daca te complici cu el ar trebui sa folosesti acest include, daca vrea cineva sa colaboreze si sa-l dezvoltam impreuna , thank!

Sursa codului:
SMA | Afiseaza codul
#if defined _nve_included
#endinput
#endif
#define _nve_included


#include <amxmodx>
#include <nvault>

new gVault;
new gVaultName[] = "NvaultEasy";



const NVE_VERSION = 1.2;




/**
* Open the NvaultEasy.vault file
* @noreturn
*/
stock nve_open( )
{
gVault = nvault_open( gVaultName );

if( gVault == INVALID_HANDLE )
set_fail_state( " Problems with Nvault Easy include ... " );
}

/**
* Close the NvaultEasy.vault file.
* @noreturn
*/
stock nve_close( ) nvault_close( gVault );

/**
* @return: The vault id wich handle the vault file ( You may want for using normal nvault natives, maybe for the same file ).
*/
stock nve_vault_id( ) return gVault;


/**
* Save an integer to an index, you need to use a symbol to make it unique.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param Number The number to save ( the integer ) .
* @noreturn
*/
stock nve_set_int( id, szSymb[], Number )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

new szData[11];
num_to_str( Number, szData, charsmax( szData ) );

nvault_set( gVault, buffer, szData );
}



/**
* Get an integer from an index
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @return: The Number
*/
stock nve_get_int( id, szSymb[] )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

return nvault_get( gVault, buffer );
}

/**
* Update an integer from an index ( same as nve_get_int() you use this when your user is changing his name to retrieve the actual integer for his actual name. )
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @return: The Number
*/
stock nve_update_int( id, szSymb[] )
{
new buffer[64];
new szName[32];
get_user_info( id, "name", szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

return nvault_get( gVault, buffer );
}


/**
* Save an string to an index, you need to use a symbol to make it unique.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string to save ( "this is a string" )
* @noreturn
*/
stock nve_set_string( id, szSymb[], String[] )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

nvault_set( gVault, buffer, String );
}



/**
* Get an string from an index
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string variable to insert the saved string ( "this is a string" )
* @param lengh The lengh of the String variable ( Note: user charsmax() )
* @noreturn
*/
stock nve_get_string( id, szSymb[], String[] , lengh=64 )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

nvault_get( gVault, buffer, String, lengh );
}

/**
* Update an string from an index ( Same as nve_get_string, you use this when your user is changing his name to retrieve the actual string for his actual name.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string variable to insert the saved string ( "this is a string" )
* @param lengh The lengh of the String variable ( Note: user charsmax() )
* @noreturn
*/
stock nve_update_string( id, szSymb[], String[] , lengh=64 )
{
new buffer[64];
new szName[32];
get_user_info( id, "name", szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

nvault_get( gVault, buffer, String, lengh );
}




/**
* Reset a vault, so it deletes all the entries ( #RO: Sterge toate salvarile, goloseste vault-ul. )
* @noreturn
*/
stock nve_reset( )
{
nvault_prune( gVault, 0, get_systime( ) );
}



Explicatii

Cum observati codul nu e prea mare si inca nu prea contine multe native dar asa cum am zis e la inceput.

O sa va explic ce face fiecare in parte, nu uitati e un mod mult mai usor de a salve Numerele ( integers ) pentru incepatori.

Prima data includeti libraria:
Code:
#include <nve>


In plugin init si in plugin_end va trebuie sa aveti mereu asa:
Code:
public plugin_init( )
{
        nve_open();
}

public plugin_end( )
{
        nve_close();
}


Lista Stock-uri/Functii
Lista | Afiseaza codul
nve_open() - deschide Nve Vault.
nve_close() - inchide Nve Vault.

nve_vault_id() - returneaza vault Id. ( #In caz ca vreti sa folositi si celelalte native ale nvault-ului. )
nve_reset() - Reseteaza NVE ( il goleste ).

nve_set_int( id, szSymb[], Number ) - Salveaza un numar id-ului.
nve_get_int( id, szSymb[] ) - Returneaza numarul salvat id-ului.
nve_update_int( id, szSymb[] ) - Returneaza numar salvat al id-ului cu noul nume.

nve_set_string( id, szSymb[], String[] ) - Salveaza un string id-ului.
nve_get_string( id, szSymb[], String[], lengh ) - Insereaza string-ul salvat al id-ului in variabila data.
nve_update_string( id, szSymb[], String[], lengh[] - Insereaza string-ul salvat al id-ului cu noul nume in variabila data.



Exemplu salvare numar:

SMA | Afiseaza codul
#include <amxmodX>
#include <cstrike>
#include <nve>

// Creiem un MACROSS cu "Test" , as prefera ca sa creati o variabila constanta, dar daca asa e mai usor pentru voi ...
#define SYMBOL "Test"

public plugin_init( )
{
register_plugin( "Nvault Easy Test", "1.0", "Fuffy" );

register_clcmd( "say /show", "show" );
register_clcmd( "say /big", "big" );

// Nv Open:
nve_open( );

}

// De fiecare data cand scrii in chat '/big' iti salva 'banii actuali + inca o suta"

public big( id )
{

new iMoney = cs_get_user_money( id );

nve_set_int( id, SYMBOL, iMoney + 100);

}


// De fiecare data cand scrii /show iti va arata cand bani ai salvati.
public show( id )
{
new ReturneazaMoney = nve_get_int( id, SYMBOL );

client_print( id, print_chat, "Money: %i", ReturneazaMoney );
}

public plugin_end()
{
nve_close();
}


Exemplu salvare string:

SMA | Afiseaza codul
#include <amxmodX>
#include <cstrike>
#include <nve>

#define SYMBOL "Test"

public plugin_init( )
{
register_plugin( "Nvault Easy Test", "1.0", "Fuffy" );

register_clcmd( "say /test", "big" );
register_clcmd( "say /show", "show" );

nve_open( );

}


public big( id )
{

nve_set_string( id, SYMBOL, " PROPOZITIE " );

}


public show( id )
{
new TheString[64];
nve_get_string( id, SYMBOL, TheString, charsmax( TheString ) );

client_print( id, print_chat, "%s", TheString );
}

public plugin_end()
{
nve_close();
}

_________________
AMXX Blue e acum doar pe github.


Last edited by Fuffy on 13 Dec 2016 23:49, edited 9 times in total.



29 Nov 2016 17:00
Profile multumesc WWW
Membru, skill +4
Membru, skill +4
User avatar

Joined: 05 Jan 2016 19:17
Posts: 1878
Detinator Steam: Nu
Detinator server CS: Da
Reputatie: Membru Club eXtreamCS (2 luni)
Fond eXtream: 0
se poate salva in nvault si stringuri


29 Nov 2016 19:05
Profile multumesc YIM WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
JaiLBreaK wrote:
se poate salva in nvault si stringuri


Mersi, am sa-mi notez in palma sa tin minte.

Si , care e rostul reply-ului asta?

_________________
AMXX Blue e acum doar pe github.


29 Nov 2016 19:32
Profile multumesc WWW
Online
Utilizator neserios
Utilizator neserios

Joined: 10 Oct 2014 06:21
Posts: 3428
Location: Roman, Neamț
Detinator Steam: Da
SteamID: /id/london_extreamcs
Reputatie: Membru Club eXtreamCS (6 luni)
Restrictie moderator
Utilizator neserios
Fond eXtream: 0
| Afiseaza codul
#if defined _easy_stock_included
#endinput
#endif

#define _easy_stock_included

#include <cstrike>
#include <fun>
#include <fakemeta>

stock afla_echipa(id)
{
if(!is_user_alive(id) || is_user_bot(id) || is_user_hltv(id))
return -1;

return get_user_team(id);
}

stock afla_bani(id)
{
if(!is_user_alive(id) || is_user_bot(id) || is_user_hltv(id))
return -1;

return cs_get_user_money(id);
}

stock afla_resurse(id, szType = 0)
{
if(!is_user_alive(id) || is_user_bot(id) || is_user_hltv(id) || !szType)
return -1;

switch(Type)
{
case 1: return get_user_health(id);
case 2: return get_user_armor(id);
}

return -1;
}

stock afla_loc(id)
{
if(!is_user_alive(id) || is_user_bot(id) || is_user_hltv(id))
return -1;

new Float:Origin[3], ReturnLocation[3];
pev(id, pev_origin, Origin);
FVecIVec(Origin, ReturnLocation);

return ReturnLocation;
}


am gasit si eu astea prin PC poate ajuta pe cineva.

_________________
METODA BOOST/DROP 2018 GRATUITA (pentru CS 1.6)
AMX XMAS Gifts 2.0 - Private Plugin
AMX Christmass Addons (2018)
[VAND] Addons Zombie v7.1 (Release 10 February 2018)[/center]


29 Nov 2016 21:27
Profile multumesc
Membru, skill +4
Membru, skill +4
User avatar

Joined: 05 Jan 2016 19:17
Posts: 1878
Detinator Steam: Nu
Detinator server CS: Da
Reputatie: Membru Club eXtreamCS (2 luni)
Fond eXtream: 0
stock nve_set_int( id, szSymb[], Number )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );

formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );

new szData[11];
num_to_str( Number, szData, charsmax( szData ) );


nvault_set( gVault, buffer, szData );
}
uite rostu


29 Nov 2016 21:45
Profile multumesc YIM WWW
Fost moderator
Fost moderator
User avatar

Joined: 11 Jul 2012 18:45
Posts: 3463
Detinator Steam: Da
CS Status: [əˈnɒn.ɪ.məs]
Reputatie: Fost scripter eXtreamCS
Fost eXtream Mod
Fond eXtream: 0
JailBreak, mai nou esti orb?
Omul a specifiat:
Quote:
e un mod mult mai usor de a salve Numerele ( integers )

Exemplu: nve_set_int( id, "L", g_iUserLevel[id] )

_________________
Cand nu merge acest forum sunt online aici:
    * Skype: nubo_cs
    * Y!M ID: nubo_cs



29 Nov 2016 21:54
Profile multumesc YIM
Membru, skill +4
Membru, skill +4
User avatar

Joined: 05 Jan 2016 19:17
Posts: 1878
Detinator Steam: Nu
Detinator server CS: Da
Reputatie: Membru Club eXtreamCS (2 luni)
Fond eXtream: 0
Nubo wrote:
JailBreak, mai nou esti orb?
Omul a specifiat:
Quote:
e un mod mult mai usor de a salve Numerele ( integers )

Exemplu: nve_set_int( id, "L", g_iUserLevel[id] )

eh nu am vazut asta dar putea face totusi 2 variante, una pentru numere si una pentru string


29 Nov 2016 21:56
Profile multumesc YIM WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
JaiLBreaK wrote:
eh nu am vazut asta dar putea face totusi 2 variante, una pentru numere si una pentru string


Ok, adaugat, alte idei sau nevoi?

Code:
nve_get_string( id, symbol, string, len );
nve_set_string( id, symbol, string );

_________________
AMXX Blue e acum doar pe github.


30 Nov 2016 00:47
Profile multumesc WWW
Membru, skill +1
Membru, skill +1
User avatar

Joined: 07 Jan 2016 09:34
Posts: 317
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Update:

- Adaugat:
Code:
const NVE_VERSIO


Poate ii trebe cuiva, eu stiu ..

+

2 stock-uri:

nve_update_int / nve_update_string

Le folosit in client_infochanged() cand jucatorul isi schimba noul nume pentru ai updata cu informatia noului nume.

_________________
AMXX Blue e acum doar pe github.


13 Dec 2016 23:35
Profile multumesc WWW
Online
Utilizator neserios
Utilizator neserios

Joined: 10 Oct 2014 06:21
Posts: 3428
Location: Roman, Neamț
Detinator Steam: Da
SteamID: /id/london_extreamcs
Reputatie: Membru Club eXtreamCS (6 luni)
Restrictie moderator
Utilizator neserios
Fond eXtream: 0
Nu e complet functional, dupa schimbarea mapei nu imi mai salveaza datele.

_________________
METODA BOOST/DROP 2018 GRATUITA (pentru CS 1.6)
AMX XMAS Gifts 2.0 - Private Plugin
AMX Christmass Addons (2018)
[VAND] Addons Zombie v7.1 (Release 10 February 2018)[/center]


09 Feb 2018 11:43
Profile multumesc
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

În cazul în care aveți probleme cu contul trimiteți un email sau mesaj la servicii_extream[arond]yahoo[punct]com

Powered by phpBB® Forum Software © phpBB Group