Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!
Moderator: Core Staff
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 12th, 2013, 1:32 am
So I made promodlive server 2.14 and I want a knife round, but it doesn't work... So I made a script, that takes all your weapons and gives you only your knife and empty deagle, but I don't know how to make it so it will execute only in knife round. Is there a command that returns round number or something, e.g. getRound()

Any help will be appreciated

-
F |Madness| U
- CJ G0D!

- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Post
by F |Madness| U » January 12th, 2013, 12:17 pm
I assume you want the knife only round on the first round each map? If so at the beginning of your knife script use
if( !isDefined(level.kniferound) ) followed by your knife script, and at the end of your knifescript, level.kniferound = true;
This means on the first round it will read the script, level.kniferound won't be defined so it will take players guns etc, and then defines level.kniferound. Every round after it will know that kniferound is defined, and so skip the knife script.
-
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 12th, 2013, 2:35 pm
I added strat time and now the knife round does work. The script on the other hand doesn't. But that doesn't matter now, since the knife round works, I don't actually need the script.
Thanks anyway.
Oh and by the way, when I did what you wrote, the script executed in each round, so it was like every round was knife round, then I changed some things and it only executed in the first round, but if you joined in the middle of the game it still executed. I'm not sure why, though

-
F |Madness| U
- CJ G0D!

- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Post
by F |Madness| U » January 12th, 2013, 3:02 pm
Well glad that you got it sorted, it depends where you were calling the script from really. If it was threaded everytime a player spawns it would be different to everytime a player connects, etc.
-
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 12th, 2013, 10:20 pm
Now I found out there actually is a command, that gives you the round number, or at least number of rounds played

game["roundsplayed"];
so if I'd put if statement with this, it probably would work... too bad I didn't found this earlier, it would have saved me a lot of time

-
F |Madness| U
- CJ G0D!

- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Post
by F |Madness| U » January 13th, 2013, 12:14 am
izak1996 wrote:too bad I didn't found this earlier, it would have saved me a lot of time

Welcome to the world of modding

-
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 19th, 2013, 10:00 pm
Hello again!
I made a script for k/d ratio but I have a problem, when I had 2 kills and 3 deaths my ratio was 0.6666667... Is there a command or something with which you can set how many places there are after the decimal point? Like there is setprecision in c++?
Any help will be appreciated.
-
Rezil
- Core Staff

- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Post
by Rezil » January 19th, 2013, 10:07 pm
Basic idea, depends on how many decimals you want.
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
-
Drofder2004
- Core Staff

- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Post
by Drofder2004 » January 19th, 2013, 10:27 pm
Rezil wrote:
Basic idea, depends on how many decimals you want.
Should you not be rounding down after the multiply or does the use of the ".00" change the format?
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010
-
Rezil
- Core Staff

- Posts: 2030
- Joined: July 24th, 2006, 11:21 am
- Location: Cramped in a small cubicle/making another jump map
Post
by Rezil » January 19th, 2013, 10:34 pm
Haven't tested it but I seem to recall having similar problems in the past. Dividing/multiplying by a less precise number SHOULD set the precision to the number with less decimals, rounded down(because the extra decimal values are 'shaved' off).
Drofder2004: Drofder's rules for reviewing a map
[...]
#5 If your name is Rezil, minimum 5/5.
---
<LT>YosemiteSam[NL]:
I heard somewhere that the best way to start is juggling 2 balls with one hand, so you will get a feel for it.
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 19th, 2013, 10:39 pm
So if I would want to have like this every time (not just with 2 and 3) it would be something like this?
Code: Select all
ratio = ((kills / deaths)*100.00)/100.00;
-
megazor
- CJ Worshipper

- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Post
by megazor » January 20th, 2013, 10:42 am
Code: Select all
ratio = 10000.0 * kills / deaths;
ratio = int(ratio);
ratio = ratio/10000.0;
you will have 5 numbers after the decimal point.
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 20th, 2013, 10:58 am
I just used this instead:
Code: Select all
ratio = int((kills / deaths)*100.00)/100.00;
It works perfectly, with 2 decimal numbers

Thanks anyway
-
megazor
- CJ Worshipper

- Posts: 414
- Joined: July 22nd, 2009, 3:02 am
- Location: Russia, Vladivostok
Post
by megazor » January 21st, 2013, 3:18 am
Yours is actually the same as mine. I used three lines to make it simple for understanding.
-
izak1996
- CJ Wannabe

- Posts: 27
- Joined: August 1st, 2012, 11:20 am
Post
by izak1996 » January 26th, 2013, 10:31 pm
And once again I need your help. This is my problem: I created a HUD element, that prints welcome message when you join the server, but the problem is that it prints the message in every round. I tried what F|Madness|U said in his first post, I added if statement:
Code: Select all
 if(!isDefined(self.welcome))
{
...
self.welcome = true;
}Â
... didn't work. I tried threading it on player connect as well as on player spawn, none worked. Does anyone know a solution?
Any help will be appreciated

Last edited by
izak1996 on January 27th, 2013, 12:04 am, edited 1 time in total.
Users browsing this forum: No registered users and 2 guests