The exact same .gsc makes the server crash on a different PC.
-
Hey everyone.
So I managed to put a very simple K/D counter on-screen and it runs absolutely fine on my main PC as a host.
On my laptop, which I use to host the server, it crashes after a couple of minutes.
Even with no players at all, server is simply running and boom, crash.
I made sure it wasn't a misconfig in dedicated.cfg and verified the "ping" on IW4M's console, which informed be the same map was running for at least 30 seconds with no players then simply killed itself.
Hope someone can help me but I dont really expect much due to the rarity of this happening.
killCount() { i = 0; while( i < level.players.size) { if(level.players[i] == self) { self thread killCountSelf(level.players[i]); } i++; wait 0.2; } } killCountSelf(thisPlayer) { self.kill = createFontString("small" , 1.3); //Fixed self.kill setPoint("TOPLEFT", undefined, -45, 87); self.death = createFontString("small" , 1.3); //Fixed self.death setPoint("TOPLEFT", undefined, -45, 100); while(true) { self.kill.label = &"^2Baixas: ^7"; self.kill setValue(thisPlayer.kills); self.death.label = &"^1Mortes: ^7"; self.death setValue(thisPlayer.deaths); wait 0.36; } }
OBS: I DO accept some coding tips as well I do have C# and typescript experience but I still feel a little lost with these scripts, specially when to use "player" or "self" because even the slightest change of these makes it not work properly (even if it looks completely logical that it would run using the "wrong/unaccepted" keyword.
Thxx
-
@GangorraAidetica I haven't tried it, but it should work.
init() { level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connected", player); player thread onPlayerSpawned(); player thread killCountSelf(); //Thread for each player } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); // Will appear each time when the player spawn, that's just an exemple. self iprintln("Black Ops 2 - GSC Studio | Project : ^2Show K/D"); } } killCountSelf() { self endon ("disconnect"); level endon("game_ended"); self.kill = createFontString("small" , 1.3); //Fixed self.kill setPoint("TOPLEFT", undefined, -45, 87); self.death = createFontString("small" , 1.3); //Fixed self.death setPoint("TOPLEFT", undefined, -45, 100); self.kill.label = &"^2Baixas: ^7"; self.death.label = &"^1Mortes: ^7"; while(true) { self.kill setValue(self.kills); self.death setValue(self.deaths); wait 0.25; } }
-
Kalitos said in The exact same .gsc makes the server crash on a different PC.:
@GangorraAidetica I haven't tried it, but it should work.
init() { level thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill("connected", player); player thread onPlayerSpawned(); player thread killCountSelf(); //Thread for each player } } onPlayerSpawned() { self endon("disconnect"); level endon("game_ended"); for(;;) { self waittill("spawned_player"); // Will appear each time when the player spawn, that's just an exemple. self iprintln("Black Ops 2 - GSC Studio | Project : ^2Show K/D"); } } killCountSelf() { self endon ("disconnect"); level endon("game_ended"); self.kill = createFontString("small" , 1.3); //Fixed self.kill setPoint("TOPLEFT", undefined, -45, 87); self.death = createFontString("small" , 1.3); //Fixed self.death setPoint("TOPLEFT", undefined, -45, 100); self.kill.label = &"^2Baixas: ^7"; self.death.label = &"^1Mortes: ^7"; while(true) { self.kill setValue(self.kills); self.death setValue(self.deaths); wait 0.25; } }
So hey dude, actually self.kills does not retrieve anything at all.
It was my very first shot on how to get the kill counter and I only reached it by using the player attribute -
@GangorraAidetica It is rare, it should work, what you do by assigning a thread to each player through the cycle, I do it by assigning a thread to each player when it connects, hence, it is all the same. "self" being inside the player, would refer to the player. I don't see why it wouldn't work.
Can you post all your code to see how you have it structured? -
@GangorraAidetica I tried it and it works, I don't know how you would implement it.
-
Kalitos said in The exact same .gsc makes the server crash on a different PC.:
@GangorraAidetica I tried it and it works, I don't know how you would implement it.
Is works indeed my dear Chuckie Finster.
But hey, what exactly explains the threading??
For example, we all know at this point the "mistery box price change" and is set as a player/self thread. Since the MB is a LEVEL entity, shouldn't it be a LEVEL thread??
cheers!
-
@GangorraAidetica I understand your idea, I explain to you, the price change of the mysterious box as I remember in a published post created a thread for each player, basically it works, but it is not the right thing, since the server will create a thread for each player and here is the point, each player will establish the price of the mystery box, instead the correct way would be to create a level thread and only with a single thread would the price of the box be established for all players and thus be avoided create a thread for each player and redo with threads that do the same and also avoid saturating the server with unnecessary threads. I hope you have explained me.
Instead, in your case, what you need is to manage the values โโof kills and deaths of each of the players, for that reason a player thread is necessary. Since the kills and deaths are unique for each player that connects to the server. Unlike the price of the box, a level thread is needed because the box is the same item that will have the same properties for all players.