A syntax error that I can't see whats causing it.
Moderator: Core Staff
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: A syntax error that I can't see whats causing it.
Indeed, it is not the loop that causes stress. An empty loop is no more stressful than calling a blank function.
It is very dependant on what is being called inside the loops.
Generally, player loops will cause more stress, simply because there are more players than there is a 'level'.
There are few if no situation that can substitute a player to level loop (or opposite) effectively. The loop is either designed to run on a level a player.
For example, updating a players HUD would be pointless to loop in a level, updating every players HUD just so one player is up-to-date, you would just use a player loop, and the same would apply for a 'level' and team scores.
This is why we use 'Notify' calls, so that loops that require player events (kills, deaths, etc) can be acknowledged by a level based loop.
It is very dependant on what is being called inside the loops.
Generally, player loops will cause more stress, simply because there are more players than there is a 'level'.
There are few if no situation that can substitute a player to level loop (or opposite) effectively. The loop is either designed to run on a level a player.
For example, updating a players HUD would be pointless to loop in a level, updating every players HUD just so one player is up-to-date, you would just use a player loop, and the same would apply for a 'level' and team scores.
This is why we use 'Notify' calls, so that loops that require player events (kills, deaths, etc) can be acknowledged by a level based loop.

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: A syntax error that I can't see whats causing it.
I already guessed that an empty loop would cause no server stress 
But from what your saying, something like my code below wouldn't cause too much stress? (being called on the level btw).
Oh ye the `SetTimeScale();` function apprently requires 2 arguments, however after searching through many .gscs all I found was `SetTimeScale(2);` or `SetTimeScale(1);` etc, any idea on what second argument could be other than the number? This isn't CoD4 remember 

But from what your saying, something like my code below wouldn't cause too much stress? (being called on the level btw).
Code: Select all
timescale()
{
    if(getDvarFloat("scr_timescale") != 1.0)
    {
        setdvar("scr_timescale", 1.0);
    }
    timecmd = getDvarFloat("scr_timescale");
   Â
    for(;;)
    {
        wait 0.5;
        timecmd;
        SetTimeScale(timecmd);//--- expected 2 args?
    }
}

-
Re: A syntax error that I can't see whats causing it.
setcvar("timescale",2); or smthing
You can write write-protected cvars from script...
You can write write-protected cvars from script...
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: A syntax error that I can't see whats causing it.
You sure? I know there is a command in black ops (something like g_scoreboard_axiscolour) that exists, but even if you change it in script it doesn't work ingame :S
-
-
- Core Staff
- Posts: 13315
- Joined: April 13th, 2005, 8:22 pm
- Location: UK, London
Re: A syntax error that I can't see whats causing it.
Most likely because it is being reverted by another function elsewhere.F |Madness| U wrote:You sure? I know there is a command in black ops (something like g_scoreboard_axiscolour) that exists, but even if you change it in script it doesn't work ingame :S
All cheat protected server values, can, as said, be written by script.

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: A syntax error that I can't see whats causing it.
as written on zeroy's script index page, setTimeScale() is only for sp.
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: A syntax error that I can't see whats causing it.
Is there no way to use functins from SP in MP? Seems kinda stupid that any good functions in SP have to go to waste for mods..megazor wrote:as written on zeroy's script index page, setTimeScale() is only for sp.
-
Re: A syntax error that I can't see whats causing it.
to change the timescale, you can use:
setCvar("timescale", 2);
setCvar("timescale", 2);
Re: A syntax error that I can't see whats causing it.
Was already hereIzNoGoD wrote:setcvar("timescale",2); or smthing
You can write write-protected cvars from script...

