Raised This Month: $ Target: $400
 0% 

How to make this Hud work =O


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bobby3
Member
Join Date: Apr 2011
Old 05-07-2011 , 07:10   How to make this Hud work =O
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Some Hud message for PPG that actually work =D"
#define VERSION "9999999999.0"
#define AUTHOR "Mecca"
new players[32] = true;
new 
num
public plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
get_players(players,num)
 
set_task(10.0,"hudmessage",69,"",0,"b");
 
register_clcmd("say /ajuda","helpon");
 
register_clcmd("say /ajudaoff","helpoff");
}
public 
hudmessage(id)
{
 
          if(
players[id]){
 
set_hudmessage(57199710.450.8206.012.0)
 
show_hudmessage(0"Message!")
        }
}
 
}
client_connect(id)
{
 
players[id] = true;
}
client_disconnect(id)
{
 
players[id] = false;
}
public 
helpon(id)
{
 
players[id] = true;
}
public 
helpoff(id)
{
 
players[id] = false;

Imtrying make a hud menu where shows a menu to all players when they enter the server. They can turn on the menu and off by using /helpon and helpoff. Unforgently i cant see the menu, probaly its about the ID crap and so I need help =S
bobby3 is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-07-2011 , 07:22   Re: How to make this Hud work =O
Reply With Quote #2

First of all, indent your code ! You didn't even see that you've got an extra "}" over there.

Also, forwards (like client_connect() ) must have public in front of them.

Next, players are from 1 to 32, a 32 cell array holds from 0 to 31, you need to set it to 33.

Use client_putinserver() since client_connect() triggers when player connects BUT if player cancells in loading, client_disconnect() doesn't trigger, so you'll have a slot set to true even if the player isn't in the game.

Use a loop to cycle through all players in hudmessage(), remove that id since it's always "69" (the task id).
Example loop:
Code:
new g_iMaxPlayers

//...

// plugin_init()
g_iMaxPlayers = get_maxplayers()

//...

set_hudmessage( ... ) /* you don't need to call this for each player so just place it here */

for(new i = 1; i <= g_iMaxPlayers; i++)
{
    if(players[i])
    {
        show_hudmessage(i, "message!")
    }
}
Remove get_players() from plugin_init() since it will ALWAYS return 0 players, plugin_init() is called only when plugin is loaded, you could use get_players() in hudmessage() but it's faster to just use that loop since you're already tracking online players in a way (offline players have players[id] = false so it'll skip them anyway).


And I don't think you can set an array to a value like that, either use = {true, ...} or just use them the other way around, false means show hud message, and true means hide hud message, it could be easier for you.

Your version is weird =) use a lower number such as 0.1, 1.0, 2.0, or just leave it empty.


EDIT: and yeah, show_hudmessage() is a hud MESSAGE, not a menu.
__________________

Last edited by Hunter-Digital; 05-07-2011 at 07:46.
Hunter-Digital is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 05-07-2011 , 07:24   Re: How to make this Hud work =O
Reply With Quote #3

i can't find a menu in your code
this is the reason why you don't see the menu

if menu do not exsits you can't see it

here is a link
[TUT] for menu's
New AMXX Menu System
__________________

Last edited by vato loco [GE-S]; 05-07-2011 at 07:27.
vato loco [GE-S] is offline
bobby3
Member
Join Date: Apr 2011
Old 05-07-2011 , 07:29   Re: How to make this Hud work =O
Reply With Quote #4

lol i didnt but a menu yet, til then i know how too, problem is functions and damit i forgot publics -.-
bobby3 is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 05-07-2011 , 07:32   Re: How to make this Hud work =O
Reply With Quote #5

Quote:
Originally Posted by Hunter-Digital View Post
Code:
new g_iMaxPlayers

//...

// plugin_init()
g_iMaxPlayers = get_maxplayers()

//...

set_hudmessage( ... ) /* you don't need to call this for each player so just place it here */

for(new i = 0; i <= g_iMaxPlayers; i++){
    if(players[i])
    {
        show_hudmessage(i, "message!")
    }
}

PHP Code:
for(new 1<= g_iMaxPlayersi++) 

__________________
vato loco [GE-S] is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 05-07-2011 , 07:47   Re: How to make this Hud work =O
Reply With Quote #6

Quote:
Originally Posted by vato loco [GE-S] View Post

PHP Code:
for(new 1<= g_iMaxPlayersi++) 

My bad, fixed :}
__________________
Hunter-Digital is offline
vato loco [GE-S]
Veteran Member
Join Date: Oct 2006
Location: Germany
Old 05-07-2011 , 07:48   Re: How to make this Hud work =O
Reply With Quote #7

__________________
vato loco [GE-S] 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 04:17.


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