Jump to content
  • 0

@reward command ( BUG )


awesomazingxed

Question


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Hello everyone, can someone help me with this script. 

Everytime I use @reward command, it keeps saying "player is not online" eventhough they're online and the name is correct. Thanks in advance. Ciao. 



-	script	reward	-1,{

	OnInit:
		// Configuration
		bindatcmd "reward", strnpcinfo(3) +"::OnAtcommand", 40, 40;
	
		// Enable preset items? 1 = yes, 0 = no
		.preset = 1;
		
		// Announce reward? 1 = yes, 0 = no
		.announce = 1;
		
		// Log reward? 1 = yes, 0 = no
		.log = 1;
		
		// Define preset item IDs and amounts
		setarray .preset_id[0],
			7720, 1,	// 1: Gold Coin
			7307, 50;	// 2: Spiritual Whispers
			
		end;
		
	
	OnAtcommand:
		// Reward with preset items (syntax: @reward <preset> <player name>)
		if (.preset) {
			// Check if preset is defined
			if (!atoi(.@atcmd_parameters$[0]) || (atoi(.@atcmd_parameters$[0]) - 1) * 2 > .@atcmd_numparameters) {
				message strcharinfo(0), "Invalid preset defined.";
				
				// List presets
				for (.@i = 0; .@i < getarraysize(.preset_id); .@i += 2) {
					message strcharinfo(0), (.@i / 2 + 1) +": "+ .preset_id[.@i + 1] +" "+ getitemname(.preset_id[.@i]);
				}
				
				message strcharinfo(0), .@atcmd_command$ +" failed.";
				end;
			}
			
			// Select preset item ID and amount
			.@item_id = .preset_id[(atoi(.@atcmd_parameters$[0]) - 1) * 2];
			.@amount = .preset_id[(atoi(.@atcmd_parameters$[0]) - 1) * 2 + 1];
			
		// Reward with user-defined items (syntax: @reward <item id> <amount> <player name>
		} else {
			// Define item ID and amount
			.@item_id = atoi(.@atcmd_parameters$[0]);
			.@amount = atoi(.@atcmd_parameters$[1]);
		}
		
		// Check for proper input
		if (.@atcmd_numparameters < (.preset ? 2 : 3)) {
			message strcharinfo(0), "Invalid syntax (usage: "+ .@atcmd_command$ +" "+ (.preset ? "<preset>" : "<item id> <amount>") +" <player name>).";
			message strcharinfo(0), .@atcmd_command$ +" failed.";
			end;
		}
	
		// Determine target player name
		for (.@i = (.preset ? 1 : 2); .@i < .@atcmd_numparameters; .@i++) {
			.@player_name_tmp$[.@j++] = .@atcmd_parameters$[.@i];
		}
	
		// Define target player name
		.@player_name$ = implode(.@player_name_tmp$, " ");
		
		// Check if target player is online
		if (!getcharid(3, .@player_name$)) {
			message strcharinfo(0), "The player '"+ .@player_name$ +"' is not online or does not exist.";
			message strcharinfo(0), .@atcmd_command$ +" failed.";
			
		// Reward target player
		} else {
			getitem .@item_id, .@amount, getcharid(3, .@player_name$);
			
			// Announce reward
			if (.announce) {
				announce strcharinfo(0) +" has rewarded '"+ .@player_name$ +"' with "+ .@amount +" "+ getitemname(.@item_id) +".", bc_all;
			}
			
			// Log reward
			if (.log) {
				query_logsql
				"INSERT INTO `rewardlog` VALUES (NULL, '"+ getcharid(3) +"', '"+ escape_sql(strcharinfo(0)) +"', '"+ .@amount +"', '"+ .@item_id +"', "+
				"'"+ escape_sql(getitemname(.@item_id)) +"', '"+ getcharid(0, .@player_name$) +"', '"+ escape_sql(.@player_name$) +"', NOW())";
				
				message strcharinfo(0), "Reward has been logged.";
			}
		}
		
		end;

}

Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Anyone?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  177
  • Reputation:   21
  • Joined:  01/31/12
  • Last Seen:  

Posts in the support sections may be bumped with MORE INFORMATION no less than 24 hours after the last post.Any other bumping is not allowed.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Oh sorry. didn't know that.  /ok

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  51
  • Topics Per Day:  0.01
  • Content Count:  95
  • Reputation:   0
  • Joined:  10/24/14
  • Last Seen:  

Can you help me with this Luciar?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...