-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: A syntax error that I can't see whats causing it.
Doesn't work in black ops, no idea why. But if there was some other functions in SP that arn't in MP, is tehre anyway to use them?
And also I must be really dumb, I'm trying to make something happen when a certain person is killed, and i also want damage to show when you shoot a person. I found a function which I think I should use, but I have no idea how to use it.
I'm guessing I should use them, but I really have no idea how to. To give you an idea of what I want to do, some example script:
And also I must be really dumb, I'm trying to make something happen when a certain person is killed, and i also want damage to show when you shoot a person. I found a function which I think I should use, but I have no idea how to use it.
Code: Select all
CodeCallback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
{
    self endon("disconnect");
    [[level.callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
}
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
    self endon("disconnect");
    [[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
}
Code: Select all
Showdamagereceived()
{
    for(;;)
    {
        self waittill("been_damaged");
        self iprintln(AttackerName + "inflicted " + damage " on you.");
    }
}
Â
Showdamagedone()
{
    for(;;)
    {
        self waittill("done_damage");
        self iprintln("You inflicted " + damage + " on " + DamagedName);
    }
}
Â
specialpersonkilled()
{
    if(KilledPerson == level.specialperson)
    {
        ...
    }
}
-
Re: A syntax error that I can't see whats causing it.
Do you run this mod from a dedicated server? (Lan or internet in cod2..)
Cause if you dont, it wont work. Have been messing around with that a lot myself.
Edit: the code you requested:
Its untested, but should work.
Cause if you dont, it wont work. Have been messing around with that a lot myself.
Edit: the code you requested:
Code: Select all
onserverstart()
{
wait 1; //to ensure the callbacks are already written
//store the old callbacks
level.oldcallbackPlayerDamage=level.callbackplayerdamage;
level.oldcallbackplayerkilled=level.callbackplayerkilled;
//now, create new callbacks
level.callbackplayerdamage=::damage;
level.callbackplayerkilled=::killed;
}
damage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset)
{
if(isdefined(eAttacker)&&isplayer(eAttacker)&&eAttacker!=self)
{
self iprintln(eAttacker.name+" did "+iDamage+" damage on you");
eAttacker iprintln("You did "+iDamage+" damage to "+self.name);
}
//now, do the normal callback
[[level.oldcallbackplayerdamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
}
killed(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
if(isdefined(self)&&isplayer(self)&&isdefined(level.specialperson)&&isplayer(level.specialperson)&&self==level.specialperson)
{
iprintlnbold("The special person has been killed, it was "+self.name);
iprintlnbold("Now all should cry");
}
//do the normal callback after this
[[level.oldcallbackplayerkilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
}
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: A syntax error that I can't see whats causing it.
Thanks for the help, and I'm running a listen server (other friends can connect to it, but I am the client/level at the same time).
I'll test that code you provided soon, just wondering would the damage()/killed() functions need to be infinitely looped once a player spawns? Or just called when a player spawns?
Lastly, I don't really understand the reason for the first function, nor do I understand the `callback code` at the end of damage/killed functions. This bit:
I'll test that code you provided soon, just wondering would the damage()/killed() functions need to be infinitely looped once a player spawns? Or just called when a player spawns?
Lastly, I don't really understand the reason for the first function, nor do I understand the `callback code` at the end of damage/killed functions. This bit:
Code: Select all
[[level.oldcallbackplayerdamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
-
Re: A syntax error that I can't see whats causing it.
The game creates a callback for killed/damage and stores it in level.callbackplayerdamage or level.callbackplayerkilled
This is done at the start of the game
After one second, i copy this callback into the var with OLD in the name, and overwrite the existing ones with my own functions.
Now every time a player is damaged, it will be redirected to the level.callbackplayerdamage which i created (damage()), but as you want to keep the original too, i added the [[level.oldcallbackplayerdamage]], which directs the player to the finishplayerdamage() and stuff of the original game.
Also: try NOT to be client and server at the same time when messing with server cvars.
This is done at the start of the game
After one second, i copy this callback into the var with OLD in the name, and overwrite the existing ones with my own functions.
Now every time a player is damaged, it will be redirected to the level.callbackplayerdamage which i created (damage()), but as you want to keep the original too, i added the [[level.oldcallbackplayerdamage]], which directs the player to the finishplayerdamage() and stuff of the original game.
Also: try NOT to be client and server at the same time when messing with server cvars.
-
- CJ G0D!
- Posts: 1575
- Joined: June 3rd, 2009, 9:02 pm
- Location: Cardiff University, UK
Re: A syntax error that I can't see whats causing it.
Okay I think I understand it better, thanks. Would this mean I only have to call the damage/killed functions once, when a player connects?
And I don't think its posssible to not be client/server at the same time on Blops, unless you buy an official server, which atm I don't want to do
And I don't think its posssible to not be client/server at the same time on Blops, unless you buy an official server, which atm I don't want to do

-
Re: A syntax error that I can't see whats causing it.
You only need to call the onserverstart() when the game starts
Script takes care of the rest
For the servercvar problem: set the cvar on clients when they connect
Script takes care of the rest
For the servercvar problem: set the cvar on clients when they connect
Who is online
Users browsing this forum: No registered users and 1 guest