Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Own scripts.dll commands
Own scripts.dll commands [message #236066] Wed, 27 December 2006 15:18 Go to next message
DodgeThis is currently offline  DodgeThis
Messages: 29
Registered: December 2006
Karma: 0
Recruit
I'm totally new to modding scripts.dll and new to c++. I followed many of these tutorials and now I think i know the basics of c++

To improve my not very developed skills I'm trying to make my own server side scripts...

I want to add my own custom commands...
I added this line to the scripts.dll (i know it's cheating but it's only to try it Smile )

 else if (stricmp(Msg2,"!setcash <player> <amount>") == 0)
{
// code
}


So if you say in teamchat "!setcash DodgeThis 800" it will set the cash of player DodgeThis to 800
Now i want to include that it only executes the code if it is me who said it, and that it works on the <player> with the <amount>

Does anyone knows how to do this?

I thought by myself it was something like
else if (stricmp(Msg2,"!setcash <player> <amount>") == 0 && strincmp(Get_Player_ID(sender), DodgeThis)
{
// code
}

[Updated on: Wed, 27 December 2006 15:40]

Report message to a moderator

Re: Own scripts.dll commands [message #236069 is a reply to message #236066] Wed, 27 December 2006 15:36 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
else if ((stricmp(Msg2,"!setcash <player> <amount>") == 0) && (stringcmp(Get_Player_ID(sender), DodgeThis) == 0))
{
// code
}

[Updated on: Wed, 27 December 2006 15:36]

Report message to a moderator

Re: Own scripts.dll commands [message #236070 is a reply to message #236069] Wed, 27 December 2006 15:38 Go to previous messageGo to next message
DodgeThis is currently offline  DodgeThis
Messages: 29
Registered: December 2006
Karma: 0
Recruit
saberhawk wrote on Wed, 27 December 2006 23:36

else if ((stricmp(Msg2,"!setcash <player> <amount>") == 0) && (stringcmp(Get_Player_ID(sender), DodgeThis) == 0))
{
// code
}


oh thanks ^^ forgot some little things Satisfied


but now.. i assume that you HAVE to type "!setcash <player> <amount>" and the whole code is not working if you type "!setcash friend1 100"

[Updated on: Wed, 27 December 2006 15:41]

Report message to a moderator

Re: Own scripts.dll commands [message #236075 is a reply to message #236070] Wed, 27 December 2006 16:43 Go to previous messageGo to next message
0x90
Messages: 142
Registered: September 2006
Location: Germany
Karma: 0
Recruit
DodgeThis wrote on Wed, 27 December 2006 23:38

saberhawk wrote on Wed, 27 December 2006 23:36

else if ((stricmp(Msg2,"!setcash <player> <amount>") == 0) && (stringcmp(Get_Player_ID(sender), DodgeThis) == 0))
{
// code
}


oh thanks ^^ forgot some little things Satisfied


but now.. i assume that you HAVE to type "!setcash <player> <amount>" and the whole code is not working if you type "!setcash friend1 100"


sure... since youre doing a strcmp against "!setcash <player> <amount>".. so it will check exactly this. <*> is no placeholder or something Razz
you could check if the string begins with !setcash and then parse the "params" by yourself, for example via strtok or something like that.

0x90
Re: Own scripts.dll commands [message #236146 is a reply to message #236066] Thu, 28 December 2006 08:01 Go to previous messageGo to next message
Cat998
Messages: 1082
Registered: January 2004
Location: Austria, Vienna
Karma: 0
General (1 Star)
Moderator/Captain

I think you should learn a little bit more about C++, and about
programming in general. how to compare strings and why it
does not automatically replace <player> and <amount>.


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: Own scripts.dll commands [message #236182 is a reply to message #236146] Thu, 28 December 2006 11:54 Go to previous message
DodgeThis is currently offline  DodgeThis
Messages: 29
Registered: December 2006
Karma: 0
Recruit
Cat998 wrote on Thu, 28 December 2006 16:01

why it
does not automatically replace <player> and <amount>.


I wrote

but now.. i assume that you HAVE to type "!setcash <player> <amount>" and the whole code is not working if you type "!setcash friend1 100"

Sarcasm

I already said that ^^ but indeed, I have to learn more of it to mod scripts.dll

Previous Topic: Teleport problem
Next Topic: spawn animation
Goto Forum:
  


Current Time: Thu Dec 26 00:19:24 MST 2024

Total time taken to generate the page: 0.00797 seconds