PDA

View Full Version : My first plugin, help pls


4JOKE
04-05-2008, 10:47
I tryed to write my first plugin, but i have problem with changing color of chat text. When i write amx_f10 into console, i should see " [player] hello" in green color. But it only says in console "unknown command".

#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
register_plugin("Test", AMXX_VERSION_STR, "Test Plugin");
register_clcmd("amx_test", "cmdtest", ADMIN_ALL);
}


public cmdtest(id)
{
new name[31];
new SayText;
get_user_name(id, name, 31);
static iPlayers[32], iPlayer, plnum;
get_players( iPlayers, plnum, "" );


for( new i = 0; i < plnum; i++ )
{
iPlayer = iPlayers[i];

if( !is_user_admin(iPlayer) )
continue;

new msg[128];
format(msg,127,"^x03 [ %s ] hello ",name);
message_begin(MSG_ONE,SayText,{0,0,0},iPlayer );
write_byte(iPlayer);
write_string(msg);
message_end();

}

}And here is first version of my plugin with normal color of chat text. This is working without problems.
#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
register_plugin("Test", AMXX_VERSION_STR, "Test plugin")
register_clcmd("amx_test", "cmdtest", ADMIN_ALL)
}

public cmdtest(id)
{
new name[31]
get_user_name(id, name, 31)
new i
new maxPlayers
new Players[32]
new playerCount
get_players(Players, playerCount)
maxPlayers = get_maxplayers()

for(i = 0; i <= maxPlayers; i++)
{
if (!is_user_connected(i))
continue

if ( is_user_admin(Players[i]) )
continue

client_print( i, print_chat,"[ %s ] hello",name)

}


}So my question is: How I can write colored text in chat? Can someone correct the source at the top ? thnx.

4JOKE
04-07-2008, 15:49
No body know what i am doing wrong? I try to again :
1.Quote
- when I write into console "amx_test", it says "unknown command"

2. Quote
- function without problems, but client_print text isn't another color

How to successful rebuild client_print to saying color messages ?
So what I am doing in first Quote bad? I try to write color chat for first time...
Thnx.

rudle
04-07-2008, 15:59
Badly set up and next time make it cmdtest and cmdtest2

register_clcmd("amx_test", "cmdtest", ADMIN_ALL)Should be
register_clcmd("amx_test", ADMIN_ALL, "cmdtest")

Exolent[jNr]
04-07-2008, 16:00
Actually rudle, he registered the command right.
http://www.amxmodx.org/funcwiki.php?search=register_clcmd&go=search

4JOKE
04-07-2008, 16:11
Actually rudle, he registered the command right.
http://www.amxmodx.org/funcwiki.php?search=register_clcmd&go=search


Yes, I have it registered right. But what is very interesting? Check the commands in BOLD because only these commands are different in these 2 versions of plugin.

hoboman
04-07-2008, 16:11
the name of the command is amx_test not amx_f10

also you should have copied what was given in the tutorial and used:
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, id)

4JOKE
04-07-2008, 17:03
Big Thnx to Hoboman. Now plugin works (it says message of blue color) but still in console I see "unknown command".

#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
register_plugin("Test", AMXX_VERSION_STR, "Test Plugin");
register_clcmd("amx_test", "cmdtest", ADMIN_ALL);
}


public cmdtest(id)
{
new name[31];
get_user_name(id, name, 31);
static iPlayers[32], iPlayer, plnum;
get_players( iPlayers, plnum, "" );


for( new i = 0; i < plnum; i++ )
{
iPlayer = iPlayers[i];

if( !is_user_admin(iPlayer) )
continue;

new msg[128];
format(msg,127,"^x03 [ %s ] hello ",name);
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, iPlayer);
write_byte(iPlayer);
write_string(msg);
message_end();

}

}

hoboman
04-07-2008, 17:10
you have to return PLUGIN_HANDLED at the end of that function

4JOKE
04-07-2008, 17:29
This doesn't function:
#include <amxmodx>
#include <amxmisc>


public plugin_init()
{
register_plugin("Test", AMXX_VERSION_STR, "Test Plugin");
register_clcmd("amx_test", "cmdtest", ADMIN_ALL);
}


public cmdtest(id)
{
new name[31];
get_user_name(id, name, 31);
static iPlayers[32], iPlayer, plnum;
get_players( iPlayers, plnum, "" );


for( new i = 0; i < plnum; i++ )
{
iPlayer = iPlayers[i];

if( !is_user_admin(iPlayer) )
continue;

new msg[128];
format(msg,127,"^x04 [ %s ] hello ",name);
message_begin(MSG_ONE, get_user_msgid("SayText"), {0,0,0}, iPlayer);
write_byte(iPlayer);
write_string(msg);
message_end();

}
PLUGIN_HANDLED;

}

hoboman
04-07-2008, 17:31
return PLUGIN_HANDLED

4JOKE
04-07-2008, 17:46
thnx again, it works now. I should read more carefuly :)