Quote from: [ss]keLvin_ on Sep 26, 2020, 10:15 PMyou could do something like this:Code SelectplayerProfession <- array( GetMaxPlayers(), 0 ); // 0 for no profession.
function getPlayerProfessionName( player )
{
switch( playerProfession[ player.ID ] )
{
case 1:
return "Police Officer";
case 2:
return "Firefighter";
case 3:
return "Paramedic";
}
return "Citizen";
}
function onPlayerChat( player, message )
{
Message( format( "[%s] %s: %s", getPlayerProfessionName( player ), player.Name, message ) );
return 0;
}
function onPlayerPart( player, reason )
{
playerProfession[ player.ID ] = 0;
}
all you have to do is to assign players a profession anytime using:Code SelectplayerProfession[ player ID ] = profession ID;
for example:Code Selectfunction onPlayerCommand( player, command, arguments )
{
if ( command == "cop" )
{
playerProfession[ player.ID ] = 1;
PrivMessage( player, "You are now a Police Officer!" );
}
}
Your code doesn't seem to work if
error:
AN ERROR HAS OCCURED [the index 'message' does not exist]
CALLSTACK
*FUNCTION [onPlayerChat()] scripts/main.nut line [337]
LOCALS
[text] "32"
[player] INSTANCE
[this] TABLE
and my privatechat for Emergency services doesn't seem to work it doesn't give an error that is pretty weird when I remove the getplayerprofession it works fine but it doesn't show the profession.
MessagePlayer("[#A42F2B][Emergency-Chat] " +getplayerProfession+ " "+player.Name+ ":[#0CF4D4] " + text + "", plr);