AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make this Hud work =O (https://forums.alliedmods.net/showthread.php?t=156482)

bobby3 05-07-2011 07:10

How to make this Hud work =O
 
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

Hunter-Digital 05-07-2011 07:22

Re: How to make this Hud work =O
 
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.

vato loco [GE-S] 05-07-2011 07:24

Re: How to make this Hud work =O
 
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 :wink:

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

bobby3 05-07-2011 07:29

Re: How to make this Hud work =O
 
lol i didnt but a menu yet, til then i know how too, problem is functions and damit i forgot publics -.-

vato loco [GE-S] 05-07-2011 07:32

Re: How to make this Hud work =O
 
Quote:

Originally Posted by Hunter-Digital (Post 1464933)
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!")
    }
}


:arrow:
PHP Code:

for(new 1<= g_iMaxPlayersi++) 



Hunter-Digital 05-07-2011 07:47

Re: How to make this Hud work =O
 
Quote:

Originally Posted by vato loco [GE-S] (Post 1464938)
:arrow:
PHP Code:

for(new 1<= g_iMaxPlayersi++) 



My bad, fixed :}

vato loco [GE-S] 05-07-2011 07:48

Re: How to make this Hud work =O
 
:wink:


All times are GMT -4. The time now is 04:17.

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