Raised This Month: $ Target: $400
 0% 

Nvault top15


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 12-11-2012 , 12:20   Nvault top15
Reply With Quote #1

in top15 its shows steamid insted of names
i want i to show name
how can i fix that?

Code:
stock save_client_points( index )
{
 gVault = nvault_open( "Jbcash" )
 
 if( gVault == INVALID_HANDLE )
 {
  set_fail_state( "[JbShop] nValut ERROR: =-> Invalid-Handle" )
 }
 
 get_user_authid( index, gSteamID, charsmax( gSteamID ) )
 
 formatex( vKey, charsmax( vKey ), "%sCASH", gSteamID )
 formatex( vData, charsmax( vData ), "%d", gKillerPoints[ index ] )
 nvault_set( gVault, vKey, vData )
 nvault_close( gVault )
}
stock load_client_points( index )
{
 gVault = nvault_open( "Jbcash" )
 
 if( gVault == INVALID_HANDLE )
 {
  set_fail_state( "[JbShop] nValut ERROR: =-> Invalid-Handle" )
 }
 
 get_user_authid( index, gSteamID, charsmax( gSteamID ) )
 
 formatex( vKey, charsmax( vKey ), "%sCASH", gSteamID )
 gKillerPoints[ index ] = nvault_get( gVault, vKey )
 nvault_close( gVault )
}
public show_top15(id){
 new pos,key[64],data[64],timestamp
 new vault = nvault_util_open("Jbcash")
 new count = nvault_util_count(vault)
 
 new Array:stats,Trie:names
 stats = ArrayCreate(20)
 names = TrieCreate()
 
 new temp[20],knum[5]
 for (new i=1;i<=count;i++ ){
  pos = nvault_util_read(vault,pos,key,64,data,64,timestamp)
  formatex(temp,19,"%d %d",i,str_to_num(data))
  ArrayPushString(stats,temp)
  replace_all(key,64,"CASH","")
  formatex(knum,4,"%d",i)
  TrieSetString(names,knum,key)
 }
 
 nvault_util_close(vault)
 ArraySort(stats,"sorter")
 
 new motd[1501],iLen;
 iLen = format(motd, sizeof motd - 1,"<body bgcolor=#000000><font color=#98f5ff><pre>");
 iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"%s %-22.22s %3s^n", "#", "Name", "Cash")
 
 for(new x = 0; x < 15; x++){
  new rank,name[32],srank[5]
  new pt = getter(stats,x,rank)
  formatex(srank,4,"%d",rank)
  TrieGetString(names,srank,name,31)
  iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"%d %-22.22s %d^n", x + 1, name, pt);
 }
 iLen += format(motd[iLen], (sizeof motd - 1) - iLen,"</body></font></pre>")
 
 ArrayDestroy(stats)
 TrieDestroy(names)
 show_motd(id,motd, "Cash top");
}
public sorter(Array:array,item1,item2){
 new res1=getter(array,item1)
 new res2=getter(array,item2)
 
 if(res1<res2)
  return 1
 
 else if(res1>res2)
  return -1
 return 0
}
getter(Array:array,item,&rank=0){
 new outa[32],temp[2][10],val
 ArrayGetString(array,item,outa,31)
 parse(outa,temp[0],9,temp[1],9)
 rank = str_to_num(temp[0])
 val = str_to_num(temp[1])
 return val
}
 
public ClientUserInfoChanged(id) 
{ 
 static const name[] = "name" 
 static szOldName[32], szNewName[32] 
 pev(id, pev_netname, szOldName, charsmax(szOldName)) 
 if( szOldName[0] ) 
 {
  get_user_info(id, name, szNewName, charsmax(szNewName)) 
  if( !equal(szOldName, szNewName) ) 
  {
   gKillerPoints[id] = 0
   set_task(0.5, "ChangeTime", id)
   return FMRES_HANDLED 
  }
 }
 return FMRES_IGNORED 
}
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 12-11-2012 , 22:59   Re: Nvault top15
Reply With Quote #2

get_user_authid -> get_user_name
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 12-12-2012 , 09:29   Re: Nvault top15
Reply With Quote #3

Quote:
Originally Posted by Neeeeeeeeeel.- View Post
get_user_authid -> get_user_name
SOLVED

Thanks
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 06-30-2016 , 13:17   Re: Nvault top15
Reply With Quote #4

How to save on SteamID and display name of the player ?
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 06-30-2016 , 13:36   Re: Nvault top15
Reply With Quote #5

