Page 1 of 3
if failure?
Posted: September 18th, 2010, 3:41 pm
by Moustache
How is it possible that a script just executes a code in the if statement while the if statement isn't correct?
This is what I am talking about:
Code: Select all
if (self.clientid == warn[0])
{
self IPrintLnBold(self.clientid);
self IPrintLnBold(warn[0]);
}
On my screen I see:
1
0
WTF?
How can it be printed while 1 is not equal to 0?
Re: if failure?
Posted: September 18th, 2010, 4:22 pm
by waywaaaard
!=
Re: if failure?
Posted: September 18th, 2010, 4:27 pm
by Moustache
waywaaaard wrote:!=
I know that that means is not. But I think you don't understand me.
Why does the script print the values? Even when the values are not equal to each other?
And when I tried != I still get the same thing.
Re: if failure?
Posted: September 18th, 2010, 4:50 pm
by waywaaaard
is any other thread using those vars? Would print them out before the if and inside it. So maybe it changes. And or try to cast both to int with int(warn[0]) == int(self.clientid)
Re: if failure?
Posted: September 18th, 2010, 10:26 pm
by Drofder2004
What are the assigned values of these variable, because my guess is that we have mis-matched types (one being a string), but the code is not throwing an error.
Re: if failure?
Posted: September 19th, 2010, 8:59 am
by Moustache
Actually my whole system fails.
I want a system where you can send a command to the server with the player slot in it and a warning message.
My script doesn't work good. It only works when I place the command in the .cfg file. Because when I send it to the server when the server is running it doesn't work. I don't know what I am doing wrong
I hope someone can and is willing to help me.
Re: if failure?
Posted: September 19th, 2010, 10:22 am
by Opel
Code: Select all
SayPlayer()
{
tokens = strTok( getDvar("jmp_say"), ":");
if(tokens.size == 2)
{
players = getEntArray("player", "classname");
for(i=0; i<players.size; i++)
{
playernum = players[i] getEntityNumber();
if(playernum == int(tokens[0] ))
{
players[i] iprintlnbold(tokens[1]);
break;
}
}
}
setDvar("jmp_say", "");
}
Mabye try something like that. I havent tested it though
Re: if failure?
Posted: September 19th, 2010, 10:58 am
by Drofder2004
The above should work fine.
Although to add the loop:
Code: Select all
SayPlayer()
{
for(;;)
{
setDvar("jmp_say", "");
while(getDvar("jmp_say") == "")
wait 0.05;
tokens = strTok( getDvar("jmp_say"), ":");
if(tokens.size == 2)
{
players = getEntArray("player", "classname");
for(i=0; i<players.size; i++)
{
playernum = players[i] getEntityNumber();
if(playernum == int(tokens[0] ))
{
// This is where you would insert your "if true" code
players[i] iprintlnbold(tokens[1]);
break;
}
}
}
}
}
Re: if failure?
Posted: September 20th, 2010, 2:45 pm
by Moustache
Thank you very much, that script works perfect
Only combined with my code, there is something strange.
Because I always see the IPrintLineBold, but not the text that should be on the hud element.
I just start the server, join it. Put in console: /rcon login [rcon_pass]
Then I type in console: /rcon set warn_player "0:Do ^1not ^3spam ^7please"
I get the IPrintLineBold warning and after 2 seconds the HUD elements. The black screen with the warning. But I don't get the: "You can continue in [number]" text.
And when I type /reconnect in console.
And then type this in console: /rcon set warn_player "0:Do ^1not ^3spam ^7please"
I get the IPrintLineBold message, but after 2 seconds I only get a black screen. Without any text in it.
How is that possible?
Re: if failure?
Posted: September 20th, 2010, 7:43 pm
by Drofder2004
you may need to add a small wait before assigning the label/text to a hud.
Re: if failure?
Posted: September 21st, 2010, 6:07 am
by Moustache
I don't see any text now, only a black screen

Re: if failure?
Posted: September 21st, 2010, 10:56 am
by Drofder2004
Use ".sort" on all your hud elements, start at 100 for the black and 101 for the text.
Re: if failure?
Posted: September 21st, 2010, 4:40 pm
by Moustache
Thanks again, that worked
But when I reconnect and type in the command again I first see the IPrintLnBold message but then I get a black screen without any text in it.
Re: if failure?
Posted: September 21st, 2010, 4:57 pm
by Drofder2004
For testing purposes, change the "setText(message)" to "setText("TESTING")"
Post results.
Re: if failure?
Posted: September 21st, 2010, 5:25 pm
by Moustache
Still the same.
Only a black screen after reconnect.