C++ help [message #276426] |
Tue, 31 July 2007 21:07 |
Sn1per74*
Messages: 939 Registered: April 2006
Karma: 0
|
Colonel |
|
|
Three questions!
1. When ever I make an SSM and set it to the model of a large_blocker, you can walk through it where the SSM part isn't, how do I fix it?
2. I try to make a spy. It costs 150 credits. But, if you have less than 150, it still buys it and goes into negatives. How do you make it so you just can't buy it if its less than 150? Here's my code:
Quote: | else if (strncmp(Msg3,"!spy",4) == 0) { // change 12 to how many letters command + ! is change !yourcommand to what you want
if (obj){ // LEAVE THIS VERY IMPORTANT
if(Commands->Get_Money(obj) < 150.0f) {
char message[256];
sprintf(message,"ppage %d You need 150 credits!",ID);
Console_Input(message);
}
else(Commands->Get_Money(obj) >= 150.0f){
Commands->Give_Money(obj,-150,false);
}
if(Get_Team(ID) == 1) {
Change_Character(obj,"CnC_Nod_MiniGunner_0");
}
else Change_Character(obj,"CnC_GDI_Minigunner_0");
char message[256];
sprintf(message,"message The player has %f credits",Commands->Get_Money(obj));
Console_Input(message);
}
}
|
3. Is there someway to make your name the other teams color, like your tag when you walk around. NOT in the scoreboard.
-
Attachment: meh.JPG
(Size: 92.44KB, Downloaded 334 times)
Creator: AoBFrost
[Updated on: Tue, 31 July 2007 21:35] Report message to a moderator
|
|
|
Re: C++ help [message #276454 is a reply to message #276426] |
Tue, 31 July 2007 23:10 |
_SSnipe_
Messages: 4121 Registered: May 2007 Location: Riverside Southern Califo...
Karma: 0
|
General (4 Stars) |
|
|
for the ssml launcher um heres a guess check the model in lvl and make sure its the right one?
|
|
|
|
Re: C++ help [message #276517 is a reply to message #276426] |
Wed, 01 August 2007 08:07 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
1) Pretty sure it's using the world box of the SSM.
2) I'm pretty sure it's just the else should be else if, but...
Declare the variable "PlayerCreds" as type int, and then.. oh fuck it, it's easier to show you:
int PlayerCreds = Commands->Get_Money(obj);
This will make it easier for you write and follow, so it would look something like (havn't tried it, most likely will give erros, but you get the idea):
if (PlayerCreds > 150) {
Commands->Give_Money(obj, -150, false);
if(Get_Team(ID) == 1) {
Change_Character(obj,"CnC_Nod_MiniGunner_0");}
}
else if (PlayerCreds < 150) {
//blah blah blah
3) I'm sure it's possible, as there is a weird bug that can cause it, but I havn't ever tried to do it on purpose
|
|
|
|
Re: C++ help [message #276524 is a reply to message #276521] |
Wed, 01 August 2007 09:14 |
Sn1per74*
Messages: 939 Registered: April 2006
Karma: 0
|
Colonel |
|
|
RoShamBo wrote on Wed, 01 August 2007 11:03 |
if(!Purchase_Item(<player GameObject *>, <cost>))
{
//not enough
}
else
{
//buy the item
}
Although the spy thing is possible, it required ASM hacks afaik.
|
Could I make a script or something? It doesn't seem to complicated. I mean, if somebody can make a boat and submarine script, how hard could it be to make something change color? Then again, I've never made a script before.
Creator: AoBFrost
[Updated on: Wed, 01 August 2007 09:14] Report message to a moderator
|
|
|
|
|
|
|
Re: C++ help [message #276608 is a reply to message #276525] |
Wed, 01 August 2007 16:41 |
Sn1per74*
Messages: 939 Registered: April 2006
Karma: 0
|
Colonel |
|
|
Cat998 wrote on Wed, 01 August 2007 11:22 |
I also recommend you to use a string tokenizer for the command
checking, it's a pain to always use strncmp
|
What do you mean string tokenizer. BTW, Thanks for all the help guys!
And what's the difference between true and false?
Creator: AoBFrost
[Updated on: Wed, 01 August 2007 16:42] Report message to a moderator
|
|
|
Re: C++ help [message #276620 is a reply to message #276608] |
Wed, 01 August 2007 17:34 |
|
Cat998
Messages: 1081 Registered: January 2004 Location: Austria, Vienna
Karma: 0
|
General (1 Star) Moderator/Captain |
|
|
Sn1per74* wrote on Thu, 02 August 2007 01:41 |
Cat998 wrote on Wed, 01 August 2007 11:22 |
I also recommend you to use a string tokenizer for the command
checking, it's a pain to always use strncmp
|
What do you mean string tokenizer. BTW, Thanks for all the help guys!
And what's the difference between true and false?
|
You can use my char string tokenizer. It's awesome
It splits any strings into pieces, you can define the delimiter it uses for splitting (for example a space), and you can define the maximum number of pieces, the last one contains the rest of the string.
http://www.blackintel.org/Cat998/strtokenizer.txt
strtokenizer takes 4 arguments:
char *message: The message you want to split into pieces
char *buf: It needs a memory buffer, where it can copy the tokens into, for ingame chat messages 512 bytes is enough I think
unsigned int n: The max number of tokens (The last one contains the rest of the string)
char delimiter: The delimiter character
Example:
Quote: | char *message "!kick Sn1per74 C++ newb";
char buf[512]; //buffer for the function
char **toks;
toks = strtokenizer(message, buf, 3, ' '); //function call
Console_Output("%s has been kicked out of the game for: %s", toks[1], toks[2]);
//kick code here
delete[] toks; //cleanup
|
So toks[0] contains word1 (!kick), toks[1] contains word2 (Sn1per74) and toks[2] contains the rest of the string
When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter then "Yes"
Programming is like sex: one mistake and you have to support it for the rest of your life
Want the best answers? Ask the best questions!
"So long, and thanks for all the fish."
[Updated on: Thu, 02 August 2007 12:27] Report message to a moderator
|
|
|
Re: C++ help [message #276628 is a reply to message #276620] |
Wed, 01 August 2007 18:28 |
Sn1per74*
Messages: 939 Registered: April 2006
Karma: 0
|
Colonel |
|
|
[quote title=Cat998 wrote on Wed, 01 August 2007 19:34][quote title=Sn1per74* wrote on Thu, 02 August 2007 01:41]Cat998 wrote on Wed, 01 August 2007 11:22 |
Example:
Quote: | char *message "!kick Sn1per74 C++ newb";
char buf[512]; //buffer for the function
char **toks;
toks = strtokenizer(message, buf, 3, ' '); //function call
Console_Output("%s has been kicked out of the game for: %s", toks[1], toks[2]);
//kick code here
delete[] toks; //cleanup
|
So toks[0] contains word1 (!kick), toks[1] contains word2 (Sn1per74) and toks[2] contains the rest of the string
|
Good example.
Creator: AoBFrost
|
|
|
|
Re: C++ help [message #276640 is a reply to message #276426] |
Wed, 01 August 2007 22:10 |
|
Whitedragon
Messages: 832 Registered: February 2003 Location: California
Karma: 1
|
Colonel |
|
|
Use SSGM's ChatCommandClass, it has automatic tokenizing. I showed you this in one of your other topics.
Black-Cell.net
Network Administrator (2003 - )
DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )
Dragonade, Renegade's first server side modification
Lead coder (2005 - )
|
|
|
Re: C++ help [message #276668 is a reply to message #276426] |
Thu, 02 August 2007 02:07 |
|
Cat998
Messages: 1081 Registered: January 2004 Location: Austria, Vienna
Karma: 0
|
General (1 Star) Moderator/Captain |
|
|
From what I know, it's using std:: strings and it's very bloated.
When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter then "Yes"
Programming is like sex: one mistake and you have to support it for the rest of your life
Want the best answers? Ask the best questions!
"So long, and thanks for all the fish."
|
|
|