Re: Scripting Healthpacks that drop on death
Posted: July 12th, 2011, 1:10 pm
where is dropHealth being called?
CoDJumper.com - For all your CoDJumping needs!
https://codjumper.com/~codjumpe/forums/
https://codjumper.com/~codjumpe/forums/viewtopic.php?t=13936
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.
Onplayerspawned sends out a nice notify: "spawned_player"Nekoneko wrote:Yours could still run twice, if the onPlayerSpawned is run twice.
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.
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.
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;
    }
}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? ^^
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;
}
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
Code: Select all
if(getDvar("customDvar") == "")
  setDvar("customDvar", "customValue")Code: Select all
setDvar("customDvar", "");