PDA

View Full Version : problem with my scripts



ORDI
6th April 2014, 20:04
hello everybody

i have a problem
my mod do lag the servers so my mod seems to be correct, i dont get a error in the scripts, where is the problem?
many of scripts? i have:
-ranksystem
-account system
-prestige
-HUD kills,deaths,bashes,headshots,leader(if he is leader, it mark yes else no)
-i have 11 menus
so you can help me?
thoumta tell me that it's my whiles but idk what do or change...
xfire: ordi37zk

ORDI
6th April 2014, 20:29
in my local server, the server started to lag when i started to open the server
in a server source internet, it lag more in more
in another, it crash
in again another it lag moment for moment

IzNoGoD
6th April 2014, 20:56
did you test with developer 1?
Is there any infinite loop?
are you aware dedicated 0 servers cannot read files except in their first frame?

Tally
6th April 2014, 21:29
hello everybody

i have a problem
my mod do lag the servers so my mod seems to be correct, i dont get a error in the scripts, where is the problem?
many of scripts? i have:
-ranksystem
-account system
-prestige
-HUD kills,deaths,bashes,headshots,leader(if he is leader, it mark yes else no)
-i have 11 menus
so you can help me?
thoumta tell me that it's my whiles but idk what do or change...
xfire: ordi37zk

Servers don't lag when there aren't any errors. So, the fact that your server is lagging tells me it is producing script runtime errors, but you simply aren't recording them. Enable logfile and you will see the errors:


set logfile "2"

This will produce a file named "console_mp.log". Open it with a text editor and search for the word "runtime".

ORDI
7th April 2014, 14:50
******* script runtime error *******
pair 'undefined' and '.txt' has unmatching types 'undefined' and 'string': (file 'ordi/tdm.gsc', line 1345)
f=openfile(self.loginname+".txt","write");

i took the acc system edit by tally in http://killtube.org/showthread.php?1845-Account-system-2-caracters
in tdm.gsc:

