%s Mini Help Nedded
#1

pawn Код:
//Baton Detect
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(GetPlayerWeapon(issuerid) == 3)
        {
           new string[50],Attacker[MAX_PLAYERS];
           GetPlayerName(issuerid, Attacker, sizeof (Attacker));
           format(string, sizeof(string), "(INFO) You have been stunned by Officer %s.", Attacker);
           SendClientMessage(playerid, COLOR_GOLD, string);
           SetPlayerColor(playerid, COLOR_LIGHTGREEN);
           SetTimerEx("timer_stunned",20000,false,"i",playerid);
           TogglePlayerControllable(playerid, 0);
        }
    }
    return 1;
}
I want send a message to the "attacker" too with You have stunned %S (<- Issued player name)
Reply
#2

pawn Код:
public OnPlayerTakeDamage( playerid, issuerid, Float:amount, weaponid )
{
    if ( issuerid != INVALID_PLAYER_ID )
    {
        if ( GetPlayerWeapon( issuerid ) == 3 )
        {
            new string[50], Attacker[MAX_PLAYER_NAME], pzName[MAX_PLAYER_NAME];
            GetPlayerName( issuerid, Attacker, sizeof(Attacker) );
            GetPlayerName( playerid, pzName, MAX_PLAYER_NAME );
            format( string, sizeof(string), "(INFO) You have been stunned by Officer %s.", Attacker );
            SendClientMessage( playerid, COLOR_GOLD, string );
            format( string, sizeof(string), "(INFO) You have stunned %s.", pzName );
            SendClientMessage( issuerid, COLOR_GOLD, string );
            SetPlayerColor( playerid, COLOR_LIGHTGREEN );
            SetTimerEx( "timer_stunned", 20000, false, "i", playerid );
            TogglePlayerControllable( playerid, 0 );
        }
    }
    return(1);
}
Reply
#3

First of all declarate Attacker[MAX_PLAYER_NAME] and not Attacker[MAX_PLAYERS] (MAX_PLAYER_NAME is a definition of the value 24 and MAX_PLAYERS of 500)

Second declarate an array (Victim[MAX_PLAYER_NAME]), get its name by using GetPlayerName and do a second format after the SendClientMessage for example:
pawn Код:
format(string, sizeof string, "You have stunned %s.", Victim);
Send this message to issuerid and you are done.
Reply
#4

also:

pawn Код:
//Cuff and Uncuff
CMD:cuff(playerid, params[])
{
    new id;
    if (sscanf(params, "u", id)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /Cuff [ID]");
    if(GetPlayerSkin(playerid) == 285 || GetPlayerSkin(playerid) == 282 || GetPlayerSkin(playerid) == 281 || GetPlayerSkin(playerid) == 283 || GetPlayerSkin(playerid) == 288)
    if(GetDistanceBetweenPlayers(playerid,id)> 2)return SendClientMessage(playerid,COLOR_RED,"(INFO) You are to far from that player");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "(INFO) Player not found");
    else
    {
        SendClientMessage(id, COLOR_GOLD, "(INFO) You have been Cuffed by a BCSD Officer.");
        SendClientMessage(id, COLOR_GOLD, "(INFO) Your weapons were been confiscated.");
        ResetPlayerWeapons(id);
        SetCameraBehindPlayer(id);
        SendClientMessage(playerid, COLOR_GOLD, "(INFO) Player Cuffed succesfully.");
        TogglePlayerControllable(id, 0);
    }
    return 1;
}
hOW can i replace "player cuffed succesfully" with "you have cuffed %s" and the same for the cuffed "you have been cuffed by %s" +REP!
Reply
#5

pawn Код:
CMD:cuff( playerid, params[] )
{
    new id, pzName[24], suszName[24], stz[64];
    if ( sscanf( params, "u", id ) ) SendClientMessage( playerid, COLOR_LIGHTBLUE, "Usage: /Cuff [ID]" );
    if ( GetPlayerSkin( playerid ) == 285 || GetPlayerSkin( playerid ) == 282 || GetPlayerSkin( playerid ) == 281 || GetPlayerSkin( playerid ) == 283 || GetPlayerSkin( playerid ) == 288 )
    {  
        if ( GetDistanceBetweenPlayers( playerid, id ) > 2 ) return(SendClientMessage( playerid, COLOR_RED, "(INFO) You are to far from that player" ) );
        else if ( id == INVALID_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "(INFO) Player not found" );
        else
        {
            GetPlayerName( id, suszName, 24 );
            GetPlayerName( playerid, pzName, 24 );
            format( stz, 64, "(INFO) You have been Cuffed by %s.", pzName ); SendClientMessage( id, COLOR_GOLD, stz );
            format( stz, 64, "(INFO) You have cuffed %s.", suszName ); SendClientMessage( playerid, COLOR_GOLD, stz );
            SendClientMessage( id, COLOR_GOLD, "(INFO) Your weapons were been confiscated." );
            ResetPlayerWeapons( id );
            SetCameraBehindPlayer( id );
            TogglePlayerControllable( id, 0 );
        }
    }
    return(1);
}
Reply
#6

add:
pawn Код:
new string2[60], suspect[MAX_PLAYER_NAME]
pawn Код:
GetPlayerName( playerid, suspect, MAX_PLAYER_NAME );
and replace this
pawn Код:
SendClientMessage(playerid, COLOR_GOLD, "(INFO) Player Cuffed succesfully.");
with this:
pawn Код:
format( string2, sizeof(string2), "(INFO)%s have been cuffed succesfully.", suspect);
pawn Код:
SendClientMessage(playerid, COLOR_GOLD, string2);
Edit: He was faster
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)