AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Command Unknowned. Where did i go wrong? (https://forums.alliedmods.net/showthread.php?t=117472)

z3rongod 02-01-2010 12:37

Command Unknowned. Where did i go wrong?
 
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.

Mxnn 02-01-2010 13:46

Re: Command Unknowned. Where did i go wrong?
 
Remove return PLUGIN_CONTINUE from plugin_init() function

z3rongod 02-01-2010 14:11

Re: Command Unknowned. Where did i go wrong?
 
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)

xPaw 02-01-2010 15:39

Re: Command Unknowned. Where did i go wrong?
 
Check if player is more than 0 befor executing the command.

M249-M4A1 02-01-2010 15:48

Re: Command Unknowned. Where did i go wrong?
 
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"


Spunky 02-01-2010 16:00

Re: Command Unknowned. Where did i go wrong?
 
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



M249-M4A1 02-01-2010 16:22

Re: Command Unknowned. Where did i go wrong?
 
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

fysiks 02-01-2010 21:20

Re: Command Unknowned. Where did i go wrong?
 
Quote:

Originally Posted by M249-M4A1 (Post 1075434)
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

M249-M4A1 02-01-2010 21:49

Re: Command Unknowned. Where did i go wrong?
 
Quote:

Originally Posted by fysiks (Post 1075640)
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

z3rongod 02-02-2010 03:24

Re: Command Unknowned. Where did i go wrong?
 
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!


All times are GMT -4. The time now is 07:23.

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