Page 2 of 3
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 1:10 pm
by Drofder2004
where is dropHealth being called?
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 1:31 pm
by F |Madness| U
It's in various other functions, but each of these functions are only called once, and it originates from onPlayerSpawned.
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 2:15 pm
by Nekoneko
what I would do for debug is:
at the start of the script put in a
self endon("delete_healthpack");
self notify("delete_healthpack");
So, if it is running twice, it'll stop.
If it now only gives you health once, you know it's being called twice.
Also
Your do_healthtrigger never ends, unless it's triggered (not a bad problem, but it's still running in the background forever)
So you could also end the do_healthtrigger on a notify and in the first script after 30 secs, notify, so that it will stop.
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 2:21 pm
by IzNoGoD
Nekoneko wrote:what I would do for debug is:
at the start of the script put in a
self endon("delete_healthpack");
self notify("delete_healthpack");
So, if it is running twice, it'll stop.
If it now only gives you health once, you know it's being called twice.
Also
Your do_healthtrigger never ends, unless it's triggered (not a bad problem, but it's still running in the background forever)
So you could also end the do_healthtrigger on a notify and in the first script after 30 secs, notify, so that it will stop.
exactly why i made the self endon("spawned_player") in my script.
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 2:27 pm
by Nekoneko
Yours could still run twice, if the onPlayerSpawned is run twice.
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 7:17 pm
by IzNoGoD
Nekoneko wrote:Yours could still run twice, if the onPlayerSpawned is run twice.
Onplayerspawned sends out a nice notify: "spawned_player"

Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 8:23 pm
by Nekoneko
I don't get it..
When the player spawns the script will stop.
But onPlayerSpawned runs the script.
So if onPlayerSpawned is run twice, it will run twice too.
More on topic:
And did it work? ^^
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 8:31 pm
by Drofder2004
F |Madness| U wrote:It's in various other functions, but each of these functions are only called once, and it originates from onPlayerSpawned.
If I had 10 functions calling one function once EACH, there would be 10 functions.
The likelyhood is that this function is being called twice... because of two separate functions.
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 9:51 pm
by F |Madness| U
Drofder2004 wrote:F |Madness| U wrote:It's in various other functions, but each of these functions are only called once, and it originates from onPlayerSpawned.
If I had 10 functions calling one function once EACH, there would be 10 functions.
The likelyhood is that this function is being called twice... because of two separate functions.
EDIT: It was infact called twice..most bizarrely however. Since I have been testing the mod with bots (I used somebody elses code for spawning bots since I was a pure noob when I started), in the thread where bots are spawned, I found the line bot thread onPlayerSpawned(). No idea why he needed to call it there, so yeah basically there was onPlayerSpawned() being called when the bots were initiated, and when the bots connected to the server. Anyway the problem has solved and it has also fixed many other smaller issues in my mod

Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 10:52 pm
by F |Madness| U
I also have a small problem regarding custom Dvars however, (kinda aimed at Drofder since I read his guide on them).
When I create a custom dvar in my gsc, I go into my mod and type the dvar, however it simply says unknown command.
Eg.
Code: Select all
sayCommand()
{
    if(getdvar("scr_say") == "")
    {
        setdvar("scr_say", "nothing");
    }
    while(1)
    {
        if(getDvar("scr_say") != "nothing")
        {
            abc = getDvar("scr_say");
            iprintlnbold(abc);
            setDvar("scr_say", "nothing");
        }
        wait 0.1;
    }
}
Threaded on the level when the server starts. I load my map, type /scr_say testing into console, and I just get "unknown cmd scr_say".Arghh
Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 11:37 pm
by IzNoGoD
Nekoneko wrote:I don't get it..
When the player spawns the script will stop.
But onPlayerSpawned runs the script.
So if onPlayerSpawned is run twice, it will run twice too.
More on topic:
And did it work? ^^
Lets simplify things:
Code: Select all
onplayerspawned()
{
self notify("spawned_player"); //this is in the stock function
self thread drophealth();
}
drophealth()
{
self endon("spawned_player");
while(true)
wait 0.05;
}
see that the function can only be running once?
Re: Scripting Healthpacks that drop on death
Posted: July 13th, 2011, 2:27 am
by Drofder2004
F |Madness| U wrote:I load my map, type /scr_say testing into console, and I just get "unknown cmd scr_say".Arghh
The Dvar does not exist until you "set" it..
So, you can either do
"/set scr_say hello" in console or commonly
Code: Select all
if(getDvar("customDvar") == "")
  setDvar("customDvar", "customValue")
or, if you are making a DVAR you want to start empty:
Now, you can simply load "/customDvar customValue" without the need to set it first.
Re: Scripting Healthpacks that drop on death
Posted: July 13th, 2011, 11:47 am
by Nekoneko
Am I missing something?
Re: Scripting Healthpacks that drop on death
Posted: July 13th, 2011, 12:35 pm
by F |Madness| U
@Drofder, I still don't see what's wrong with my code?
It checks to see if the dvar scr_say exists (which it doesn't), and then sets the dvar to equal "nothing".
Then it infinitely checks to see if the dvar equals something other than "nothing", and prints what it equals. Surely when I type in console /scr_say TEST , that will change the value of the dvar from "nothing" to "TEST", and it will then print it? Am I missing something? ALso with dvars in Black Ops you can't use `set` ingame for some reason. Ie. /set g_gametype dm wouldn't work, but /g_gametype dm does.
Re: Scripting Healthpacks that drop on death
Posted: July 13th, 2011, 1:11 pm
by Nekoneko
well does it say "nothing" once you connect and type in /scr_say