Callback_PlayerDisconnect()
{
if(isdefined(self.login)) self saveacc();

if(!level.splitscreen)
iprintln(&"MP_DISCONNECTED", self);


saveacc()
{
if(self.sessionstate=="intermission") return;
f=openfile(self.loginname+".txt","write");
fprintln(f,self.loginpw);
if(!isdefined(self.banned)) fprintln(f,0); else fprintln(f,1);
fprintln(f,self.rank);
fprintln(f,self.xp);
fprintln(f,self.kills);
fprintln(f,self.deaths);
fprintln(f,self.bashes);
fprintln(f,self.headshots);
fprintln(f,self.leader);
closefile(f);
}

loadacc()
{
f=openfile(self.loginname+".txt","read");
freadln(f);
self.loginpw=fgetarg(f,0);
self.rank=int(fgetarg(f,2));
self.xp=int(fgetarg(f,3));
self.kills=int(fgetarg(f,4));
self.deaths=int(fgetarg(f,5));
self.bashes=int(fgetarg(f,6));
self.headshots=int(fgetarg(f,7));
self.leader=int(fgetarg(f,8));
closefile(f);
}

in _account.gsc

/**/
init()
{
game["menu_login"] = "login";
game["menu_register"] = "register";
precacheMenu( game["menu_login"] );
precacheMenu( game["menu_register"] );

level thread onPlayerConnect();
}

onPlayerConnect()
{
for( ;; )
{
level waittill( "connected", player );

player thread monitorAccount();
}
}

monitorAccount()
{
self.lname = "";
self.lpw = "";
self.text = "";
self.edittext = false;
self setclientcvar( "loginname", "_" );
self setclientcvar( "loginpw", "" );
self setclientcvar( "error", "" );

for( ;; )
{
self waittill( "menuresponse", menu, response );

if( menu == "login" )
{
if( response.size == 1 && issubstr( "0123456789abcdefghijklmnopqrstuvwxyz", response[0] ) )
{
if( !self.edittext )
{
if( self.lname.size < 35 )
self.lname += response;

self setclientcvar( "loginname", self.lname + "_" );

continue;
}
else
{
if( self.lpw.size < 35 )
self.lpw += response;

self setclientcvar( "loginpw", self.lpw + "_" );

continue;
}
}
else if( response[0] == "#" )
{
if( response.size > 80 )
continue;

name="";
pw="";
for( i=1; i < response.size; i++ )
{
if( issubstr( "123456789abcdefghijklmnopqrstuvwxyz", response[i] ) )
name += response[i];

if( response[i] == "#" )
break;
}

for( i=1; i < response.size; i++ )
{
if( issubstr( "123456789abcdefghijklmnopqrstuvwxyz", response[i] ) )
pw += response[i];
}


if( name != "" && pw != "" && name.size <= 35 && pw.size <= 35 )
{
self.lname = name;
self.lpw = pw;
self.edittext = false;
self setclientcvar( "loginname",name);
self setclientcvar( "loginpw",pw);
}
}

if( response == "bs" )
{
if( !self.edittext )
{
self.lname = getsubstr( self.lname, 0, self.lname.size - 1 );
self setclientcvar( "loginname", self.lname + "_" );
continue;
}
else
{
self.lpw = getsubstr( self.lpw, 0, self.lpw.size - 1 );
self setclientcvar( "loginpw", self.lpw + "_" );
continue;
}
}

if( response == "nm" )
{
self.edittext = false;
self setclientcvar( "loginname", self.lname + "_" );
self setclientcvar( "loginpw", self.lpw );
continue;
}

if( response == "pw" )
{
self.edittext = true;
self setclientcvar( "loginname", self.lname );
self setclientcvar( "loginpw", self.lpw + "_" );
continue;
}

if( response == "ok" )
{
if( isdefined( self.login ) )
{
self thread er( "^7Vec ste prijavljeni^3!", "^7You^3'^7re already logged in^3!" );
continue;
}

if( self.lname == "" )
{
self thread er( "^7Nisi unio naziv^3!", "^7Please specify a name^3!" );
continue;
}

if( self.lpw == "" )
{
self thread er( "^7Nisi unio zaporku^3!", "^7Please specify a password^3!" );
continue;
}

f = openfile( self.lname + ".cfg", "read" );

if( f == -1 )
{
self thread er( "^7Korisnik ne postoji^3!", "^7No such user^3!" );
continue;
}

freadln( f );
if( fgetarg( f, 0 ) != self.lpw )
{
self thread er( "^7Pogresna lozinka^3!", "^7Invalid password^3!" );
closefile( f );
continue;
}

if( int( fgetarg( f, 1 ) ) )
{
self thread er( "^7Profil je izbrisan^3!", "^7ACCOUNT BANNED^3!" );
closefile( f );
continue;
}

closefile( f );

players = getentarray( "player", "classname" );
for( i=0; i < players.size; i++ )
if( isdefined( players[i].loginname ) && players[i].loginname == self.lname )
break;

/* if( i !=players.size )
{
self thread er("^7To ime je trenutno u upotrebi^3!", "^7This username is currently in use^3!" );
continue;
}
*/

self.loginname = self.lname;
self.loginpw = self.lpw;
self ordi\tdm::loadacc();
self.login = true;
self setclientcvar( "execute", "seta autologin openscriptmenu menu_login #" + self.loginname + "#" + self.loginpw + ";writeconfig logininfo.cfg" );
self closemenu();
self closeInGameMenu();
wait .1;
self closemenu();
self closeInGameMenu();
}
}
else if ( menu == "register" )
{
if( response.size == 1 && issubstr( "0123456789abcdefghijklmnopqrstuvwxyz", response[0] ) )
{
if( !self.edittext )
{
if( self.lname.size < 35 )
self.lname += response;
self setclientcvar( "loginname", self.lname + "_" );
continue;
}
else
{
if(self.lpw.size<35) self.lpw+=response;
self setclientcvar("loginpw",self.lpw+"_");
continue;
}
}

if( response == "bs" )
{
if( !self.edittext )
{
self.lname=getsubstr(self.lname,0,self.lname.size-1);
self setclientcvar("loginname",self.lname+"_");
continue;
}
else
{
self.lpw=getsubstr(self.lpw,0,self.lpw.size-1);
self setclientcvar("loginpw",self.lpw+"_");
continue;
}
}

if( response == "nm" )
{
self.edittext=false;
self setclientcvar("loginname",self.lname+"_");
self setclientcvar("loginpw",self.lpw);
continue;
}

if( response == "pw" )
{
self.edittext=true;
self setclientcvar("loginname",self.lname);
self setclientcvar("loginpw",self.lpw+"_");
continue;
}

if( response == "ok" )
{
if(isdefined(self.login)) {self thread er("^7Vec si prijavljen^3!","^7You^3'^7re already logged in^3!");continue;}
if(self.lname=="") {self thread er("^7Nisi unio naziv^3!","^7Please specify a name^3!");continue;}
if(self.lpw=="") {self thread er("^7Nisi unio lozinku^3!","^7Please specify a password^3!");continue;}
f=openfile(self.lname+".cfg","read");
if(f!=-1) {self thread er("^7To ime je zauzeto^3, ^7odaberite drugo^3!","^7This name is occupied^3, ^7choose an other one^3!");closefile(f);continue;}
self.loginname=self.lname;
self.loginpw=self.lpw;
self.login=true;
self ordi\tdm::saveacc();
self ordi\tdm::loadacc();
f=openfile("_users.cfg","append");
fprintln(f,"\n"+self.loginname);
closefile(f);
self thread er("^7Registracija je uspjela^3!","^7Registration successful^3!");
self setclientcvar("execute","seta autologin openscriptmenu menu_login #"+self.loginname+"#"+self.loginpw+";writeconfig logininfo.cfg");
wait .1;
self closemenu();
self closeInGameMenu();
wait .1;
self closemenu();
self closeInGameMenu();
self iprintlnbold("hello!");
}
}




}
}

er( text1, text2 )
{
self endon( "disconnect" );

self notify( "enderror" );
self endon( "enderror" );

self setclientcvar( "error", text2 );

wait( 1.5 );

self setclientcvar( "error", "" );
}

what i have to do?

Tally
8th April 2014, 11:36
******* script runtime error *******
pair 'undefined' and '.txt' has unmatching types 'undefined' and 'string': (file 'ordi/tdm.gsc', line 1345)
f=openfile(self.loginname+".txt","write");

i took the acc system edit by tally in http://killtube.org/showthread.php?1845-Account-system-2-caracters
in tdm.gsc:

Callback_PlayerDisconnect()
{
if(isdefined(self.login)) self saveacc();

if(!level.splitscreen)
iprintln(&"MP_DISCONNECTED", self);


saveacc()
{
if(self.sessionstate=="intermission") return;
f=openfile(self.loginname+".txt","write");
fprintln(f,self.loginpw);
if(!isdefined(self.banned)) fprintln(f,0); else fprintln(f,1);
fprintln(f,self.rank);
fprintln(f,self.xp);
fprintln(f,self.kills);
fprintln(f,self.deaths);
fprintln(f,self.bashes);
fprintln(f,self.headshots);
fprintln(f,self.leader);
closefile(f);
}

loadacc()
{
f=openfile(self.loginname+".txt","read");
freadln(f);
self.loginpw=fgetarg(f,0);
self.rank=int(fgetarg(f,2));
self.xp=int(fgetarg(f,3));
self.kills=int(fgetarg(f,4));
self.deaths=int(fgetarg(f,5));
self.bashes=int(fgetarg(f,6));
self.headshots=int(fgetarg(f,7));
self.leader=int(fgetarg(f,8));
closefile(f);
}

in _account.gsc

/**/
init()
{
game["menu_login"] = "login";
game["menu_register"] = "register";
precacheMenu( game["menu_login"] );
precacheMenu( game["menu_register"] );

level thread onPlayerConnect();
}

onPlayerConnect()
{
for( ;; )
{
level waittill( "connected", player );

player thread monitorAccount();
}
}

monitorAccount()
{
self.lname = "";
self.lpw = "";
self.text = "";
self.edittext = false;
self setclientcvar( "loginname", "_" );
self setclientcvar( "loginpw", "" );
self setclientcvar( "error", "" );

for( ;; )
{
self waittill( "menuresponse", menu, response );

if( menu == "login" )
{
if( response.size == 1 && issubstr( "0123456789abcdefghijklmnopqrstuvwxyz", response[0] ) )
{
if( !self.edittext )
{
if( self.lname.size < 35 )
self.lname += response;

self setclientcvar( "loginname", self.lname + "_" );

continue;
}
else
{
if( self.lpw.size < 35 )
self.lpw += response;

self setclientcvar( "loginpw", self.lpw + "_" );

continue;
}
}
else if( response[0] == "#" )
{
if( response.size > 80 )
continue;

name="";
pw="";
for( i=1; i < response.size; i++ )
{
if( issubstr( "123456789abcdefghijklmnopqrstuvwxyz", response[i] ) )
name += response[i];

if( response[i] == "#" )
break;
}

for( i=1; i < response.size; i++ )
{
if( issubstr( "123456789abcdefghijklmnopqrstuvwxyz", response[i] ) )
pw += response[i];
}


if( name != "" && pw != "" && name.size <= 35 && pw.size <= 35 )
{
self.lname = name;
self.lpw = pw;
self.edittext = false;
self setclientcvar( "loginname",name);
self setclientcvar( "loginpw",pw);
}
}

if( response == "bs" )
{
if( !self.edittext )
{
self.lname = getsubstr( self.lname, 0, self.lname.size - 1 );
self setclientcvar( "loginname", self.lname + "_" );
continue;
}
else
{
self.lpw = getsubstr( self.lpw, 0, self.lpw.size - 1 );
self setclientcvar( "loginpw", self.lpw + "_" );
continue;
}
}

if( response == "nm" )
{
self.edittext = false;
self setclientcvar( "loginname", self.lname + "_" );
self setclientcvar( "loginpw", self.lpw );
continue;
}

if( response == "pw" )
{
self.edittext = true;
self setclientcvar( "loginname", self.lname );
self setclientcvar( "loginpw", self.lpw + "_" );
continue;
}

if( response == "ok" )
{
if( isdefined( self.login ) )
{
self thread er( "^7Vec ste prijavljeni^3!", "^7You^3'^7re already logged in^3!" );
continue;
}

if( self.lname == "" )
{
self thread er( "^7Nisi unio naziv^3!", "^7Please specify a name^3!" );
continue;
}

if( self.lpw == "" )
{
self thread er( "^7Nisi unio zaporku^3!", "^7Please specify a password^3!" );
continue;
}

f = openfile( self.lname + ".cfg", "read" );

if( f == -1 )
{
self thread er( "^7Korisnik ne postoji^3!", "^7No such user^3!" );
continue;
}

freadln( f );
if( fgetarg( f, 0 ) != self.lpw )
{
self thread er( "^7Pogresna lozinka^3!", "^7Invalid password^3!" );
closefile( f );
continue;
}

if( int( fgetarg( f, 1 ) ) )
{
self thread er( "^7Profil je izbrisan^3!", "^7ACCOUNT BANNED^3!" );
closefile( f );
continue;
}

closefile( f );

players = getentarray( "player", "classname" );
for( i=0; i < players.size; i++ )
if( isdefined( players[i].loginname ) && players[i].loginname == self.lname )
break;

/* if( i !=players.size )
{
self thread er("^7To ime je trenutno u upotrebi^3!", "^7This username is currently in use^3!" );
continue;
}
*/

self.loginname = self.lname;
self.loginpw = self.lpw;
self ordi\tdm::loadacc();
self.login = true;
self setclientcvar( "execute", "seta autologin openscriptmenu menu_login #" + self.loginname + "#" + self.loginpw + ";writeconfig logininfo.cfg" );
self closemenu();
self closeInGameMenu();
wait .1;
self closemenu();
self closeInGameMenu();
}
}
else if ( menu == "register" )
{
if( response.size == 1 && issubstr( "0123456789abcdefghijklmnopqrstuvwxyz", response[0] ) )
{
if( !self.edittext )
{
if( self.lname.size < 35 )
self.lname += response;
self setclientcvar( "loginname", self.lname + "_" );
continue;
}
else
{
if(self.lpw.size<35) self.lpw+=response;
self setclientcvar("loginpw",self.lpw+"_");
continue;
}
}

if( response == "bs" )
{
if( !self.edittext )
{
self.lname=getsubstr(self.lname,0,self.lname.size-1);
self setclientcvar("loginname",self.lname+"_");
continue;
}
else
{
self.lpw=getsubstr(self.lpw,0,self.lpw.size-1);
self setclientcvar("loginpw",self.lpw+"_");
continue;
}
}

if( response == "nm" )
{
self.edittext=false;
self setclientcvar("loginname",self.lname+"_");
self setclientcvar("loginpw",self.lpw);
continue;
}

if( response == "pw" )
{
self.edittext=true;
self setclientcvar("loginname",self.lname);
self setclientcvar("loginpw",self.lpw+"_");
continue;
}

if( response == "ok" )
{
if(isdefined(self.login)) {self thread er("^7Vec si prijavljen^3!","^7You^3'^7re already logged in^3!");continue;}
if(self.lname=="") {self thread er("^7Nisi unio naziv^3!","^7Please specify a name^3!");continue;}
if(self.lpw=="") {self thread er("^7Nisi unio lozinku^3!","^7Please specify a password^3!");continue;}
f=openfile(self.lname+".cfg","read");
if(f!=-1) {self thread er("^7To ime je zauzeto^3, ^7odaberite drugo^3!","^7This name is occupied^3, ^7choose an other one^3!");closefile(f);continue;}
self.loginname=self.lname;
self.loginpw=self.lpw;
self.login=true;
self ordi\tdm::saveacc();
self ordi\tdm::loadacc();
f=openfile("_users.cfg","append");
fprintln(f,"\n"+self.loginname);
closefile(f);
self thread er("^7Registracija je uspjela^3!","^7Registration successful^3!");
self setclientcvar("execute","seta autologin openscriptmenu menu_login #"+self.loginname+"#"+self.loginpw+";writeconfig logininfo.cfg");
wait .1;
self closemenu();
self closeInGameMenu();
wait .1;
self closemenu();
self closeInGameMenu();
self iprintlnbold("hello!");
}
}




}
}

er( text1, text2 )
{
self endon( "disconnect" );

self notify( "enderror" );
self endon( "enderror" );

self setclientcvar( "error", text2 );

wait( 1.5 );

self setclientcvar( "error", "" );
}

what i have to do?

You should read the thread - the script (which I did not write, only ammended) does not work with any file types other than ".cfg". It will NOT work (for somone reason) with ".txt".

I didn't write

ORDI
8th April 2014, 15:07
.cfg dont work too, same error

IzNoGoD
8th April 2014, 15:27
.cfg wont make an undefined var magically defined.

Try to debug it first, i think .lname instead of .loginname should help you a lot already

Rocky
9th April 2014, 08:50
That is working fine.. i'm using that accounts (you did something wrong :) )

ORDI
9th April 2014, 10:58
i placed:

if(isdefined(self.login)) self saveacc();

in player disconnect (tdm.gsc)
and:

saveacc()
{
if(self.sessionstate=="intermission") return;
f=openfile(self.loginname+".txt","write");
fprintln(f,self.loginpw);
if(!isdefined(self.banned)) fprintln(f,0); else fprintln(f,1);
fprintln(f,self.rank);
fprintln(f,self.xp);
fprintln(f,self.kills);
fprintln(f,self.deaths);
fprintln(f,self.bashes);
fprintln(f,self.headshots);
fprintln(f,self.leader);
closefile(f);
}

loadacc()
{
f=openfile(self.loginname+".txt","read");
freadln(f);
self.loginpw=fgetarg(f,0);
self.rank=int(fgetarg(f,2));
self.xp=int(fgetarg(f,3));
self.kills=int(fgetarg(f,4));
self.deaths=int(fgetarg(f,5));
self.bashes=int(fgetarg(f,6));
self.headshots=int(fgetarg(f,7));
self.leader=int(fgetarg(f,8));
closefile(f);
} in zom.gsc
i changed only the maps\mp\gametypes... for ordi\_account

Tally
9th April 2014, 11:00
That is working fine.. i'm using that accounts (you did something wrong :) )

Yeah, he must have missed some stuff and left things undefined somewhere. After all, he ported the script from SD gametype file to TDM. So, he must have forgotten to initialize the arrays at callback_startgametype.

ORDI
9th April 2014, 11:07
already placed, i forgotten to say:

thread ordi\_account::init();
thread ordi\_menus::init();
thread maps\mp\gametypes\_serversettings::init();
thread maps\mp\gametypes\_clientids::init();
thread maps\mp\gametypes\_teams::init();
thread maps\mp\gametypes\_weapons::init();
thread maps\mp\gametypes\_scoreboard::init();
thread maps\mp\gametypes\_killcam::init();
thread maps\mp\gametypes\_shellshock::init();
thread maps\mp\gametypes\_hud_teamscore::init();
thread maps\mp\gametypes\_deathicons::init();
thread maps\mp\gametypes\_damagefeedback::init();
thread maps\mp\gametypes\_healthoverlay::init();
thread maps\mp\gametypes\_friendicons::init();
thread maps\mp\gametypes\_spectating::init();
thread maps\mp\gametypes\_grenadeindicators::init();
thread ordi\hud::main();
thread ordi\_pchud::init();
thread ordi\_unknownsoldier::onPlayerConnect();

ORDI
12th April 2014, 11:22
mhm btw rocky, like you use this acc system, have you ever done "developper 1"?
you will see problems, i am sure ;)
i tested your mod placed on killtube, i did developper 1 and many error ;)
i tried to do a mod zom, nothing of HUD atm, only quickoption and i placed bjuster taunts, i get script runtime error when i do "developper 1", if i open only the console, the server work but if i use V+6+1 (show fps) i get script runtime error

