printf
#1

hello i have this code and want the cmd saved in server_log but i got this errors


Код:
printf("(CMD) %s: %s",name_, cmdtext);
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    new
        msg_[ 64 ],
        name_[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
    format( msg_, sizeof( msg_ ), "(CMD) %s: %s", name_, cmdtext );

    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) || !IsPlayerAdmin( i ) ) continue;
        
        SendClientMessage( i, 0x754829AA, msg_ );
    }

    if( !success ) return 0;
    return 1;
}
PHP код:
 error 021symbol already defined"printf" 
Reply
#2

It must be inside the callback.
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    new
        msg_[ 64 ],
        name_[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
    format( msg_, sizeof( msg_ ), "(CMD) %s: %s", name_, cmdtext );
    print( msg_ );

    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) || !IsPlayerAdmin( i ) ) continue;
       
        SendClientMessage( i, 0x754829AA, msg_ );
    }

    if( !success ) return 0;
    return 1;
}
You've already format it, just print it! No need to use printf.
Reply
#3

Why do you put printf() on top of OnPlayerCommandPerformed()?
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It must be inside the callback.
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    new
        msg_[ 64 ],
        name_[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
    format( msg_, sizeof( msg_ ), "(CMD) %s: %s", name_, cmdtext );
    print( msg_ );

    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) || !IsPlayerAdmin( i ) ) continue;
       
        SendClientMessage( i, 0x754829AA, msg_ );
    }

    if( !success ) return 0;
    return 1;
}
You've already format it, just print it! No need to use printf.
Thank You Sir +rep
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It must be inside the callback.
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    new
        msg_[ 64 ],
        name_[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
    format( msg_, sizeof( msg_ ), "(CMD) %s: %s", name_, cmdtext );
    print( msg_ );

    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) || !IsPlayerAdmin( i ) ) continue;
       
        SendClientMessage( i, 0x754829AA, msg_ );
    }

    if( !success ) return 0;
    return 1;
}
You've already format it, just print it! No need to use printf.
sorry but can u help me with this code i want when i do clearchat i got message "Admin blalala has cleared the chat"
and sorry again for my suck english :/

Код:
CMD:clearchat(playerid,params[])
{
   if(!IsPlayerAdmin( playerid ) )return SCM( playerid, RED, "Unknown Command! Type /help" );
   
   for(new i = 0; i < 100; i++) SCMA(-1 ," ");
   
   return 1;
}
Reply
#6

Here you go
pawn Код:
CMD:clearchat(playerid,params[])
{
    if(!IsPlayerAdmin( playerid ) )return SCM( playerid, RED, "Unknown Command! Type /help" );

    for(new i = 0; i < 100; i++) { SCMA(-1 ," "); }

    new
        pString[ 128 ],
        PlayerName[ 24 ]
    ;
    GetPlayerName( playerid, PlayerName, sizeof( PlayerName ) );
    format(pString, sizeof( pString ), "");
    SCMA(-1, "%s(%d) Has cleared the chat box.", PlayerName, playerid );
    return 1;
}
Код:
This forum requires that you wait 240 seconds between posts. Please try again in 13 seconds. - shutup annoying fag
Reply
#7

pawn Код:
CMD:clearchat(playerid,params[])
{
    if(!IsPlayerAdmin( playerid ) ) return SCM( playerid, RED, "Unknown Command! Type /help" );
    for( new i = 0; i < 100; i++ ) SCMA( -1 , " " );
    new
        sz_msg[ 52 ]
    ;
    GetPlayerName( playerid, sz_msg, MAX_PLAYER_NAME );
    format( sz_msg, sizeof( sz_msg ), "Admin %s has cleared the chat", sz_msg );
    SendClientMessageToAll( 0xFF0000FF, sz_msg );  
    return 1;
}
Quote:
Originally Posted by pds2k12
Посмотреть сообщение
pawn Код:
CMD:clearchat(playerid,params[])
{
    if(!IsPlayerAdmin( playerid ) )return SCM( playerid, RED, "Unknown Command! Type /help" );

    for(new i = 0; i < 100; i++) { SCMA(-1 ," "); }

    new
        pString[ 128 ],
        PlayerName[ 24 ]
    ;
    GetPlayerName( playerid, PlayerName, sizeof( PlayerName ) );
    format(pString, sizeof( pString ), "");
    SCMA(-1, "%s(%d) Has cleared the chat box.", PlayerName, playerid );
    return 1;
}
I guess you were in a hurry! You used what the format should had to SCMA.
Reply
#8

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It must be inside the callback.
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    new
        msg_[ 64 ],
        name_[ MAX_PLAYER_NAME ]
    ;
    GetPlayerName( playerid, name_, MAX_PLAYER_NAME );
    format( msg_, sizeof( msg_ ), "(CMD) %s: %s", name_, cmdtext );
    print( msg_ );

    for(new i = 0; i < MAX_PLAYERS; i++ )
    {
        if( !IsPlayerConnected( i ) || !IsPlayerAdmin( i ) ) continue;
       
        SendClientMessage( i, 0x754829AA, msg_ );
    }

    if( !success ) return 0;
    return 1;
}
You've already format it, just print it! No need to use printf.
printf() is made for a reason you know.
Reply
#9

Quote:
Originally Posted by Djole1337
Посмотреть сообщение
printf() is made for a reason you know.
But in this case is pointless.

We formatted the message because we want to send it with a client message. There's not reason to pass arguments when we already got the formatted message. print will just print the already formatted message.
Reply
#10

formatted the message.. print.. printf...blalala i thing ill leave this hard shit and back to samp as a player
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)