Raised This Month: $ Target: $400
 0% 

[resolved] Vault and Events


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 10-22-2006 , 01:09   [resolved] Vault and Events
Reply With Quote #1

I want to make this plugin record the player's score and deaths in the vault and load them up whenever the player connects. So, the player's score and deaths are never set back to 0.

Here's the not-working code, it doesn't even show any of the client_print's when I tested it. And it didn't want to show up in amx_plugins until I added the register_concmd().

I never learned to use the vault, this is just ripped from the "XP based plugin" thread. And I don't know what the difference between register_message() and register_event() is...

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_connect(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, 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-23-2006 at 18:49.
stupok is offline
 



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