******* script runtime error *******
pair 'undefined' and '0' has unmatching types 'undefined' and 'int': (file 'maps/mp/gametypes/_quickmessages.gsc', line 55)
if(self.drawfps == 0)
*
called from:
(file 'maps/mp/gametypes/_zommenus.gsc', line 172)
maps\mp\gametypes\_quickmessages::quickoptions(res ponse);
*
started from:
(file 'maps/mp/gametypes/_zommenus.gsc', line 56)
self waittill("menuresponse", menu, response);
*
************************************
********************
ERROR: script runtime error
(see console for details)
(file 'maps/mp/gametypes/_zommenus.gsc', line 56)

********************
----- Server Shutdown -----
Sending heartbeat to cod2master.activision.com
==== ShutdownGame ====
Going to CS_ZOMBIE for ^2#^5ORDI^2~^0(fr)
0:^2#^5ORDI^2~^0(fr) EXE_DISCONNECTED
---------------------------
i wouldn't show you my scripts on killtube (because i do not want that other people here, use that) on xfire or teamviewer but i want to know where is the problem, i looked some mods found on internet, with a option menu and i tested, it bug also.
so a person can help me, then contact me on xfire and i will show. :)
xfire: ordi37zk

Mitch
12th April 2014, 11:27
(show fps) i get script runtime error

******* script runtime error *******
pair 'undefined' and '0' has unmatching types 'undefined' and 'int': (file 'maps/mp/gametypes/_quickmessages.gsc', line 55)
if(self.drawfps == 0)



the easiest way to fix this run time error is this:


if(!isDefined(self.drawfps) || (isDefined(self.drawfps) && self.drawfps == 0))
....

ORDI
12th April 2014, 12:01
i resolved otherwise:

if(response == "PO6")
{
self setclientcvar("cg_drawfps", 1);
}