Raised This Month: $ Target: $400
 0% 

[resolved] Vault and Events


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-22-2006 , 07:32   Re: Vault and Events
Reply With Quote #1

you have to use client_authorized... client_connect wont work...
[ --<-@ ] Black Rose is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 10-22-2006 , 14:15   Re: Vault and Events
Reply With Quote #2

I don't know how to use nVault, or any kind of vault for that matter. There is also a problem with my ScoreInfo event, because NONE of the client_print's get executed, and at least the ScoreInfo one should.

I tried client_putinserver, and it may no change. client_authorized should not be any different.

EDIT: I got the client_print for the ScoreInfo function to show up, but the other two on LoadXP and SaveXP do not show.

Here's the code I used:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <vault> new score[33] new deaths[33] new currentscore[33] new currentdeaths[33] //new g_scoreinfo public plugin_init() {     register_plugin("Kill/Death Records", "1.0", "fluffy")     register_concmd("say saveme", "SaveXP")     //g_scoreinfo = get_user_msgid("ScoreInfo")     register_event("ScoreInfo", "ScoreInfo", "a") } public SaveXP(id) {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"score-%s",authid)     format(vaultdata,63,"%i",currentscore[id])     set_vaultdata(vaultkey,vaultdata)         format(vaultkey,63,"deaths-%s",authid)     format(vaultdata,63,"%i",currentdeaths[id])     set_vaultdata(vaultkey,vaultdata) } public LoadXP(id) {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"score-%s",authid)     get_vaultdata(vaultkey,vaultdata,63)     score[id] = str_to_num(vaultdata)         format(vaultkey,63,"deaths-%s",authid)     get_vaultdata(vaultkey,vaultdata,63)     deaths[id] = str_to_num(vaultdata)     } public client_putinserver(id) {     client_print(id, print_console, "Kill/Death Loaded.")     LoadXP(id) } public client_disconnect(id) {           client_print(id, print_console, "Kill/Death Saved.")     SaveXP(id) } public ScoreInfo() {     new playerid, playerscore, playerdeaths, data4, data5         playerid = read_data(1)         if(is_user_bot(playerid))     {         return PLUGIN_HANDLED     }         client_print(playerid, print_chat, "ScoreInfo function called.")         playerscore = read_data(2)     playerdeaths = read_data(3)         data4 = read_data(4)     data5 = read_data(5)         format(currentscore[playerid], 32, "%i", playerscore + score[playerid])         format(currentdeaths[playerid],32, "%i", playerdeaths + deaths[playerid])         message_begin(MSG_ALL, 83, {0,0,0}, playerid)     //message_begin(MSG_ALL, g_scoreinfo, {0,0,0}, playerid)     write_byte(playerid)     write_short(playerscore)     write_short(playerdeaths)     write_short(data4)     write_short(data5)     message_end()         return PLUGIN_CONTINUE }

Last edited by stupok; 10-22-2006 at 14:29.
stupok is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 10-22-2006 , 15:56   Re: Vault and Events
Reply With Quote #3

This deserves a new post! I fixed all the kinks and here is the working code, though there may be some performance issues. I think the server lags a little with this plugin running...

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <vault> #include <engine> new score[33] new deaths[33] new currentscore[33] new currentdeaths[33] new framecount public plugin_init() {     register_plugin("Kill/Death Records", "1.0", "fluffy")     register_concmd("say /save", "SaveXP")     register_event("ScoreInfo", "ScoreInfo", "a") } public server_frame() {     if(++framecount > 90)     {         for(new i = 0; i <= 32; i++)         {             if(is_user_bot(i))             {                 return PLUGIN_HANDLED             }                     new authid[32], vaultstring[256]             get_user_authid(i,authid,31)                         new xe[256]             num_to_str(currentscore[i], xe, 255)                         format(vaultstring, 255, "score%s=", authid)             set_vaultdata(vaultstring, xe)                         num_to_str(currentdeaths[i], xe, 255)                         format(vaultstring, 255, "deaths%s=", authid)             set_vaultdata(vaultstring, xe)             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE } public SaveXP(id) {         if(is_user_bot(id))     {         return PLUGIN_HANDLED     }         new authid[32], vaultstring[256]     get_user_authid(id,authid,31)         new xe[256]     num_to_str(currentscore[id], xe, 255)         format(vaultstring, 255, "score%s=", authid)     set_vaultdata(vaultstring, xe)         num_to_str(currentdeaths[id], xe, 255)         format(vaultstring, 255, "deaths%s=", authid)     set_vaultdata(vaultstring, xe)     return PLUGIN_CONTINUE } public LoadXP(id) {     if(is_user_bot(id))     {         return PLUGIN_HANDLED     }         new authid[32], vaultstring[256]     get_user_authid(id, authid, 31)         format(vaultstring, 255, "score%s=", authid)         if(vaultdata_exists(vaultstring))     {         new xe[256]         get_vaultdata(vaultstring, xe, 255)         score[id] = str_to_num(xe)     }         format(vaultstring, 255, "deaths%s=", authid)         if(vaultdata_exists(vaultstring))     {         new xe[256]         get_vaultdata(vaultstring, xe, 255)         deaths[id] = str_to_num(xe)     }     return PLUGIN_CONTINUE } public client_putinserver(id) {     LoadXP(id) } public client_disconnect(id) {     SaveXP(id) } public ScoreInfo() {     new playerid, playerscore, playerdeaths, data4, data5         playerid = read_data(1)         if(is_user_bot(playerid))     {         return PLUGIN_HANDLED     }         client_print(playerid, print_chat, "ScoreInfo function called.")         playerscore = read_data(2)     playerdeaths = read_data(3)         data4 = read_data(4)     data5 = read_data(5)         currentscore[playerid] = playerscore + score[playerid]     currentdeaths[playerid] = playerdeaths + deaths[playerid]         message_begin(MSG_ALL, 83, {0,0,0}, playerid)     write_byte(playerid)     write_short(currentscore[playerid])     write_short(currentdeaths[playerid])     write_short(data4)     write_short(data5)     message_end()         return PLUGIN_CONTINUE }
stupok 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 04:44.


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