This post have 4 years, post your thread with this question.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-01-2016 , 05:34   Re: Nvault top15
Reply With Quote #6

Quote:
Originally Posted by EFFx View Post
This post have 4 years, post your thread with this question.
Why making a new thread if an old one could be revived with a simular question? I don't see the difference in it, only that this saves memory & money for alliemods to buy more storage nothing else.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 07-01-2016 , 17:02   Re: Nvault top15
Reply With Quote #7

Quote:
Originally Posted by BaD CopY View Post
How to save on SteamID and display name of the player ?
Check out my levelmod, in that plugin i save steamid and display player name
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.

Last edited by ironskillz1; 07-01-2016 at 17:02.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 07-03-2016 , 00:59   Re: Nvault top15
Reply With Quote #8

What is wrong with my code ?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault_util>
#include <fun>
#include <cstrike>
#include <ColorChat>

#define PLUGIN ""
#define VERSION "1.0"
#define AUTHOR ""

#define TopNumber 15
#define MAX_PLAYERS 32

new gPointsMAX_PLAYERS ]
new const 
SPECIAL_CHAR[2] = "-"
new g_iVault
new g_szTopMotd[1024]


public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_iVault nvault_open("POINTS")
    
FormatTop(TopNumber)
    
register_clcmd("say /btop15""show_top15");
}

public 
client_connect(id)
{
    
Load_Points(id);
}

public 
client_disconnect(id)
{
    
Save_Points(id);
}

stock Save_Pointsid )
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
    
    new 
szAuthId[35]; 
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    new 
szName[32]; 
    
get_user_name(idszName31)
    
    new 
szData[256];
    
formatex(szDatacharsmax(szData), "%i"gPoints[id]);
    
    
nvault_remove(g_iVaultszAuthId)
    
nvault_set(g_iVaultszAuthIdszData)
        
    
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
    
nvault_remove(g_iVaultszAuthId)
    
nvault_set(g_iVaultszAuthIdszName)

}

stock Load_Pointsid )
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
        
    new 
szSavedName[32]
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    new 
szAuthId[33]; get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    new 
szData[256], iTimeStamp
    
if( !nvault_lookup(g_iVaultszAuthIdszDatacharsmax(szData), iTimeStamp) )
    {
        
nvault_set(g_iVaultszAuthId"0")
        
        
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
        
nvault_set(g_iVaultszAuthIdszName)
        
        return 
0
    
}
    
    
ParseLoadData(idszData);
    
    
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
    
nvault_get(g_iVaultszAuthIdszSavedName)
    
    if(!
equal(szNameszSavedName))
    {
        
nvault_remove(g_iVaultszAuthId)
        
nvault_set(g_iVaultszAuthIdszName)
    }
    return 
0
}

ParseLoadData(idszData[256])
{
    static 
szNum[11];
    
strbreak(szDataszNumcharsmax(szNum), szDatacharsmax(szData));
    
gPoints[id] = str_to_num(szNum);
}

public 
show_top15(id)
    
show_motdidg_szTopMotd"Top Points" )

