AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I find a target? (https://forums.alliedmods.net/showthread.php?t=185519)

Boyka Abi 05-18-2012 15:05

How can I find a target?
 
Hi people, as you can see im asking a really simple question. I wanna make a command like for example u say !kick (name) in the chat that user will get kicked, but I dont know how to find the target

<VeCo> 05-18-2012 15:13

Re: How can I find a target?
 
find_target

Boyka Abi 05-18-2012 15:21

Re: How can I find a target?
 
Quote:

Originally Posted by <VeCo> (Post 1711590)
find_target

I still dont get it, how will I find the target by typing it, for example in the chat: !kick (name)

wickedd 05-18-2012 15:29

Re: How can I find a target?
 
Take a look at this. player menu

<VeCo> 05-18-2012 15:33

Re: How can I find a target?
 
Read the second argument from the chat command (read_argv or read_args natives) and use that arg in the cmd_target native (accepts username and #userid).

My mistake : it's cmd_target, not find_target.

Boyka Abi 05-18-2012 15:37

Re: How can I find a target?
 
I've tryed

PHP Code:

public Cmdsay(id)
{
    new 
message[194]
    
read_args(messagecharsmax(message))
    
remove_quotes(message)
    
    if (
containi(message"!slap") == 0)
    {
        
strbreak(message""0messagecharsmax(message))
        
        new 
arg[35]
        
strbreak(messageargcharsmax(arg), messagecharsmax(message))
        
        
trim(arg)
        
trim(message)
        
        if (
arg[0] && message[0])
        {
            new 
target cmd_target(idarg0)
            
            new 
name[32], name2[32]
            
get_user_name(idname31)
            
get_user_name(targetname231)
            
            if (
target)
            {
                
user_slap(target0)
                
ColorChat(0GREY"%s ^4%s^4 has slapped ^4%s"Prefixnamename2)
            }
            else if (!
target)
            {
                
ColorChat(idGREY"%s ^1Couldn't find player: %s"Prefixarg)
            }
        }
    }


Cant make this to work.

Boyka Abi 05-18-2012 18:58

Re: How can I find a target?
 
Hmm nevermind, can anyone help me and tell me what im doing wrong in this code.

PHP Code:

public Cmdsay(id)
{
    new 
message[192]
    
read_args(messagecharsmax(message))
    
remove_quotes(message)
    
    if (
equal(message"!slap"))
    {
        new 
arg[65]
        
read_args(argcharsmax(arg))
        
parse(messageargcharsmax(arg))
        
        new 
target cmd_target(idarg)
        
        new 
name[32], name2[32]
        
get_user_name(idname31)
        
get_user_name(targetname231)
        
        if (
target)
        {
            
user_slap(target0)
            
ColorChat(0GREY"%s ^4%s^1 has slapped ^4%s"Prefixnamename2)
        }
    }
    return 
PLUGIN_CONTINUE



Napoleon_be 05-18-2012 19:42

Re: How can I find a target?
 
you should use read_argv() instead. It can detect which word have been typed as first, second, third, ...

Boyka Abi 05-18-2012 20:01

Re: How can I find a target?
 
Already tryed that aint working either.

dias 05-18-2012 20:12

Re: How can I find a target?
 
Search "AMX Give AP" and you will see the example code


All times are GMT -4. The time now is 00:26.

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