Raised This Month: $ Target: $400
 0% 

Name contain


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 03-30-2014 , 14:11   Name contain
Reply With Quote #1

I want to check if there is players with a similar name as the player i am using the command on.. I want to be able to type for example /ban Chu, if the player i am going to ban's name is "Chuck", but if there are other people on the server which names contains Chu, it will give an error message saying there are too many people with a similar name, and that you should provide more information. I know you are supposed to use "strlen" and a for loop in some way.. But i can't figure out how. So.. Run the command if the part of the name entered is unique and nobody else currently on the server has it, but give an error if someone else has a name which contains for example "Chu" . How do i do this? Thanks.

note:
I do not want to check specific names in the code itself, i want this to work on whatever player you use it on

Just made this quickly, i know it has alot of flaws in it's code and looks bad, and you don't need to fix that for me, i just made this quickly and haven't really cleared it up from junk and i will do that later.. But you get the point. The comment is where i want to check.

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

new const File[ ] = "addons/amxmodx/Reportlog.html"
new const szPREFIX[ ] = "[AMXX]"


public plugin_init( )
{
    
register_plugin"Report Player""1.0""BuckShot" )
    
register_clcmd"say ""PlayerReport" )
}

public 
PlayerReportid )
{
    new 
String192 ], Command10 ]
    
read_argsString191 )
    
remove_quotes(String)
    
strbreakStringCommand9String191 )
    
    if( !
equaliCommand"/report" ) )
    {
        return 
PLUGIN_HANDLED;
    }
    new 
Name32 ], Reason154 ], WriteToFile600 ]

    
strbreakStringNamesizeofName ), Reason153 )
    if( 
strlenName ) == )
    {
        
ColorChatidGREEN"%s^x01 Example Usage:^x04 /Report ^"Michael^" ^"He is using Aimbot^""szPREFIX )
        return 
PLUGIN_HANDLED;
    }
    
    new 
Players32 ], pnumPlayer
    
new num 0;
    
get_playersPlayerspnum )
    for(new 
0pnumi++)
    {
        
num++
        
Player Players]
        new 
szName32 ]
        
get_user_namePlayerszName32 )
        
        if(
containiszName ), Name ) ) // here is where i want to check it.. I wanna check if there are other players with a similar part of the name as in the "Name" variable here, if there's not, continue. Else give an error
        
{
            continue;
        }
        else if( 
pnum == num )
        {
            
ColorChat(idGREEN"This player doesnt exist" )
            return 
PLUGIN_HANDLED;
        }
    }
    
num 0;
    if( 
strlenReason ) < )
    {
        
ColorChatidGREEN"%s^x01 Please supply more information about the player"szPREFIX )
        return 
PLUGIN_HANDLED;
    }
    new 
Authid32 ], Ip32 ]
    
get_user_authidPlayerAuthid31 )
    
get_user_ipPlayerIp311)
    new 
Name232 ], Authid232 ], Ip232 ]
    
get_user_nameidName231 )
    
get_user_authididAuthid231 )
    
get_user_ipidIp2311)
    
    static 
Time21 ], InputTime64 ]
    
get_time("%Y/%m/%d - %H:%M:%S"Time20);
    
    
formatexInputTime63"<font color=^"blue^"><b>Time:</b></font> %s<br>"Time )
    
formatexWriteToFile599"<font color=^"red^"><b>Reported player:</font></b> %s<br><b><font color=^"red^">Reason:</font></b> %s<br><b><font color=^"red^">SteamID:</font></b> %s<br><b><font color=^"red^">IP:</font></b> %s</font><br><font color=^"green^"><b>Player who reported:</font></b> %s<br><b><font color=^"green^">SteamID:</font></b> %s<br><b><font color=^"green^">IP:</b></font> %s<br>_____________________________<br><br>"NameReasonAuthidIpName2Authid2Ip2 )
    
ColorChatidGREEN"%s^x01 Thank you! Your abuse report has been recieved"szPREFIX )
    
    
write_fileFileInputTime, -)
    
write_fileFileWriteToFile, -)
    return 
PLUGIN_HANDLED;

__________________
PM me for private work.



Last edited by Buckshot; 03-30-2014 at 14:33.
Buckshot is offline
Send a message via Skype™ to Buckshot
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-30-2014 , 14:44   Re: Name contain
Reply With Quote #2

cmd_target()
__________________
fysiks is offline
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 03-30-2014 , 14:47   Re: Name contain
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
cmd_target()
That doesn't really tell me anything.. :/ The main problem i'm having is finding a way to loop through players and check if theres anyone which's name contains the value of the Name variable, and if more than 1 player has that part of the name, it's gonna obviously just give an error.. And continue if it's an unique name
__________________
PM me for private work.



Last edited by Buckshot; 03-30-2014 at 14:52.
Buckshot is offline
Send a message via Skype™ to Buckshot
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-30-2014 , 15:06   Re: Name contain
Reply With Quote #4

cmd_target does exactly that
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Old 03-30-2014, 15:14
Buckshot
This message has been deleted by Buckshot. Reason: Never mind. Thanks for help :)
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 03-31-2014 , 15:36   Re: Name contain
Reply With Quote #5

Still can't get it working really though.. Having some problems here. What am i doing wrong? I'm only getting "Player not found" message

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