stock FormatTop(iNum)
{    
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
        
    
enum _:VaultData
    
{
        
VD_Key[33],
        
VD_Value,
        
VD_szName[33]
    };
    
    new 
Vault2 nvault_util_open("POINTS")
    new 
iSize nvault_util_count(Vault2)
    
    new Array:
entries ArrayCreate(VaultData);
    new 
sizeEntries
    
    
new data[VaultData], value[256], data2[VaultData]

    for(new 
0postimestampiSizei++)
    {
        
pos nvault_util_read(Vault2posdata[VD_Key], charsmax(data[VD_Key]), valuecharsmax(value), timestamp);
    
        if(
contain(data[VD_Key], SPECIAL_CHAR) != -1)
            continue;
        
        else
        {
            
formatex(data[VD_szName], charsmax(data[VD_szName]), "%s%s"data[VD_Key], SPECIAL_CHAR)
            
nvault_get(g_iVaultdata[VD_szName], data[VD_szName], charsmax(data[VD_szName]))
        }

        
data[VD_Value] = str_to_num(value);
        
        if(
sizeEntries == 0)
        {
            
ArrayPushArray(entriesdata);
            
sizeEntries++;
            continue;
        }
        
        else
        {
            for(
timestamp 0timestamp <= sizeEntriestimestamp++)
            {
                if(
timestamp == sizeEntries)
                {
                    if(
sizeEntries iNum)
                    {
                        
ArrayPushArray(entriesdata);
                        
sizeEntries++;
                    }
                    
                    break;
                }
          
                
ArrayGetArray(entriestimestampdata2);
                
                if(
data[VD_Value] >= data2[VD_Value])
                {
                    
ArrayInsertArrayBefore(entriestimestampdata);
                    
                    if(
sizeEntries iNum)
                    {
                        
sizeEntries++;
                    } 
                    else 
                    {
                        
ArrayDeleteItem(entriessizeEntries);
                    }
                    
                    break;
                }
            }
        }
    }
    
    new 
iLen
    
    
new len charsmax(g_szTopMotd)
    
    
iLen formatex(g_szTopMotdlen"<STYLE>body{background:#212121;color:#d1d1d1;font-family:Arial}table{width:100%%;font-size:28px}</STYLE><table cellpadding=1 cellspacing=1 border=0>")
    
iLen += formatex(g_szTopMotd[iLen], len iLen"<tr bgcolor=#333333><th width=1%%><align=left font color=white> %s <th width=5%%> %-22.22s <th width=5%%> %s""#""Name""Points")

    new 
i
    
for(0sizeEntriesi++)
    {
        
ArrayGetArray(entriesidata);
        
        
data[VD_Key][32] = 0;
        
data[VD_szName][32] = 0
        
        replace_all
(data[VD_szName], charsmax(data[VD_szName]), "<""&lt;")
        
replace_all(data[VD_szName], charsmax(data[VD_szName]), ">""&gt;")
        
        
iLen += formatex(g_szTopMotd[iLen], len iLen"<tr align=left%s><td align=left><font color=white> %d. <td> %-22.22s <td> %d"" bgcolor=#2b5b95", (i+1), data[VD_szName], data[VD_Value])
    }
    
    
ArrayDestroy(entries);
    
    
iLen += formatex(g_szTopMotd[iLen], len iLen"</table></body>")

Error: Doesn't show player name in motd. Shows only first 7 players (points). Shows '<tr align=left bgcolor=#2b5b' instead players points...

Last edited by BaD CopY; 07-03-2016 at 08:13.
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 07-03-2016 , 07:12   Re: Nvault top15
Reply With Quote #9

Quote:
Originally Posted by BaD CopY View Post
What is wrong with my code ?

PHP Code:
#define TopNumber 15
#define MAX_PLAYERS 32

new gPointsMAX_PLAYERS ]
new const 
SPECIAL_CHAR[2] = "-"
new g_iVault
new g_szTopMotd[1024]

//plugin init
        
g_iVault nvault_open("POINTS")
    
FormatTop(TopNumber)
        
register_clcmd("say /btop15""show_top15");

public 
client_connect(id)
{
    
Load_Points(id);
}

public 
client_disconnect(id)
{
    
Save_Points(id);
}

stock Save_Pointsid )
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
    
    new 
szAuthId[35]; 
    
get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    new 
szName[32]; 
    
get_user_name(idszName31)
    
    new 
szData[256];
    
formatex(szDatacharsmax(szData), "%i"gPoints[id]);
    
    
nvault_remove(g_iVaultszAuthId)
    
nvault_set(g_iVaultszAuthIdszData)
        
    
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
    
nvault_remove(g_iVaultszAuthId)
    
nvault_set(g_iVaultszAuthIdszName)

}

stock Load_Pointsid )
{
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
        
    new 
szSavedName[32]
    new 
szName[32]; get_user_name(idszNamecharsmax(szName))
    new 
szAuthId[33]; get_user_authid(idszAuthIdcharsmax(szAuthId))
    
    new 
szData[256], iTimeStamp
    
if( !nvault_lookup(g_iVaultszAuthIdszDatacharsmax(szData), iTimeStamp) )
    {
        
nvault_set(g_iVaultszAuthId"0")
        
        
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
        
nvault_set(g_iVaultszAuthIdszName)
        
        return 
0
    
}
    
    
ParseLoadData(idszData);
    
    
format(szAuthIdcharsmax(szAuthId), "%s%s"szAuthIdSPECIAL_CHAR)
    
nvault_get(g_iVaultszAuthIdszSavedName)
    
    if(!
equal(szNameszSavedName))
    {
        
nvault_remove(g_iVaultszAuthId)
        
nvault_set(g_iVaultszAuthIdszName)
    }
    return 
0
}

