Raised This Month: $ Target: $400
 0% 

Arguments not finishing


  
 
 
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 02-16-2007 , 21:17   Arguments not finishing
Reply With Quote #1

Sorry for the name, It's very hard to make into a topic name.

My goal for this plugin: To allow players to transfer Experience (XP) between themselves but only allow a percentage of transferable XP.

Example: Player A has 10,000 XP and wants to give player B 100 XP. Percentage of usable XP is 10% so Player A transfers 10,000 XP so that player B receives the 100 XP.

My problem(s): When a name is passed via "/transferxp <name> <amount>" the plugin does not do anything, but when NOTHING is called but saying "/transferxp" it gives all the debug statements I included in the code. Here is a picture for better reference of all info. shown from JUST typing "/transferxp": [IMG]http://img126.**************/img126/4367/csitaly0000fv9.th.png[/IMG]

Note: the info. you cannot see is that of my debug statements inside the code. It says the SERVER is receiving the XP when I provide NO parameters.

My idea: For player A (Bill) to give XP to player B (John) by typing
"/transferxp John 10000" using the regular "say" function.

My code:
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Transfer XP (WC3FT)"
#define VERSION ".4a"
#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", "10")// XP actually used, other xp trashed (default: 10)
}

public transfer_xp(id)
{
	if (read_argc() == 1) // only 1 parameter (nothing passed)
	{
		client_print(id, print_chat, "Usage: /transferxp <name> <Amount XP to transfer>", 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
	
	client_print(0, print_chat, "Debug 1: Target's ID # %d - Amount: %d", target, amt); //debug
	new xp = str_to_num(amt); // make string to number for multiplication
	client_print(0, print_chat, "Debug 2: %s wants to give a player %d XP", target, xp); //debug
	new target_num = str_to_num(target);
	new target_id = get_user_index("target_num"); //Index for target
	client_print(0, print_chat,"Debug 3: %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 * percent kept)
	
	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
}
Also attached. A fix for this to work will result in major karma and possibly other rewards

Slmclarengt
Attached Files
File Type: sma Get Plugin or Get Source (Transfer_XP.sma - 462 views - 2.2 KB)
__________________
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
 


Thread Tools
Display Modes

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 00:36.


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