Raised This Month: $ Target: $400
 0% 

Why wont this work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-19-2004 , 21:57   Why wont this work?
Reply With Quote #1

Code:
#include <amxmodx>

new phrase[1][] = { "/hello" } 

public say_event(id)
{
	new sid[10]
	num_to_str(id,sid,10)
	new said[192]
	read_args(said,191) 
	
	for(new i = 0 ;i < 1; i += 1)
		if(containi(said,phrase[i]) != -1) {
			set_hudmessage(225, 25, 25, -1.0, 0.32, 0, 2.0, 9.0, 0.8, 0.8, 2)    
            show_hudmessage(0,"Hello and welcome to this server")
            set_task(1.0,"client",0,sid,10)
            break
    }
}

public client(sid[])
{
	new id = str_to_num(sid)
	engclient_cmd(id,"say", "Hello and welcome to server") 
    client_cmd(0, "spk ^"you are a ass hole^"")
	
}

public plugin_init()
{
	register_plugin("Say Hello","0.4","SneakerBoots")
	register_clcmd("say","say_event")
    return PLUGIN_CONTINUE
}
When you type /hello nothing happens Whats wrong with it?
__________________
Nick is offline
Send a message via MSN to Nick
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-19-2004 , 22:58  
Reply With Quote #2

Well, one thing I noticed is you are Declaring a var inside the for loop Declaration [ie: for( new i = 0; .... ) ], which is okay, unless you use break inside of it, then Small won't like it anymore (i think it fails to deallocate the counters memory or something).. Simple fix, declare your counter var outside the for loop structure..

Also, public plugin_init() function doesn't require a return value.. so PLUGIN_CONTINUE was useless.. anyway, no harm there...

Some other stuff I changed around too, look in comments too...

Code:
#include <amxmodx> new phrase[2][] = { "hello", "hi" } public say_event( id ) {     new said[192], sid[2], i     read_args(said,191)     sid[0] = id     for( i = 0; i < 2; i++ )     {         if(containi(said,phrase[i]) > -1)         {             set_hudmessage(225, 25, 25, -1.0, 0.32, 0, 2.0, 9.0, 0.8, 0.8, 2)             show_hudmessage(0,"Hello and welcome to this server")             set_task(1.0,"client",0,sid,1)             break         }     }     return PLUGIN_HANDLED } public client(sid[]) {     new id = sid[0]     //  Using the word 'hello' or 'hi' (from phrase[] above) will cause an infinite loop..     // Think: if the player says hello, you call this function, which makes them say Hello again!     // I changed Hello to Hey..     client_cmd(id,"say ^"Hey! Welcome to This Server!^"")     client_cmd(0, "spk ^"you are a ass hole^"") } public plugin_init() {     register_plugin("Say Hello","0.4","SneakerBoots")     register_clcmd("say","say_event") }
xeroblood is offline
Send a message via MSN to xeroblood
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-20-2004 , 00:11  
Reply With Quote #3

ty lemme look
__________________
Nick is offline
Send a message via MSN to Nick
dragonchaos
Member
Join Date: Mar 2004
Old 04-20-2004 , 00:34  
Reply With Quote #4

Well couldn't you use the client_print , and just fake a client "say"
dragonchaos is offline
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-20-2004 , 00:36  
Reply With Quote #5

I still got same problem anything thing else I got wrong?
__________________
Nick is offline
Send a message via MSN to Nick
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-20-2004 , 00:37  
Reply With Quote #6

Quote:
Originally Posted by dragonchaos
Well couldn't you use the client_print , and just fake a client "say"
Ill try it
__________________
Nick is offline
Send a message via MSN to Nick
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-20-2004 , 00:51  
Reply With Quote #7

nvm it works now but the speech keeps on repeating and doesnt stop...Whats going on wit that or is it just my server?
__________________
Nick is offline
Send a message via MSN to Nick
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 04-20-2004 , 00:55  
Reply With Quote #8

nvm it works now but the speech keeps on repeating and doesnt stop...Whats going on wit that or is it just my server?
__________________
Nick is offline
Send a message via MSN to Nick
ts2do
Senior Member
Join Date: Mar 2004
Old 04-20-2004 , 10:15  
Reply With Quote #9

Code:
//EASIER: #include <amxmodx> public say_event(id) {    set_hudmessage(225, 25, 25, -1.0, 0.32, 0, 2.0, 9.0, 0.8, 0.8, 2)        show_hudmessage(0,"Hello and welcome to this server")    client(id)    engclient_cmd(id,"say", "Hello and welcome to server")    client_cmd(0, "spk ^"you are a ass hole^"") } public plugin_init() {    register_plugin("Say Hello","0.4","SneakerBoots")    register_clcmd("say /hello","say_event")     return PLUGIN_CONTINUE }
ts2do is offline
Send a message via AIM to ts2do
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 04-20-2004 , 12:03  
Reply With Quote #10

@ts2do:
You have the return in the wrong function (return PLUGIN_CONTINUE should be in first function, not plugin_init() it isn't needed there)...

Also, you are calling client(id) which doesn't exist in your version anymore...

Also, for both of you, haw many people join your server and say /hello

In my server, they ussually say hello or hi (without the slash).. anyway...

I didn't alter Nick's original Logic, just pointed out (and fixed) a few spots that were incorrect, as well as point out a possible runtime error (infinite loops)..

I even tested it on my server before posting, and it worked fine..
xeroblood is offline
Send a message via MSN to xeroblood
Reply


Thread Tools
Display Modes

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 16:49.


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