CMD:mc(playerid,params[])
{
new string[128], targetplayer;
if(sscanf(params, "i", targetplayer)) return SendClientMessage(playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]");
else
{
format(string, 128, "Player Checks:");
if (APlayerData[targetplayer][JobStarted] == true)
{
format(string, 128, "On a mission: {66FF00}Yes");
}
else
format(string, 128, "On a mission: {FF0000}No");
if(APlayerData[targetplayer][MafiaLoad] == true)
{
format(string, 128, "Maffia load: {66FF00}Yes");
}
else
format(string, 128, "Maffia load: {FF0000}No");
if (APlayerData[targetplayer][Overloaded] == true)
{
format(string, 128, "Overloaded: {66FF00}Yes");
}
else
format(string, 128, "Overloaded: {FF0000}No");
SendClientMessage(playerid, 0xFFFFFFFF, string);
}
return 1;
}
CMD:mc( playerid, params[ ] )
{
new Str_mission[ 32 ], Str_maffia[ 32 ], Str_overloaded[ 32 ], msg[ 128 ], targetplayer;
if( sscanf( params, "r", targetplayer )) return SendClientMessage( playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]" );
if( APlayerData[ targetplayer ][ JobStarted ] == true ) format( Str_mission, sizeof( Str_mission ), "On a mission: {66FF00}Yes" );
else format( Str_mission, sizeof( Str_mission ), "On a mission: {FF0000}No" );
if( APlayerData[ targetplayer ][ MafiaLoad ] == true ) format( Str_maffia, sizeof( Str_maffia ), "Maffia load: {66FF00}Yes" );
else format( Str_maffia, sizeof( Str_maffia ), "Maffia load: {FF0000}No" );
if( APlayerData[ targetplayer ][ Overloaded ] == true ) format( Str_overloaded, sizeof( Str_overloaded ), "Overloaded: {66FF00}Yes" );
else format( Str_overloaded, sizeof( Str_overloaded ), "Overloaded: {FF0000}No" );
strcat( msg, "Player Checks:" );
strcat( msg, Str_mission );
strcat( msg, Str_maffia );
strcat( msg, Str_overloaded );
SendClientMessage( playerid, 0xFFFFFFFF, msg );
return 1;
}
[pawn]
"I'm new in scripting so, an explanation is helpful" |
CMD:mc( playerid, params[ ] ) // Command
{
new Str_mission[ 32 ], // a string of 32 Chatacters for the 'On mission' (Yes/No)
Str_maffia[ 32 ], // a string of 32 Chatacters for the 'On maffia' (Yes/No)
Str_overloaded[ 32 ], // a string of 32 Chatacters for the 'Overloaded' (Yes/No)
msg[ 128 ], // A string that we will send the message
targetplayer; // 'playerid' Variable
if( sscanf( params, "r", targetplayer )) return SendClientMessage( playerid, 0xFFFFFFFF, "[USAGE]: /mc [id]" );
// Sscanf parameter for '/mc [ID/Part Of Name]'
if( APlayerData[ targetplayer ][ JobStarted ] == true ) format( Str_mission, sizeof( Str_mission ), " On a mission: {66FF00}Yes " );
else format( Str_mission, sizeof( Str_mission ), " On a mission: {FF0000}No " );
// if the JobStarted is true it store at the 'Str_mission' Variable the text: On a mission: {66FF00}Yes
// Else it stores the text: On a mission: {FF0000}No
if( APlayerData[ targetplayer ][ MafiaLoad ] == true ) format( Str_maffia, sizeof( Str_maffia ), " Maffia load: {66FF00}Yes " );
else format( Str_maffia, sizeof( Str_maffia ), " Maffia load: {FF0000}No " );
// if the MafiaLoad is true it store at the 'Str_maffia' Variable the text: Maffia load: {66FF00}Yes
// Else it stores the text: Maffia load: {FF0000}No
if( APlayerData[ targetplayer ][ Overloaded ] == true ) format( Str_overloaded, sizeof( Str_overloaded ), " Overloaded: {66FF00}Yes " );
else format( Str_overloaded, sizeof( Str_overloaded ), " Overloaded: {FF0000}No " );
// if the MafiaLoad is true it store at the 'Overloaded' Variable the text: Overloaded: {66FF00}Yes
// Else it stores the text: Overloaded: {FF0000}No
// strcat: This function concatenates two strings into the destination reference
strcat( msg, "Player Checks: " ); // The first message
strcat( msg, Str_mission ); // then the message we stored at the Str_mission Variable
strcat( msg, Str_maffia ); // then the message we stored at the Str_maffia Variable
strcat( msg, Str_overloaded ); // and then the message we stored at the Str_overloaded Variable
SendClientMessage( playerid, 0xFFFFFFFF, msg );
// Last, we send the message that it's the 'msg' and we cat the messages before and it concatenates them
return 1;
}
// Result: 'Player Checks: On a mission: {Yes/No} Maffia load: {Yes/No} Overloaded: {Yes/No} '