Raised This Month: $32 Target: $400
 8% 

nVault(SOLVED) and Top10 MOTD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wEight
BANNED
Join Date: Jan 2015
Old 05-24-2015 , 10:32   nVault(SOLVED) and Top10 MOTD
Reply With Quote #1

Yes yes i know, but the search box doesn't help me, that's why i made this thread. I made a little nVault plugin that saves points to the user when he types the command.
The nVault tutorial only gave me info what the natives are, i just get confused every time i try to read about them... i just can't understand it.
So i made this and it saves the user's points when he reconnects but it wont save them and when the map changes... how do i do that? And i don't know how to make motds... i searched and searched and there aren't any (Like in statsx.. but that didn't help me either and not a motd with HTML). So i want the motd to save users points...

Let's just go step by step until i complete it.

And here is the sma code (UPDATED)
PHP Code:
#include <amxmodx>
#include <nvault>

#define PLUGIN "BlahnVault"
#define VERSION "1.0"
#define AUTHOR "wEight"

new points[33]
new 
g_Vault

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /winpoints""cmd_winpoints")
    
register_clcmd("say /showpoints""cmd_showpoints")
    
    
g_Vault nvault_open("blahvault")
}

public 
client_authorized(id)
{
    
points[id] = loadpoints(id)
}

public 
plugin_end()
{
    
nvault_close(g_Vault)
}

public 
cmd_winpoints(id)
{
    
points[id] += 1
    savepoints
(idpoints[id])
}

public 
loadpoints(id
{    
    new 
authid[33]
    new 
vaultkey[64], vaultdata[64]
    
    
get_user_authid(idauthid32)
    
    
format(vaultkey63"%s-blahs"authid)
    
    
nvault_get(g_Vaultvaultkeyvaultdata63)
    
// nvault_close put in plugin_end
    
return str_to_num(vaultdata)
}

public 
savepoints(idpointz)
{
    
    if(
g_Vault == INVALID_HANDLE)
        
set_fail_state("Oh noes! Invalid Handle")
    
    new 
authid[32]
    new 
vaultkey[64], vaultdata[64]
    
    
get_user_authid(idauthid31)
    
    
format(vaultkey63"%s-blahs"authid)
    
format(vaultdata63"%d^n"pointz)
    
    
nvault_set(g_Vaultvaultkeyvaultdata)
    
// nvault_close put in plugin_end
}

public 
cmd_showpoints(id)
{
    
client_print(idprint_chat"You have %d point(s)!"points[id])

So... first, i need to fix this error, then you can help me with the nvault saving the points when map changes or server restarts (not global restart), then i want to make a motd of top10 players with points...

If you can help me with this it would be very appreciated and i will put your credit on my plugin update.

Edit: Need help with motd now

Last edited by wEight; 05-24-2015 at 12:09. Reason: Solved first and second round
wEight is offline
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 05-24-2015 , 10:53   Re: nVault and Top10
Reply With Quote #2

Just check if is_user_alive to fix the problem.
zmd94 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-24-2015 , 10:57   Re: nVault and Top10
Reply With Quote #3

The problem is you open the vault at plugin_init and then close it when load or save is called. Do not close the vault after saving and loading, close the vault only once at plugin_end().

There may be other things wrong, but this is the cause of that error.
__________________

Last edited by Bugsy; 05-24-2015 at 10:58.
Bugsy is offline
wEight
BANNED
Join Date: Jan 2015
Old 05-24-2015 , 11:59   Re: nVault and Top10
Reply With Quote #4

@zmd94

How can that fix the problem? It doesn't make sense to me, checks if user is alive.. why shouldn't dead users use it?

@Bugsy

Works fine now.. Thank you

SOLVED

Last edited by wEight; 05-24-2015 at 13:49. Reason: Solved
wEight 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 16:50.


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