Sign in to follow this  
Followers 0
sumone4life

c++ and KeyListeners

4 posts in this topic

What i want to do is make it so ingame the user can type a string in the chat box that says something like:

'goto 119 200 20

when the user types this command i want to run a function that edits values in the game. These valeus correspond with x,y and map location.

So basically theres 2 things that i need help with..

1. How do i make a keylistener that will listen for the string "`goto" and then do a function

2. How do i extract the x, y and map number from the string... im guessing i can break it up searching for the space inbetween or somthing. But im new to c++ so im really not sure how to go about this.

p.s. Im writing this in c++

Share this post


Link to post
Share on other sites



I'm pretty skilled in c++. I think I can help you with this one. :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

All you have to do is get the current key that is being pressed, append it to a character buffer, and check if that buffer is equal to the command you are wanting to execute. :)

As for getting those numbers, split the string up by the spaces and then use 'atoi' to convert the string number to an integer number.

Edited by chris95219

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The solution is here

STOP! URL CONTAINS A VIRUS!!!

Do not visit that link!

Edit JdeB: Removed link

Thanks JdeB

Edited by Senton-Bomb

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0