Scripting Healthpacks that drop on death
Moderator: Core Staff
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Scripting Healthpacks that drop on death
where is dropHealth being called?
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
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: Scripting Healthpacks that drop on death
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
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.
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
exactly why i made the self endon("spawned_player") in my script.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.
Re: Scripting Healthpacks that drop on death
Yours could still run twice, if the onPlayerSpawned is run twice.
Re: Scripting Healthpacks that drop on death
Onplayerspawned sends out a nice notify: "spawned_player"Nekoneko wrote:Yours could still run twice, if the onPlayerSpawned is run twice.
Re: Scripting Healthpacks that drop on death
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? ^^
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? ^^
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Scripting Healthpacks that drop on death
If I had 10 functions calling one function once EACH, there would be 10 functions.F |Madness| U wrote:It's in various other functions, but each of these functions are only called once, and it originates from onPlayerSpawned.
The likelyhood is that this function is being called twice... because of two separate functions.
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
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: Scripting Healthpacks that drop on death
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 modDrofder2004 wrote:If I had 10 functions calling one function once EACH, there would be 10 functions.F |Madness| U wrote:It's in various other functions, but each of these functions are only called once, and it originates from onPlayerSpawned.
The likelyhood is that this function is being called twice... because of two separate functions.
-
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: Scripting Healthpacks that drop on death
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. 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
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;
    }
}
-
Re: Scripting Healthpacks that drop on death
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;
}
-
- Core Staff
- Posts: 13313
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: Scripting Healthpacks that drop on death
The Dvar does not exist until you "set" it..F |Madness| U wrote:I load my map, type /scr_say testing into console, and I just get "unknown cmd scr_say".Arghh
So, you can either do "/set scr_say hello" in console or commonly
Code: Select all
if(getDvar("customDvar") == "")
  setDvar("customDvar", "customValue")
Code: Select all
setDvar("customDvar", "");
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
Re: Scripting Healthpacks that drop on death
Am I missing something?
You do not have the required permissions to view the files attached to this post.
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: Scripting Healthpacks that drop on death
@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.
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
well does it say "nothing" once you connect and type in /scr_say
Who is online
Users browsing this forum: No registered users and 24 guests