21.07.2015, 12:46
How i can make "Name Command", like: CMD:ban just player whit nick HaZZe can use this command.
new string[36];
GetPlayerName(playerid,string,MAX_PLAYER_NAME);
if((strfind(string, "HaZZe", true) != -1))
CMD:ban(playerid, params[])
{
if((strcmp(GetPName(playerid), "HaZZe") != 0)) return 0;
/// rest of your code
return 1;
}
CMD:ban( ESS ) { if( strfind( GetPName( playerid ), "HaZZe." ) == -1 ) return 1; }
CMD:ban(playerid, params[]) { if((strcmp(GetPName(playerid), "HaZZe") != 0)) return 0; return 1; }
Код:
CMD:ban(playerid, params[]) { if((strcmp(GetPName(playerid), "HaZZe") != 0)) return 0; return 1; } |
CMD:ban( ESS ) { new a_r[ 102 ]; PLogin( playerid ); if((strcmp(PName(playerid), "HaZZe.") != 0)) return Eroare(playerid, "Just HaZZe. can use this command!"); new Player, Reason[100], Days; if( sscanf( params, "uis[100]", Player, Days, Reason ) ) return Functie( playerid, "/ban [ID Jucator] [Zi(le)] [Motiv]", "Banezi un jucator specificat de tine. [Motiv Obligatoriu!]" ); if( Player == INVALID_PLAYER_ID ) return Eroare( playerid, "Jucatorul nu este conectat." ); PImun( playerid, Player ); if( Player == playerid ) return Eroare( playerid, "Nu iti poti da Ban ti-e insuti." ); if ( Days < 1 || Days > 30 ) return Eroare( playerid, "Zi invalida ! Poti doar intre 1 si 30 de zile." ); AdminCMD( playerid, "Ban" ); new d_d, d_m, d_y, t_h, t_m, t_s; getdate( d_y, d_m, d_d ); gettime( t_h, t_m, t_s ); new year, month, day; getdate( year, month, day ); day += Days; if ( IsMonth31( month ) ) { if ( day > 31 ) { month += 1; if ( month > 12 ) { year += 1; while( day > 31 ) day -= 31; } else while( day > 31 ) day -= 31; } } else if ( !IsMonth31( month ) ) { if ( day > 30 ) { month += 1; if ( month > 12 ) { year += 1; while( day > 30 ) day -= 30; } else while( day > 30 ) day -= 30; } } else if ( !IsMonth31( month ) && IsMonth29( year ) && month == 2 ) { if ( day > 29 ) { month += 1; if ( month > 12 ) { year += 1; while( day > 29 ) day -= 29; } else while( day > 29 ) day -= 29; } } else if ( !IsMonth31( month ) && !IsMonth29( year ) && month == 2 ) { if ( day > 28 ) { month += 1; if ( month > 12 ) { year += 1; while( day > 28 ) day -= 28; } else while( day > 28 ) day -= 28; } } for( new i = 0; i < 50; i ++ ) SendClientMessage( Player, -1,"" ); SendClientMessage( Player, 0xC0FF00AA, "============================" ); MSGToOne( Player, 0xFF0000AA, "** {FFFFFF}Ai fost banat de catre {99FFFF}%s{FFFFFF}.", PName( playerid ) ); MSGToOne( Player, 0xFF0000AA, "* {99FFFF}Cu motivul: {FFFFFF}%s", Reason ); MSGToOne( Player, 0xFF0000AA, "* {99FFFF}Pana pe data: {FFFFFF}%d/%d/%d", day, month, year ); MSGToOne( Player, 0xFF0000AA, "* {99FFFF}Data banarii: {FFFFFF}%d/%d/%d", d_d, d_m, d_y ); MSGToOne( Player, 0xFF0000AA, "* {99FFFF}Ora banarii: {FFFFFF}%d:%d:%d", t_h, t_m, t_s ); MSGToOne( Player, 0xFF0000AA, "* {99FFFF}Un-Ban automat dupa data: {FFFFFF}%d/%d/%d", day, month, year ); SendClientMessage( Player, 0xC0FF00AA, "============================" ); MSGToAll( 0xFFFFFFAA, "{99FFFF}%s {FFFFFF}a fost banat de catre {99FFFF}%s. {FFFFFF}Motiv: {99FFFF}%s", PName( Player ), PName( playerid ), Reason ); format( aswstring, sizeof( aswstring ), "%s a fost banat de catre %s. Motiv: %s", PName( Player ), PName( playerid ), Reason ); Log_( "Log_Ban", "Text", aswstring ); new Security[ 200 ]; mysql_escape_string( Reason, Security ); format( query, sizeof( query ), "INSERT INTO `Banned` VALUES(0, '%s', '%s', '%s', '%s', '%d-%d-%d', '%d:%d:%d', '%d/%d/%d')", GetPlayerIpEx( Player ), PName( Player ), Security, PName( playerid ), d_y, d_m, d_d, t_h, t_m, t_s, day, month, year ); mysql_pquery( DBH, query, "", "" ); if( PI[ Player ][ Level ] >= 1 ) { format( aswstring, sizeof( aswstring ), "%s a incalcat regula ! /ban -> %s", PName( playerid ), PName( Player ) ); Log_( "Log_AtoA", "Text", aswstring ); Informatie( playerid, "Upps, vezi ca ai incalcat ce-a mai importanta Regula ca admin !" ); } SetTimerEx( "KickPlayer", 500, false, "i", Player ); return ( 1 ); }