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

Players in menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
niiii
Member
Join Date: Sep 2013
Old 04-12-2015 , 04:21   Players in menu
Reply With Quote #1

Hello, I have a problem with my plugin, I need player names showed in menu, but not mine. Need names only of other players, any ideas?

Code:
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, "c")
   
   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
}
niiii is offline
Old 04-12-2015, 07:29
Obada
This message has been deleted by Obada. Reason: My bad
Old 04-12-2015, 08:12
niiii
This message has been deleted by niiii.
Kiske
Veteran Member
Join Date: May 2009
Old 04-12-2015 , 09:17   Re: Players in menu
Reply With Quote #2

Skip yourself on loop:

PHP Code:
if(tempid == id) {
    continue;

__________________


Last edited by Kiske; 04-12-2015 at 09:17.
Kiske is offline
Send a message via Skype™ to Kiske
niiii
Member
Join Date: Sep 2013
Old 04-12-2015 , 09:27   Re: Players in menu
Reply With Quote #3

Code:
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, "c")
   
   for( new i; i<pnum; i++ )
   {
   
   if(tempid == id) {
    continue;
    }     
      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)
   }
this doesnt work :/
niiii is offline
Kz1.0
Senior Member
Join Date: Jan 2013
Location: Vietnam
Old 04-12-2015 , 10:21   Re: Players in menu
Reply With Quote #4

Is this really your code? You must add those lines in Kiske's post right after "tempid = players[i]", not before.

Last edited by Kz1.0; 04-12-2015 at 10:22.
Kz1.0 is offline
niiii
Member
Join Date: Sep 2013
Old 04-12-2015 , 12:47   Re: Players in menu
Reply With Quote #5

thank you very much

Last edited by niiii; 04-12-2015 at 12:54.
niiii 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 03:24.


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