Messageplayer help?

Started by DontKnowScripting:(, May 06, 2015, 08:12 AM

Previous topic - Next topic

DontKnowScripting:(

I'm getting error at message player actually this script is taken from adm then I changed Emessage to messageplayer


else if ( cmd == "kick" )
{
   if ( pstats[ player.ID ].Level < 3 ) MessagePlayer( "Error - You don't have access to it.", player);
   else if ( !text ) MessagePlayer( "Error - Syntax: /kick <player> <reason>", player);
   else
   {
     local plr = GetPlayer( GetTok( text, " ", 1 ) );
     if ( !plr ) MessagePlayer( "Error - Unknown player.", player);
     else
     {
       local reason = GetTok( text, " ", 2 );
   if ( !reason ) reason = "None";
   MessagePlayer( "" + plr.Name + " have been kicked. Reason: " + reason + "" );
   plr.Kick();
     }
   }
}





Thijn

......

What is the error?


.

#3
You're missing the player instance. Without it the function doesn't know to which player to send the message. Currently you're using it like this:
function onPlayerCommand(some_player, command, arguments)
{
    MessagePlayer("This is my message!") // But who receives this message?
}

Correct usage would be like this:
function onPlayerCommand(some_player, command, arguments)
{
    MessagePlayer(some_player, "This is my message!") // some_player receives this message.
}

The error message even warns you that you have an incorrect number of arguments. Which means that you're either not passing sufficient arguments or you simply give it more it's expecting. In your case it's the first one.
.


SAzEe21

MessagePlayer( "" + plr.Name + " have been kicked. Reason: " + reason + "" );

Change this MessagePlayer to eMessage or rMessage.

KingOfVC

Quote from: Zeeshan.Bhatti on Jun 24, 2015, 12:18 PMMessagePlayer( "" + plr.Name + " have been kicked. Reason: " + reason + "" );

You forgot 'player', it should be
MessagePlayer( "" + plr.Name + " have been kicked. Reason: " + reason + "" ,player);

[VSS]Shawn

U Forget Player Use This
MessagePlayer( "" + plr.Name + " have been kicked. Reason: " + reason + ".", player  );

.

Didn't anyone notice that the last reply to this topic was "49 days ago" and that the topic was solved ? WTF is wrong with you people?
.