Raised This Month: $ Target: $400
 0% 

help with xp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-01-2005 , 01:26   help with xp
Reply With Quote #1

im trying to understand how xp plugins work. i slaped some coding together ( alot came from the Xp Tut) And Here Is Wut I Got... Sry Im A Noob.
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <vault> new PlayerXP[33] new msgtext public plugin_init() {     register_plugin("Xp_Mod", "1.0", "Fire")         register_cvar("sv_xpmod", "1")         register_event("DeathMsg", "DeathMsg", "a")         register_cvar("XP_per_kill", "20")         msgtext = get_user_msgid("StatusText") } public SaveXP(id) {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"ANIMAL-%s-xp",authid);     format(vaultdata,63,"%d",PlayerXP[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,"ANIMAL-%s-xp",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerXP[id] = str_to_num(vaultdata); } public client_connect(id) {     if(get_cvar_num("SaveXP") == 1) {                 LoadXP(id)                 client_print(id, print_chat, "[Xp_Mod] XP Loaded!")         client_print(id, print_chat, "[Xp_Mod] You Have %s XP")     } } public client_disconnect(id) {     if(get_cvar_num("SaveXP") == 1) {                 SaveXP(id)     } } public DeathMsg() {     if(get_cvar_num("sv_xpmod") == 0) {         return PLUGIN_HANDLED     }         new attacker = read_data(1)         PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(get_cvar_num("SaveXP") == 1) {                 SaveXP(attacker)     }         ShowHUD(attacker) }     ShowHUD(attacker) return PLUGIN_CONTINUE } public ShowHUD(id)     { new HUD[51] format(HUD, 50, "XP: %i", PlayerXP[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUD) message_end() return }
Can Some One Please Fix This to Give you Xp For Every kill... And Explain Wut You Did. Thanks Alot , Fire
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 09-01-2005 , 01:52  
Reply With Quote #2

In your SaveXP function, try putting quotes around the data that you're saving:
Code:
format(vaultdata,63,"^"%d^"",PlayerXP[id]);
I had some trouble saving/loading my XP, so I did that and it worked. Hopefully it'll work in your situation.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-01-2005 , 02:00  
Reply With Quote #3

Hmm Still Dosnt Work... This is My First Time Trying A plugin With xp
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-01-2005 , 03:37  
Reply With Quote #4

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <vault> new PlayerXP[33] new msgtext public plugin_init() {     register_plugin("Xp_Mod", "1.0", "Fire")         register_cvar("sv_xpmod", "1")         register_event("DeathMsg", "DeathMsg", "a")         register_cvar("XP_per_kill", "20")     register_cvar("SaveXP","1") // added SaveXP cvar         msgtext = get_user_msgid("StatusText") } public SaveXP(id) {     new authid[32];     get_user_authid(id,authid,31);         new vaultkey[64], vaultdata[64];         format(vaultkey,63,"ANIMAL-%s-xp",authid);     format(vaultdata,63,"%d",PlayerXP[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,"ANIMAL-%s-xp",authid);     get_vaultdata(vaultkey,vaultdata,63);     PlayerXP[id] = str_to_num(vaultdata); } public client_connect(id) {     if(get_cvar_num("SaveXP") == 1) {         LoadXP(id)                 client_print(id, print_chat, "[Xp_Mod] XP Loaded!")         client_print(id, print_chat, "[Xp_Mod] You Have %d XP",PlayerXP[id]) // changed %s (string) to %d (data, works for integers) and added parameter to display the experience     } } public client_disconnect(id) {     if(get_cvar_num("SaveXP") == 1) {         SaveXP(id)     } } public DeathMsg() {     if(get_cvar_num("sv_xpmod") == 0) {         return // removed PLUGIN_HANDLED so I'm not forced to return a value later     }         new attacker = read_data(1)         PlayerXP[attacker] += get_cvar_num("XP_per_kill")         if(get_cvar_num("SaveXP") == 1) {         SaveXP(attacker)     }         ShowHUD(attacker)     // removed strange extra code } // in below function: indented and removed un-needed "return" at bottom public ShowHUD(id)     {     new HUD[51]     format(HUD, 50, "XP: %i", PlayerXP[id])     message_begin(MSG_ONE, msgtext, {0,0,0}, id)     write_byte(0)     write_string(HUD)     message_end() }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-01-2005 , 09:21  
Reply With Quote #5

I think the big problem was the extra closing bracket. But yea the %s to %d was needed too.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-01-2005 , 14:10  
Reply With Quote #6

hmmm its still not saveing xp on dissconnect.. and not loading one connect.... the messages
Code:
client_print(id, print_chat, "[Xp_Mod] XP Loaded!") client_print(id, print_chat, "[Xp_Mod] You Have %d XP",PlayerXP[id])
dont work... also how would i make it to give xp for a plant or defuse? thank you , Fire
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-01-2005 , 16:29  
Reply With Quote #7

ok i got it to save fine! But now it dose not load... here is the code Plz HElp!
Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> #include <vault> new PlayerXP[33] new msgtext public plugin_init() { register_plugin("Xp_Mod", "1.0", "Fire") register_cvar("sv_xpmod", "1") register_cvar("XP_per_kill", "10") register_event("DeathMsg", "DeathMsg", "a") msgtext = get_user_msgid("StatusText") } public SaveXP(id) { new authid[32]; get_user_authid(id,authid,31); new vaultkey[64], vaultdata[64]; format(vaultkey,63,"XPMOD: %s Xp:",authid); format(vaultdata,63,"^"%d^"",PlayerXP[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,"XPMOD: %s Xp:",authid); get_vaultdata(vaultkey,vaultdata,63); PlayerXP[id] = str_to_num(vaultdata); } public client_connect(id) { LoadXP(id) } public client_disconnect(id) {   SaveXP(id) } public DeathMsg() { if(get_cvar_num("sv_xpmod") == 0) { return PLUGIN_HANDLED } new attacker = read_data(1) PlayerXP[attacker] += get_cvar_num("XP_per_kill") ShowHUD(attacker) return PLUGIN_CONTINUE } public ShowHUD(id)       { new HUD[51] format(HUD, 50, "XP: %i", PlayerXP[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUD) message_end() }
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 09-01-2005 , 18:23  
Reply With Quote #8

Quote:
Code:
public ShowHUD(id)       { new HUD[51] format(HUD, 50, "XP: %i", PlayerXP[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUD) message_end() }
Dont use %i use %d and then tell us if it works
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
onfirenburnin420
Senior Member
Join Date: Jan 2005
Old 09-01-2005 , 18:49  
Reply With Quote #9

thats not my problem .... its not loading the xp....
__________________
onfirenburnin420 is offline
Send a message via AIM to onfirenburnin420
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-01-2005 , 18:50  
Reply With Quote #10

And thats why because of the %i change it to %d ...trust us
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 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 14:28.


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