AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get victim name? (https://forums.alliedmods.net/showthread.php?t=306970)

pyresdiablo 04-21-2018 06:06

How to get victim name?
 
Hey, I am creating this plugin which blocks vote command from console, but i want to show the people in the server that who is using the command and who is the victim.
I was able to get users name using get_user_id but how do i get victim's name?
thank you.

Bugsy 04-21-2018 07:54

Re: How to get victim name?
 
Can you clarify victim? Do you mean dead player? Give an example of what you're trying to do

pyresdiablo 04-21-2018 08:05

Re: How to get victim name?
 
I mean, there is a command for client called "vote".
when a player types vote in console a list of joined players with #number appears.
they can use the command to kick people like
vote #113.
I have disabled that command but want to print the message in chat as
User1(voter) is trying to kick User2(Victim).
I have got user1's ID but dont know how to get user2's.

Natsheh 04-24-2018 05:31

Re: How to get victim name?
 
Check find_player API or cmd_target

pyresdiablo 04-28-2018 05:56

Re: How to get victim name?
 
Can you give an example?

Relaxing 04-28-2018 06:55

Re: How to get victim name?
 
If the hash code(#123) is the actual user id, then just get the name using this value.
Code:
new userid2 = 456, ui2[32] get_user_name(userid2, ui2, charsmax(ui2))

Bugsy 04-28-2018 11:47

Re: How to get victim name?
 
@Relaxing that will not work. get_user_name() expects a 1-32 client id.

PHP Code:


#include <amxmodx>
#include <amxmisc>

public plugin_init() 
{
    
register_concmd"vote" "VoteConCmd" );
}

public 
VoteConCmdid )
{
    new 
szArg32 ] , iVictim szVoter32 ];
    
    
read_argvszArg charsmaxszArg ) );
    
iVictim cmd_targetid szArg );
    
    if ( 
iVictim )
    {
        
get_user_nameid szVoter charsmaxszVoter ) );
        
get_user_nameiVictim szArg charsmaxszArg ) );
        
        
console_printid "%s voted %s" szVoter szArg);
    }




All times are GMT -4. The time now is 04:43.

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