new const File[ ] = "addons/amxmodx/Reportlog.txt"
new const szPREFIX[ ] = "[AMXX]"


public plugin_init( )
{
    
register_plugin"Report Player""1.0""BuckShot" )
    
register_clcmd"say ""PlayerReport" )
}

public 
PlayerReportid )
{
    new 
String192 ], Command10 ]
    
read_argsString191 )
    
remove_quotes( String )
    
strbreakStringCommand9String191 )
    
    if( !
equaliCommand"/report" ) )
    {
        return;
    }
    new 
Name32 ], Reason154 ]

    
strbreakStringNamesizeofName ), Reason153 )
    if(
strlen(Name) == 0)
    {
        
ColorChatidGREEN"%s^x01 Example Usage:^x04 /Report ^"Michael^" ^"He is using Aimbot^""szPREFIX )
        return;
    }
    
    new 
Player cmd_targetidName )
    
    if( !
Player )
    {
        
ColorChatidGREEN"%s^x01 Player not found"szPREFIX )
        return;
    }
    
    if( 
strlenReason ) < 6)
    {
        
ColorChatidGREEN"%s^x01 Please supply more information about the player"szPREFIX )
        return;
    }
    
    
ColorChatidGREEN"%s^x01 Thank you! Your abuse report has been recieved"szPREFIX )
    new 
szName32 ], szAuthid32 ], szOutput300 ]
    
get_user_namePlayerszName31 )
    
get_user_authidPlayerszAuthid31 )
    
formatexszOutput299"Name: %s^n SteamID: %s^n Reason: %s^n"szNameszAuthidReason )
    
    
write_fileFileszOutput, -)

__________________
PM me for private work.



Last edited by Buckshot; 03-31-2014 at 15:44.
Buckshot is offline
Send a message via Skype™ to Buckshot
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-31-2014 , 15:42   Re: Name contain
Reply With Quote #6

Code:
/* Flags:
*  1 - obey immunity
*  2 - allow yourself
*  4 - must be alive
*  8 - can't be bot */
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
#define CMDTARGET_ALLOW_SELF	(1<<1)
#define CMDTARGET_ONLY_ALIVE	(1<<2)
#define CMDTARGET_NO_BOTS		(1<<3)
stock cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY)
Are you perhaps using it on yourself or using it on someone with immunity?
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 03-31-2014 at 15:43.
YamiKaitou is offline
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 03-31-2014 , 15:46   Re: Name contain
Reply With Quote #7

Quote:
Originally Posted by YamiKaitou View Post
Code:
/* Flags:
*  1 - obey immunity
*  2 - allow yourself
*  4 - must be alive
*  8 - can't be bot */
#define CMDTARGET_OBEY_IMMUNITY (1<<0)
#define CMDTARGET_ALLOW_SELF	(1<<1)
#define CMDTARGET_ONLY_ALIVE	(1<<2)
#define CMDTARGET_NO_BOTS		(1<<3)
stock cmd_target(id,const arg[],flags = CMDTARGET_OBEY_IMMUNITY)
Are you perhaps using it on yourself or using it on someone with immunity?
I am trying it out with bots currently. Don't got those people who will come to my server whenever i need them to, and test stuff out with me. The bots haven't been given any immunity either... I find this strange because i can't really see any errors in the code myself, but it doesn't work correctly still.. Usually i find whatever the problem is, even if it is a big code.. I should be able to find it in a code which is as small as this
__________________
PM me for private work.



Last edited by Buckshot; 03-31-2014 at 15:55.
Buckshot is offline
Send a message via Skype™ to Buckshot
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 03-31-2014 , 15:57   Re: Name contain
Reply With Quote #8

Code:
] say "/report Rose He sucks"
[AMXX] Thank you! Your abuse report has been recieved
[ --{-@ ] Black Rose :  /report Rose He sucks
Working for me.
All I did was add CMDTARGET_ALLOW_SELF to cmd_target() because I also have nobody to test with.

Maybe you are getting multiple matches, because that would produce the same error.
Say your bots are named Bob1 and Bob2, cmd_target can't pick one if you just write "Bob" and will return 0.
__________________

Last edited by Black Rose; 03-31-2014 at 16:00.
Black Rose is offline
Buckshot
Senior Member
Join Date: Mar 2014
Location: Sweden
Old 03-31-2014 , 16:01   Re: Name contain
Reply With Quote #9

Quote:
Originally Posted by Black Rose View Post
Code:
] say "/report Rose He sucks"
[AMXX] Thank you! Your abuse report has been recieved
[ --{-@ ] Black Rose :  /report Rose He sucks
Working for me.
All I did was add CMDTARGET_ALLOW_SELF to cmd_target() because I also have nobody to test with.
Yeah i enabled debugging on it just now, and now it seems to be working.. Don't see why i would have to enable debugging though. A bug in the debug? But problem is solved now i guess. Thanks again guys. I will probably come back with more random threads some other day with questions, only because i do not have any active pawn coder buddies to ask. You could add me on steam if you need help with testing by the way.
__________________
PM me for private work.



Last edited by Buckshot; 03-31-2014 at 16:05.
Buckshot is offline
Send a message via Skype™ to Buckshot
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 06:01.


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