Raised This Month: $ Target: $400
 0% 

Help the new guy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NewUser
Member
Join Date: Mar 2006
Location: over there
Old 06-25-2006 , 21:36   Help the new guy
Reply With Quote #1

Hello. I'm new the C++ scene. So I figure I'd give it a whack. Well, let's start off with something basic. How would I make a simple command? Such as, 'if' someone says 'that' it does stuff. Any help is appreciated greatly.
NewUser is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 06-25-2006 , 22:16   Re: Help the new guy
Reply With Quote #2

Ok, first you need to change the way FireEvent is handled in the Source:MM example. If you dont want to, you can use the method provided.

Bascially, without actually handing you the code im going to explain the steps so you can search the SDK for answers and hopefully learn a few things along the way.


You need to use IGameEventListener2::AddListener to add a listener for player_say. Then, using any examples you can find, inside the FireGameEvent function, after you have confirmed the event is player_say, you need to check if
Code:
if ( FStrEq( event->GetString( "text" ), "that" ) )
{
       // do stuff
}
Add your own error handlers, this is just a basic walk through...

If you have any questions, just ask we are here to help, I didnt give you the exact code because you will learn much more from having to find the answers than just copying my code =)
__________________

Last edited by c0ldfyr3; 06-25-2006 at 22:22.
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
FakeMajor
New Member
Join Date: Jun 2006
Old 06-26-2006 , 00:58   Re: Help the new guy
Reply With Quote #3

Heres a tutorial for making a simple command so that when a user enters "hello" into the console the mod responds and says "hi".

to add a command we put the code in the ClientCommand function. so all this code goes in the ClientCommand function b4 RETURN_META.

first we need to check if the user has entered the command "hello" so we use this code:
Code:
const char *cmd = m_Engine->Cmd_Argv(0);
 
if(!strcmpi(cmd, "hello"))
{
  // the user has typed hello into the console
}
now this has made it so when the user enters hello in the console it does the code between the { and }

next we want it to say something back after we say hello so put this code between the { and }
Code:
m_Engine->ClientPrintf(pEntity, "hello player");
so combined the code is
Code:
const char *cmd = m_Engine->Cmd_Argv(0);
 
if(!strcmpi(cmd, "hello"))
{
  // the user has typed hello into the console
  m_Engine->ClientPrintf(pEntity, "hello player\n");
}
now compile and test the mod and when you say hello in the console it says hello player in response. and remember this code goes in the ClientCommand function.
FakeMajor is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 06-26-2006 , 10:29   Re: Help the new guy
Reply With Quote #4

I thought he said he wanted to check if the player said hello....
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 06-26-2006 , 11:49   Re: Help the new guy
Reply With Quote #5

In that case you'll need to embed a voice recognition module into your plugin to handle the raw sound stream being sent between players.

:p
L. Duke is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 06-26-2006 , 14:09   Re: Help the new guy
Reply With Quote #6

Ahh... trickery.
__________________
sslice is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 06-26-2006 , 17:56   Re: Help the new guy
Reply With Quote #7

Quote:
Originally Posted by L. Duke
In that case you'll need to embed a voice recognition module into your plugin to handle the raw sound stream being sent between players.

:p
Oops, by siad i meant typed chat ;)
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
SeLfkiLL
Member
Join Date: Nov 2005
Old 07-02-2006 , 16:33   Re: Help the new guy
Reply With Quote #8

Here's some quick programming tutorials:
http://vergil.chemistry.gatech.edu/r...orial/toc.html
http://www.cplusplus.com/doc/tutorial/
http://cplus.about.com/

Although I personally recommend you go buy a book on C++.

Last edited by SeLfkiLL; 07-02-2006 at 16:36.
SeLfkiLL is offline
Send a message via AIM to SeLfkiLL
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 20:39.


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