PDA

View Full Version : %s Mini Help Nedded


Gooday
15/03/2012, 12:54 PM
//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)

T0pAz
15/03/2012, 12:58 PM
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);
}

BigETI
15/03/2012, 01:00 PM
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:
format(string, sizeof string, "You have stunned %s.", Victim);
Send this message to issuerid and you are done.

Gooday
15/03/2012, 01:20 PM
also:

//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!

T0pAz
15/03/2012, 01:27 PM
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);
}

Issam
15/03/2012, 01:28 PM
add:
new string2[60], suspect[MAX_PLAYER_NAME]
GetPlayerName( playerid, suspect, MAX_PLAYER_NAME );
and replace this
SendClientMessage(playerid, COLOR_GOLD, "(INFO) Player Cuffed succesfully.");
with this:
format( string2, sizeof(string2), "(INFO)%s have been cuffed succesfully.", suspect);
SendClientMessage(playerid, COLOR_GOLD, string2);

Edit: He was faster :)