ParseLoadData(idszData[256])
{
    static 
szNum[11];
    
strbreak(szDataszNumcharsmax(szNum), szDatacharsmax(szData));
    
gPoints[id] = str_to_num(szNum);
}

public 
show_top15(id)
    
show_motdidg_szTopMotd"Top Points" )

stock FormatTop(iNum)
{    
    if(
g_iVault == INVALID_HANDLE)
        
set_fail_state("nVault returned invalid handle")
        
    
enum _:VaultData
    
{
        
VD_Key[33],
        
VD_Value,
        
VD_szName[33]
    };
    
    new 
Vault2 nvault_util_open("POINTS")
    new 
iSize nvault_util_count(Vault2)
    
    new Array:
entries ArrayCreate(VaultData);
    new 
sizeEntries
    
    
new data[VaultData], value[256], data2[VaultData]

    for(new 
0postimestampiSizei++)
    {
        
pos nvault_util_read(Vault2posdata[VD_Key], charsmax(data[VD_Key]), valuecharsmax(value), timestamp);
    
        if(
contain(data[VD_Key], SPECIAL_CHAR) != -1)
            continue;
        
        else
        {
            
formatex(data[VD_szName], charsmax(data[VD_szName]), "%s%s"data[VD_Key], SPECIAL_CHAR)
            
nvault_get(g_iVaultdata[VD_szName], data[VD_szName], charsmax(data[VD_szName]))
        }

        
data[VD_Value] = str_to_num(value);
        
        if(
sizeEntries == 0)
        {
            
ArrayPushArray(entriesdata);
            
sizeEntries++;
            continue;
        }
        
        else
        {
            for(
timestamp 0timestamp <= sizeEntriestimestamp++)
            {
                if(
timestamp == sizeEntries)
                {
                    if(
sizeEntries iNum)
                    {
                        
ArrayPushArray(entriesdata);
                        
sizeEntries++;
                    }
                    
                    break;
                }
          
                
ArrayGetArray(entriestimestampdata2);
                
                if(
data[VD_Value] >= data2[VD_Value])
                {
                    
ArrayInsertArrayBefore(entriestimestampdata);
                    
                    if(
sizeEntries iNum)
                    {
                        
sizeEntries++;
                    } 
                    else 
                    {
                        
ArrayDeleteItem(entriessizeEntries);
                    }
                    
                    break;
                }
            }
        }
    }
    
    new 
iLen
    
    
new len charsmax(g_szTopMotd)
    
    
iLen formatex(g_szTopMotdlen"<STYLE>body{background:#212121;color:#d1d1d1;font-family:Arial}table{width:100%%;font-size:28px}</STYLE><table cellpadding=1 cellspacing=1 border=0>")
    
iLen += formatex(g_szTopMotd[iLen], len iLen"<tr bgcolor=#333333><th width=1%%><align=left font color=white> %s <th width=5%%> %-22.22s <th width=5%%> %s""#""Name""Points")

    new 
i
    
for(0sizeEntriesi++)
    {
        
ArrayGetArray(entriesidata);
        
        
data[VD_Key][32] = 0;
        
data[VD_szName][32] = 0
        
        replace_all
(data[VD_szName], charsmax(data[VD_szName]), "<""&lt;")
        
replace_all(data[VD_szName], charsmax(data[VD_szName]), ">""&gt;")
        
        
iLen += formatex(g_szTopMotd[iLen], len iLen"<tr align=left%s><td align=left><font color=white> %d. <td> %-22.22s <td> %d"" bgcolor=#2b5b95", (i+1), data[VD_szName], data[VD_Value])
    }
    
    
ArrayDestroy(entries);
    
    
iLen += formatex(g_szTopMotd[iLen], len iLen"</table></body>")

Error: Doesn't show player name in motd. Shows only first 7 players (points). Shows '<tr align=left bgcolor=#2b5b' instead players points...
This code doesn't make sense... You don't include anything, no plugin_init, etc. etc... Provide us some original code and ask for customization if you don't know what you're doing. With this code we can't help you.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
BaD CopY
Senior Member
Join Date: Oct 2014
Location: Home
Old 07-03-2016 , 08:14   Re: Nvault top15
Reply With Quote #10

edited. (I don't need all that includes but in full code need them)
BaD CopY is offline
Send a message via Yahoo to BaD CopY Send a message via Skype™ to BaD CopY
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 18:19.


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