Raised This Month: $ Target: $400
 0% 

Transferring XP (WC3FT)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 12-03-2006 , 15:54   Transferring XP (WC3FT)
Reply With Quote #1

I'm trying to transfer XP between player. The "id" passed to the function transfer_xp is the user's ID who is calling it. Two parameters are passed: <name of receiver> <amount of XP>. Then, it creates the XP to be TAKEN from the giver, and creates the XP to be GIVEN to the receiver (which is a simple formula).

Example: Sleeper gives 100,000 XP to Johnny, the plugin will TAKE 100,000 XP from Sleeper, BUT give Johnny only 25,000 because the amount of XP given is multiplied by the PCVAR xp_percent. The plugin does not give or take XP at all which is my dilemma.

Hopefully you can help.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Transfer XP (WC3FT)" #define VERSION ".3a" #define AUTHOR "slmclarengt" new xp_percent; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say /transferxp", "transfer_xp", 0, "<name> <XP to transfer> - transfers xp between players/races")     register_clcmd("say_team /transferxp", "transfer_xp", 0, "<name> <XP to transfer> - transfers xp between players/races")     xp_percent = register_cvar("amx_xp_percent", "25")// XP actually used, other xp trashed (default: 25) } public transfer_xp(id) {     if (read_argc() == 1) // only 1 parameter (nothing passed)     {         client_print(id, print_chat, "/transferxp <name> <Amount XP to transfer> - only %d% will be transferred!", get_pcvar_num(xp_percent));     }     new target[32], amt[10];         read_argv(1, target, 31) // receiver of xp     read_argv(2, amt, 9) // amount of xp         new xp = str_to_num(amt) // make string to number for multiplication         client_print(0, print_chat, "%s wants to give a player %d XP", target, amt) //debug     new target_id = get_user_index(target); //Index for target         client_print(0, print_chat,"%d is the receivers ID", target_id) //debug         new negative_xp = 0 - xp // negative xp to take from giver     new t_xp = (xp * (get_pcvar_num(xp_percent) / 100));// ACTUAL transfer xp amount (amt * keep xp amt)         client_print(0, print_chat, "%d XP will be taken from giver & %d XP will be given to receiver", negative_xp, t_xp)         new receive_name[32];     get_user_name(target_id, receive_name, 31);     new give_name[32];     get_user_name(id, give_name, 31);         client_print(id, print_chat, "You are giving %d XP but losing %d XP to %s - what a nice person!", t_xp, xp, receive_name)     client_print(target_id, print_chat, "%s is giving you %d XP for the current race - be thankful!", give_name, t_xp)         server_cmd("amx_givexp %s %d", receive_name, t_xp) // give t_xp XP to receiver     server_cmd("amx_givexp %s %d", give_name, negative_xp); // take XP away from giver }

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt 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 06:59.


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