Raised This Month: $51 Target: $400
 12% 

Pm Plugin - need help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
niiii
Member
Join Date: Sep 2013
Old 04-11-2015 , 19:06   Pm Plugin - need help
Reply With Quote #1

Hello, I got private message plugin, but I have a problem with it. It works like when somebody write /pm, then appears menu with player names, but if I am dead and I write /pm nothing happens, it works only if I am alive, please help. Next feature I would like to add is that admins can see pm messages... Can anybody please help me?

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "PM - Private Message"
#define VERSION "1.0"
#define AUTHOR "85filip58"

static const PREFIX[] = "[PM]"

new gidPlayer[33]; 

new const pm_sound[] = { "pivnicegamingeu/pm.wav" }

public plugin_init() 
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
   
   register_clcmd("say /pm", "cmd_privatemessage")
   register_clcmd("say_team /pm", "cmd_privatemessage")
   
   register_clcmd("PM", "cmd_player");
}

public cmd_privatemessage(id)
{
   static opcion[64]
   
   formatex(opcion, charsmax(opcion),"Vyber Hraca")
   new iMenu = menu_create(opcion, "cmd_privatemessage_handler")
   
   new players[32], pnum, tempid
   new szName[32], szTempid[10]
   
   get_players(players, pnum, "a")
   
   for( new i; i<pnum; i++ )
   {
      tempid = players[i]
      
      get_user_name(tempid, szName, 31)
      num_to_str(tempid, szTempid, 9)
      
      formatex(opcion, charsmax(opcion), "\w%s", szName)
      menu_additem(iMenu, opcion, szTempid, 0)
   }
   
   menu_display(id, iMenu)
   return PLUGIN_HANDLED
}

public cmd_privatemessage_handler(id, menu, item)
{
   if( item == MENU_EXIT )
   {
      menu_destroy(menu)
      return PLUGIN_HANDLED
   }
   
   new Data[6], Name[64]
   new Access, Callback
   menu_item_getinfo(menu, item, Access, Data,5, Name, 63, Callback)
   
   new tempid = str_to_num(Data)
   
   gidPlayer[id] = tempid
   client_cmd(id, "messagemode PM")
   
   menu_destroy(menu)
   return PLUGIN_HANDLED
}

public cmd_player(id)
{
   new say[300]
   read_args(say, charsmax(say))
   
   remove_quotes(say)
   
   if(equal(say, ""))
      return PLUGIN_HANDLED; 
      
   cmd_send_pm(id, say)   
   return PLUGIN_CONTINUE;
}

public cmd_send_pm(id, say[])
{
   new player = gidPlayer[id];
   
   printMessage(player, id, say)
   return PLUGIN_HANDLED;
}
stock printMessage(reciever, sender, const message[])
{
   new name[32];
   get_user_name(sender, name, charsmax(name))

   ColorChat(reciever, "!g%s !t%s !y: !g%s", PREFIX, name, message)
   client_cmd(reciever, "spk ^"%s^"", pm_sound)
}

stock ColorChat(const id, const input[], any:...) 
{
   new count = 1, players[ 32 ]
   static msg[ 191 ]
   vformat( msg, 190, input, 3 )
   
   replace_all( msg, 190, "!g", "^4" )
   replace_all( msg, 190, "!y", "^1" )
   replace_all( msg, 190, "!t", "^3" )

   if(id) players[ 0 ] = id; else get_players( players, count, "ch" )
   {
      for(new i = 0; i < count; i++)
      {
         if( is_user_connected( players[ i ] ) )
         {
            message_begin( MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[ i ] )  
            write_byte( players[ i ] )
            write_string( msg )
            message_end( )
         }
      }
   }
} 

public plugin_precache()
{
   precache_sound(pm_sound)
}

Last edited by niiii; 04-11-2015 at 19:24.
niiii is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 04-11-2015 , 20:35   Re: Pm Plugin - need help
Reply With Quote #2

Description

get_players - Returns a list of player indices.

Syntax
get_players ( players[32], &num, const flags = )


Notes
If specified, you can constrain which players are returned by flags:
"a" - Don't return dead players
"b" - Don't return alive players
"c" - Skip bots
"d" - Skip real players
"e" - Match with passed team
"f" - Match with part of name
"g" - Ignore case sensitivity

So just change it from

