Page 1 of 2

Promod scripting help

Posted: January 12th, 2013, 1:32 am
by izak1996
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() :D
Any help will be appreciated :)

Re: Promod scripting help

Posted: January 12th, 2013, 12:17 pm
by F |Madness| U
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.

Re: Promod scripting help

Posted: January 12th, 2013, 2:35 pm
by izak1996
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 :)

Re: Promod scripting help

Posted: January 12th, 2013, 3:02 pm
by F |Madness| U
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.

Re: Promod scripting help

Posted: January 12th, 2013, 10:20 pm
by izak1996
Now I found out there actually is a command, that gives you the round number, or at least number of rounds played :D
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 :D

Re: Promod scripting help

Posted: January 13th, 2013, 12:14 am
by F |Madness| U
izak1996 wrote:too bad I didn't found this earlier, it would have saved me a lot of time :D
Welcome to the world of modding 8)

Re: Promod scripting help

Posted: January 19th, 2013, 10:00 pm
by izak1996
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.

Re: Promod scripting help

Posted: January 19th, 2013, 10:07 pm
by Rezil

Code: Select all

((2/3)*100.00)/100.00
Basic idea, depends on how many decimals you want.

Re: Promod scripting help

Posted: January 19th, 2013, 10:27 pm
by Drofder2004
Rezil wrote:

Code: Select all

((2/3)*100.00)/100.00
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?

Re: Promod scripting help

Posted: January 19th, 2013, 10:34 pm
by Rezil
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).

Re: Promod scripting help

Posted: January 19th, 2013, 10:39 pm
by izak1996
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;

Re: Promod scripting help

Posted: January 20th, 2013, 10:42 am
by megazor

Code: Select all

ratio = 10000.0 * kills / deaths;
ratio = int(ratio);
ratio = ratio/10000.0;
you will have 5 numbers after the decimal point.

Re: Promod scripting help

Posted: January 20th, 2013, 10:58 am
by izak1996
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

Re: Promod scripting help

Posted: January 21st, 2013, 3:18 am
by megazor
Yours is actually the same as mine. I used three lines to make it simple for understanding.

Re: Promod scripting help

Posted: January 26th, 2013, 10:31 pm
by izak1996
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 :)