Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » C++ help
C++ help [message #276426] Tue, 31 July 2007 21:07 Go to next message
Sn1per74* is currently offline  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?
index.php?t=getfile&id=3913&private=0
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 296 times)


http://i4.photobucket.com/albums/y133/FMAROCKS/sniper74halosigsnipedontforgettogiv.png
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 Go to previous messageGo to next message
_SSnipe_ is currently offline  _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 #276498 is a reply to message #276454] Wed, 01 August 2007 06:06 Go to previous messageGo to next message
Sn1per74* is currently offline  Sn1per74*
Messages: 939
Registered: April 2006
Karma: 0
Colonel
It is. Otherwise why would one be created?

http://i4.photobucket.com/albums/y133/FMAROCKS/sniper74halosigsnipedontforgettogiv.png
Creator: AoBFrost
Re: C++ help [message #276517 is a reply to message #276426] Wed, 01 August 2007 08:07 Go to previous messageGo to next message
reborn is currently offline  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 #276521 is a reply to message #276426] Wed, 01 August 2007 09:03 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
if(!Purchase_Item(<player GameObject *>, <cost>))
{
 //not enough
}
else
{
 //buy the item
}


Although the spy thing is possible, it required ASM hacks afaik.
Re: C++ help [message #276524 is a reply to message #276521] Wed, 01 August 2007 09:14 Go to previous messageGo to next message
Sn1per74* is currently offline  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. Big Grin


http://i4.photobucket.com/albums/y133/FMAROCKS/sniper74halosigsnipedontforgettogiv.png
Creator: AoBFrost

[Updated on: Wed, 01 August 2007 09:14]

Report message to a moderator

Re: C++ help [message #276525 is a reply to message #276426] Wed, 01 August 2007 09:22 Go to previous messageGo to next message
Cat998
Messages: 1081
Registered: January 2004
Location: Austria, Vienna
Karma: 0
General (1 Star)
Moderator/Captain

3) Not without ugly hacks, I wouldn't recommend to do that without
a client modification.

I also recommend you to use a string tokenizer for the command
checking, it's a pain to always use strncmp Wink


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."
Re: C++ help [message #276549 is a reply to message #276525] Wed, 01 August 2007 12:03 Go to previous messageGo to next message
BlueThen is currently offline  BlueThen
Messages: 2402
Registered: February 2006
Karma: 0
General (2 Stars)
Use a destroyed vech's preset for the wall. But it would seem like the clients are lagging out of it when they try to go through it, it'd be completely solid though.
Re: C++ help [message #276585 is a reply to message #276426] Wed, 01 August 2007 14:20 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
all they did for the sub script was use a flying vehicle and probably a script zone for the water Sarcasm
Re: C++ help [message #276597 is a reply to message #276426] Wed, 01 August 2007 15:42 Go to previous messageGo to next message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
For the spy script, look at the gmcrate.cpp (or gmcrates.cpp - whichever it is Razz)

-MathK1LL
Re: C++ help [message #276608 is a reply to message #276525] Wed, 01 August 2007 16:41 Go to previous messageGo to next message
Sn1per74* is currently offline  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 Wink

What do you mean string tokenizer. BTW, Thanks for all the help guys! Thumbs Up
And what's the difference between true and false?


http://i4.photobucket.com/albums/y133/FMAROCKS/sniper74halosigsnipedontforgettogiv.png
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 Go to previous messageGo to next message
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 Wink

What do you mean string tokenizer. BTW, Thanks for all the help guys! Thumbs Up
And what's the difference between true and false?


You can use my char string tokenizer. It's awesome In Love

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 Very Happy
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 Razz

delete[] toks; //cleanup



So toks[0] contains word1 (!kick), toks[1] contains word2 (Sn1per74) and toks[2] contains the rest of the string Smile


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 Go to previous messageGo to next message
Sn1per74* is currently offline  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 Razz

delete[] toks; //cleanup



So toks[0] contains word1 (!kick), toks[1] contains word2 (Sn1per74) and toks[2] contains the rest of the string Smile

Good example. Sarcasm


http://i4.photobucket.com/albums/y133/FMAROCKS/sniper74halosigsnipedontforgettogiv.png
Creator: AoBFrost
Re: C++ help [message #276637 is a reply to message #276426] Wed, 01 August 2007 21:48 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
It was Wink
Re: C++ help [message #276640 is a reply to message #276426] Wed, 01 August 2007 22:10 Go to previous messageGo to next message
Whitedragon is currently offline  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 Go to previous message
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."
Previous Topic: AI Pathfind fake out?
Next Topic: Idea?
Goto Forum:
  


Current Time: Tue Jun 04 15:14:34 MST 2024

Total time taken to generate the page: 0.00963 seconds