PDA

View Full Version : Problem with UFO script



genez_x
18th May 2017, 20:59
Hi, I use the codjumper mod on a paid server and I'v added a (ufo) script and it works very well for at least one day and as admin I use the admin menu and I noticed that when I use it the server lags.
I asked this on the cod4x forum 2 weeks ago and one of them told me this: "for(;; ) - linker never gets deleted. Memory leak."
Pros: maintaining r pressed you move wherever you want and stop it with space.
Cons: admin menu does not work a day after the server is up.


_Noclip()
{
self endon("disconnect");
self endon("killed_player");
linker = spawn("script_origin", self.origin);
for(;;)
{
if(self reloadbuttonpressed())
{
self linkto(linker);
m=380;
o=anglestoforward(self getplayerangles());
linker moveto((linker.origin+(o[0]*m,o[1]*m,o[2]*m)),0.05);
wait 0.05;
}else if(self jumpButtonPressed()){
self unlink();
wait 0.05;
}
wait 0.05;
}
linker delete();
wait 2;
}

PD: If you have time, help please.

IzNoGoD
18th May 2017, 22:06
Possibly that, or possibly that you're trying to linkto() an entity that's already linkto()'d, which might produce an error message.

Linker gets deleted properly, except in the case that a player dies or disconnects. Shouldn't be too much of an issue unless you have tons of players and never change the map.

IzNoGoD
18th May 2017, 22:54
Just looked at the script again. Why are you moving the linker 380 units per serverframe? Do you really need your clients to be racing through the map with noclip at 7600 units/sec?

genez_x
19th May 2017, 03:30
First of all, thanks for the answers IzNoGoD, I forgot to write that function only works for vip and admin, then there should be fewer problems because less people get to use that function?
PS: (380) can cause any problems?
If so what number should be safe.
PS2:mod codjumperv3_12b.
PS3:A couple minutes ago I looked the server log and saw that there's no evidence of script failure from _noclip() but a ton of script failure from the admin control script that I think it appears when we use the admin menu.
PS4:A couple hours from I will post the errors.

IzNoGoD
19th May 2017, 09:11
Try reducing m to something sensible, like 20, and remove the additional wait 0.05's. Only keep the one right before linker delete();