Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 57 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: level.onTimeLimit results in "self" becoming undefined
mortifer
General Member
Since: Jul 19, 2015
Posts: 19
Last: Jul 6, 2016
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Monday, Jun. 6, 2016 03:15 pm
As soon as level.onTimeLimit is reached, any reference whatsoever to "self" instantly creates an error of overrun string in call to va() claiming that self is undefined (struct is not an entity). Even just a simple self.iprintlnbold() triggers it.

Any idea why self becomes undefined?

edited on Jun. 6, 2016 08:26 am by mortifer
Share |
DeekCiti
General Member
Since: Mar 13, 2008
Posts: 1293
Last: Jul 9, 2016
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Jun. 6, 2016 03:38 pm
It would be easier to see the actual method in question. Just post the chunk of code that you are having trouble with.
Share |
mortifer
General Member
Since: Jul 19, 2015
Posts: 19
Last: Jul 6, 2016
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Monday, Jun. 6, 2016 03:42 pm
I mean, literally just that 1 line of code in that function.

Code:
onTimeLimit() {
    self iprintlnbold("time limit reached");
}


ANY single line that refers to the self entity will error claiming that self is not an entity.

edited on Jun. 6, 2016 08:43 am by mortifer
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Monday, Jun. 6, 2016 05:31 pm
What is 'self' in that function? Where is the function being called from? What is the function being called on?

What the function is being called on will define 'self'.

Basically, post all of your code.
Share |
mortifer
General Member
Since: Jul 19, 2015
Posts: 19
Last: Jul 6, 2016
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Monday, Jun. 6, 2016 11:58 pm
There isn't really anything else to post. It is literally JUST that. In main there is level.onTimeLimit = ::onTimeLimit; and that simple iprintlnbold. That all by itself causes the error and claims that self is not an entity.
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Tuesday, Jun. 7, 2016 12:11 am
What are you expecting 'self' to be?

Somewhere in _globallogic.gsc or the gametype .gsc there should be a line that looks something like this:

Code:

[[level.onTimeLimit]]();


'self' will be undefined in the onTimeLimit() function since it was not called on anything. If you want to print something to all players then just do:

Code:

onTimeLimit() {
	iprintlnbold("time limit reached");
}


If iPrintln or iPrintlnBold is not called on anything then it will print to all players.


Here's an example where 'self' will be defined:

Code:

bleh()
{
	players = getentarray("player", "classname");
	for(i=0;i<players.size;i++)
		players[i] doStuff(); // doStuff() was called on players[i], which is a player
}

doStuff()
{
	self suicide(); // self is the player
}
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Tuesday, Jun. 7, 2016 12:12 am
Oops clicked quote to edit and ended up with 2 posts xd
Share |
mortifer
General Member
Since: Jul 19, 2015
Posts: 19
Last: Jul 6, 2016
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Jun. 7, 2016 12:50 am
I love replying and then finding out the forums page had an error and failed to post my long reply! ;)


All I have done is taken the dm.gsc from my custom pml220 mod. In it it makes all the callbacks from globallogic.

Code:
    maps\mp\gametypes\_globallogic::init();
    maps\mp\gametypes\_callbacksetup::SetupCallbacks();
    maps\mp\gametypes\_globallogic::SetupCallbacks();
    level.onStartGameType = ::onStartGameType;
    level.onSpawnPlayer = ::onSpawnPlayer;
    level.onPlayerKilled = ::onPlayerKilled;
    level.onTimeLimit = ::onTimeLimit;
    level.onScoreLimit = ::onScoreLimit;
    level.onEndGame = ::onEndGame;


Code:
onTimeLimit() {
    // remove the line below and the script works perfectly
    self iprintlnbold("time limit reached"); // error claiming "self" is not an entity<br />
<br />
    winner = undefined;
    if (level.teamBased) {
        if (game["teamScores"]["allies"] == game["teamScores"]["axis"]) winner = "tie";
        else if (game["teamScores"]["axis"] > game["teamScores"]["allies"]) winner = "axis";
        else winner = "allies";
    } else winner = maps\mp\gametypes\_globallogic::getHighestScoringPlayer();
    makeDvarServerInfo("ui_text_endreason", game["strings"]["time_limit_reached"]);
    setDvar("ui_text_endreason", game["strings"]["time_limit_reached"]);
    thread maps\mp\gametypes\_globallogic::endGame(winner, game["strings"]["time_limit_reached"]);
}


I came across this because at the top of onTimeLimit() I added a final call for a custom killcam script I made. It works 100% except for when attempting to call it at the top of onTimeLimit(). If I put it back there, it errors on the first line referencing "self" claiming same as the iprintlnbold().

edited on Jun. 6, 2016 05:51 pm by mortifer

edited on Jun. 6, 2016 05:51 pm by mortifer
Share |
FzBr.d4rk
General Member
Since: Jan 23, 2011
Posts: 86
Last: Jun 7, 2016
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Tuesday, Jun. 7, 2016 07:51 am
Simply remove "self" in the beginning and it should work.

Code:

onTimeLimit() 
{ 
       iprintlnbold("time limit reached"); 
      // code 
}
Share |
mortifer
General Member
Since: Jul 19, 2015
Posts: 19
Last: Jul 6, 2016
[view latest posts]
Level 1
Category: CoD4 Scripting
Posted: Tuesday, Jun. 7, 2016 11:38 pm
The iprintlnbold is just a debug attempt. A few posts back I mentioned that this is for a final killcam with pml220. The player killed data is being stored and I need to be able to access that later at the end of the match. Is there something wrong with storing it as level instead of self since self appears to get deallocated?
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»