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 PlayerReport( id )
{
new String[ 192 ], Command[ 10 ]
read_args( String, 191 )
remove_quotes(String)
strbreak( String, Command, 9, String, 191 )
if( !equali( Command, "/report" ) )
{
return PLUGIN_HANDLED;
}
new Name[ 32 ], Reason[ 154 ], WriteToFile[ 600 ]
strbreak( String, Name, sizeof( Name ), Reason, 153 )
if( strlen( Name ) == 0 )
{
ColorChat( id, GREEN, "%s^x01 Example Usage:^x04 /Report ^"Michael^" ^"He is using Aimbot^"", szPREFIX )
return PLUGIN_HANDLED;
}
new Players[ 32 ], pnum, Player
new num = 0;
get_players( Players, pnum )
for(new i = 0; i < pnum; i++)
{
num++
Player = Players[ i ]
new szName[ 32 ]
get_user_name( Player, szName, 32 )
if(containi( szName ), 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(id, GREEN, "This player doesnt exist" )
return PLUGIN_HANDLED;
}
}
num = 0;
if( strlen( Reason ) < 6 )
{
ColorChat( id, GREEN, "%s^x01 Please supply more information about the player", szPREFIX )
return PLUGIN_HANDLED;
}
new Authid[ 32 ], Ip[ 32 ]
get_user_authid( Player, Authid, 31 )
get_user_ip( Player, Ip, 31, 1)
new Name2[ 32 ], Authid2[ 32 ], Ip2[ 32 ]
get_user_name( id, Name2, 31 )
get_user_authid( id, Authid2, 31 )
get_user_ip( id, Ip2, 31, 1)
static Time[ 21 ], InputTime[ 64 ]
get_time("%Y/%m/%d - %H:%M:%S", Time, 20);
formatex( InputTime, 63, "<font color=^"blue^"><b>Time:</b></font> %s<br>", Time )
formatex( WriteToFile, 599, "<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>", Name, Reason, Authid, Ip, Name2, Authid2, Ip2 )
ColorChat( id, GREEN, "%s^x01 Thank you! Your abuse report has been recieved", szPREFIX )
write_file( File, InputTime, -1 )
write_file( File, WriteToFile, -1 )
return PLUGIN_HANDLED;
}
__________________