Raised This Month: $32 Target: $400
 8% 

ReplyToTargetError() - FindTarget - Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 01-24-2015 , 08:13   ReplyToTargetError() - FindTarget - Problem
Reply With Quote #1

Hello,

This is my code:

PHP Code:
new String:arg1[32];
 
GetCmdArg(1arg132);
 new 
Target FindTarget(clientarg1);
 if(
Target == -1)
 {
    
ReplyToCommand(client"Player not found.");
    return 
Plugin_Handled;
 } 
I try command ( !test abcderfdsls ) and in console error (Player not exist on server)
PHP Code:
L 01/24/2015 14:10:24: [SMPlugin encountered error 4Invalid parameter or parameter type
L 01
/24/2015 14:10:24: [SMNative "ReplyToCommand" reportedLanguage phrase "No matching client" not found
L 01
/24/2015 14:10:24: [SMDisplaying call stack trace for plugin "test.smx":
L 01/24/2015 14:10:24: [SM]   [0]  Line 103, /groups/sourcemod/compiler-1.6/include/commandfilters.inc::ReplyToTargetError()
L 01/24/2015 14:10:24: [SM]   [1]  Line 198, /groups/sourcemod/compiler-1.6/include/helpers.inc::FindTarget()
L 01/24/2015 14:10:24: [SM]   [2]  Line 132, /groups/sourcemod/upload_tmp/textK8zZx3.sp::test() 
Why don't written in chat "Player not found."? Where is problem?
Thanks for reply.
Fastmancz is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 01-24-2015 , 08:17   Re: ReplyToTargetError() - FindTarget - Problem
Reply With Quote #2

FindTarget requires that you LoadTranslations("common.phrases.txt") since that's the file that contains the "No matching client" string. You don't need to handle the return with a ReplyToCommand yourself though, FindTarget does it automatically. Just check the return isn't -1 then continue.
__________________

Last edited by 11530; 01-24-2015 at 08:21.
11530 is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 01-24-2015 , 08:31   Re: ReplyToTargetError() - FindTarget - Problem
Reply With Quote #3

Quote:
Originally Posted by 11530 View Post
FindTarget requires that you LoadTranslations("common.phrases.txt") since that's the file that contains the "No matching client" string. You don't need to handle the return with a ReplyToCommand yourself though, FindTarget does it automatically. Just check the return isn't -1 then continue.
Ok, thanks. Problem solved.

PHP Code:
public OnPluginStart()
{
LoadTranslations("test.phrases");

---
PHP Code:
"Phrases"
{
  
"No matching client"
  
{
    
"en"  "Player not found."
  
}

---
PHP Code:
if(Target == -1)
 {
    return 
Plugin_Handled;
 } 
---
Fastmancz is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 01-24-2015 , 08:37   Re: ReplyToTargetError() - FindTarget - Problem
Reply With Quote #4

Almost there. But don't bother making your own test.phrases file. Use SourceMod's own common.phrases.txt because a) Everyone has it already, and b) There are more results that FindTarget can throw, e.g. ambiguity.

PHP Code:
public OnPluginStart()
{
    
LoadTranslations("common.phrases.txt");
}

//later...

new String:arg1[MAX_NAME_LENGTH]; 
GetCmdArg(1arg1sizeof(arg1)); 
new 
Target FindTarget(clientarg1); 
if(
Target == -1
{
    return 
Plugin_Handled

__________________

Last edited by 11530; 01-24-2015 at 08:38.
11530 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 10:29.


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