get_players(players, pnum, "a") // Skip dead players



get_players(players, pnum, "c") // Skip just bot

you may need to skip them ...
Freezo Begin is offline
niiii
Member
Join Date: Sep 2013
Old 04-11-2015 , 21:18   Re: Pm Plugin - need help
Reply With Quote #3

thank you, it works, but... how can I solve the second problem? I need that admins will see all pm messages :/

I also added line to
Code:
stock printMessage(reciever, sender, const message[])
{
   new name1[32];
   new name2[32];
   get_user_name(sender, name1, charsmax(name1))
   get_user_name(reciever, name2, charsmax(name2))
 
   ColorChat(sender, "!g%s !t%s !y-> !t%s !y: !g%s", PREFIX, name1, name2, message)
   ColorChat(reciever, "!g%s !t%s !y: !g%s", PREFIX, name1, message)
   client_cmd(reciever, "spk ^"%s^"", pm_sound)

}
that you see message and who is the reciever, but both nick are the same color... For example Im in CT team, and reciever is in T team... and it shows both nicks in blue color...

Last edited by niiii; 04-11-2015 at 21:19.
niiii is offline
Kiske
Veteran Member
Join Date: May 2009
Old 04-11-2015 , 21:46   Re: Pm Plugin - need help
Reply With Quote #4

Quote:
Originally Posted by niiii View Post
thank you, it works, but... how can I solve the second problem? I need that admins will see all pm messages :/

I also added line to
Code:
stock printMessage(reciever, sender, const message[])
{
   new name1[32];
   new name2[32];
   get_user_name(sender, name1, charsmax(name1))
   get_user_name(reciever, name2, charsmax(name2))
 
   ColorChat(sender, "!g%s !t%s !y-> !t%s !y: !g%s", PREFIX, name1, name2, message)
   ColorChat(reciever, "!g%s !t%s !y: !g%s", PREFIX, name1, message)
   client_cmd(reciever, "spk ^"%s^"", pm_sound)

}
You need a loop in that stock to check if the user is admin, like this:
PHP Code:
new iUsers[32];
new 
iCant;
new 
iId;
new 
i;

get_players(iUsersiCant);

for(
0iCant; ++i) {
    
iId iUsers[i];
    
    if(
get_user_flags(iId) & ADMIN_BAN) {
        
ColorChat(iId"!g%s !t%s !y: !g%s"PREFIXname1message);
    }

Quote:
Originally Posted by niiii View Post
but both nick are the same color... For example Im in CT team, and reciever is in T team... and it shows both nicks in blue color...
You need the other ColorChat include, this:
Attached Files
File Type: inc cc.inc (1.2 KB, 70 views)
__________________


Last edited by Kiske; 04-11-2015 at 21:47.
Kiske is offline
Send a message via Skype™ to Kiske
niiii
Member
Join Date: Sep 2013
Old 04-12-2015 , 04:19   Re: Pm Plugin - need help
Reply With Quote #5

Thank you, admins see the messages now, I but cant make the color working :/ It would be nice if anybody could do it for me :/

Code:
stock printMessage(reciever, sender, const message[])
{

   new name1[32];
   new name2[32];
   get_user_name(sender, name1, charsmax(name1))
   get_user_name(reciever, name2, charsmax(name2))
 

   ColorChat(reciever, "!g%s !t%s !y: !g%s", PREFIX, name1, message)
   client_cmd(reciever, "spk ^"%s^"", pm_sound)

   new iUsers[32];
   new iCant;
   new iId;
   new i;

   get_players(iUsers, iCant);
  
   for(i = 0; i < iCant; ++i) {
    iId = iUsers[i];
    
    if(get_user_flags(iId) & ADMIN_BAN || sender) {
        ColorChat(iId, "!g%s !t%s !y-> !t%s !y: !g%s", PREFIX, name1, name2, message)
    }
} 

}

Last edited by niiii; 04-12-2015 at 05:12.
niiii is offline
safetymoose
Senior Member
Join Date: Feb 2015
Old 04-13-2015 , 09:52   Re: Pm Plugin - need help
Reply With Quote #6

ColorChat(receiver, STARTING COLOR, message)

Starting Color = NORMAL, RED, BLUE, GREEN

Last edited by safetymoose; 04-13-2015 at 09:54.
safetymoose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:25.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode