Raised This Month: $ Target: $400
 0% 

Name contain


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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