Raised This Month: $ Target: $400
 0% 

Command Unknowned. Where did i go wrong?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
z3rongod
Member
Join Date: Jul 2009
Old 02-01-2010 , 12:37   Command Unknowned. Where did i go wrong?
Reply With Quote #1

As the topic says what's wrong with the script i wrote?

Code:
#include <amxmodx>
#include <amxmisc>

public cmdExtreme(id, level, cid) {
    if (!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
        
    new arg[32]
    read_argv(1, arg, 31)
    new player = cmd_target(id, arg)
    client_cmd(player,"Connect ex.usn.ro")
    return PLUGIN_HANDLED
}

public plugin_init() {
    register_plugin("Transfer to Extreme","1.0","z3rongod")
    register_clcmd("amx_extreme", "cmdExtreme", ADMIN_KICK, "<name>")
    return PLUGIN_CONTINUE
}
It's supposed to transfer a player to our other server.

EDIT: this is the latest version. Problem is the command is executed on everyone.

Last edited by Emp`; 02-01-2010 at 13:48. Reason: added code tags
z3rongod is offline
Mxnn
Veteran Member
Join Date: Aug 2009
Location: AT MY HOME
Old 02-01-2010 , 13:46   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #2

Remove return PLUGIN_CONTINUE from plugin_init() function
Mxnn is offline
z3rongod
Member
Join Date: Jul 2009
Old 02-01-2010 , 14:11   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #3

Still it executes on all players from the server instead of the targeted player name.

I think the problem resides here:

new player = cmd_target(id, arg)
z3rongod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-01-2010 , 15:39   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #4

Check if player is more than 0 befor executing the command.
__________________
xPaw is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 02-01-2010 , 15:48   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #5

first give cmd_target a flag because otherwise it will return 0 as failure

second check if the variable player is 0, because if its 0, then cmd_target didnt find a valid target

lastly if player is 0 in client_cmd, it will think you wanted it to be executed on everyone. solution below

PHP Code:
new player cmd_target(idarg0)

if (
player != 0)
   
client_cmd(player,"connect ex.usn.ro"
__________________
M249-M4A1 is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 02-01-2010 , 16:00   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #6

PHP Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
    
register_plugin("Transfer to Extreme""1.0""z3rongod")

    
register_concmd("amx_extreme""cmdExtreme"ADMIN_KICK"<name>")
}

public 
cmdExtreme(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED

    
new arg[32]
    
read_argv(1arg31)

    new 
target_id cmd_target(idarg8)

    if (!
target_id)
        return 
PLUGIN_HANDLED

    client_cmd
(target_id"connect ex.usn.ro")

    return 
PLUGIN_HANDLED

Spunky is offline
Send a message via AIM to Spunky
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 02-01-2010 , 16:22   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #7

lol oops cmd_target flag 8 forgot about that! @OP heres the flags list from the API

Flags:
1 - obey immunity
2 - allow yourself
4 - must be alive
8 - can't be bot
__________________
M249-M4A1 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-01-2010 , 21:20   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #8

Quote:
Originally Posted by M249-M4A1 View Post
first give cmd_target a flag because otherwise it will return 0 as failure
This is incorrect. Default flag is 1. Returns 0 on failure to find target.
http://www.amxmodx.org/funcwiki.php?...rget&go=search
__________________
fysiks is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 02-01-2010 , 21:49   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
This is incorrect. Default flag is 1. Returns 0 on failure to find target.
http://www.amxmodx.org/funcwiki.php?...rget&go=search
my bad, thanks for the correction
__________________
M249-M4A1 is offline
z3rongod
Member
Join Date: Jul 2009
Old 02-02-2010 , 03:24   Re: Command Unknowned. Where did i go wrong?
Reply With Quote #10

So if cmd_target returns 0 on failure how come it failed when i gave a valid name; executed the command on valid player name?

By the way in case you didn't know, the command must be Connect, with capital 'C' else it won't be recognized. This is in effect since an update not long ago.

Edit: Forgot to say thanks for the help, it works as it should now!

Last edited by z3rongod; 02-02-2010 at 05:17.
z3rongod 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 07:23.


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