PDA

View Full Version : PrecacheString (Small GameState Resource)



maxdamage99
28th September 2016, 09:50
Your main script file. (gametype.gsc: tdm.gsc,dm.gsc,zom.gsc etc.)


main()
{
thread script\_precache::init();

/* other script&function */


printf("[PRECACHE SYSTEM]\n");
printf("FakeStringsPrecache = "+level.precachestrings.size+"/"+script\_precache::FINDSTRS().size+"\n");
//FakeStringsPrecache = Your_CrackPrecachesCount/Max_CrackPrecaches (51)
printf("[/PRECACHE SYSTEM]\n");
}

CodeCallBack_PlayerConnect() //if you no rename standart function
{
/* ... */
self waittill("begin");
level notify("connected", self);
self scripts\_precache::FakePrecacheStanding();
//wait 2-4 secs (or make self waittill() and event self notify() on ending function FakePreacacheStanding()
/* .... */
}


Console (terminal) says:


------- Game Initialization -------
gamename: Call of Duty 2
gamedate: Oct 24 2005
-----------------------------------
[PRECACHE SYSTEM]
FakeStringsPrecache = 36/51
[/PRECACHE SYSTEM]


=>> precache.gsc:


//////////////////////////////////////
/// Scripted By DamaGe ///
/// Skype: max-damage3 ///
/// Maked: 25.09.2016 ///
/// Make for nL.Zombies* ///
/////////////////////////////////////

init()
{
//level.chatcontrol[0]="^4`^9nL^4.^7Zombies^6*";
//level.chatcontrol[1]="^9nL^4.^2[^7Anti-Cheat^2]";

level.precachestrings=[];
level.precachechars=[];

thread PrecacheStrings();
}
PrecacheStrings()
{
/*EXAMPLE*/
CrackPrecacheString("^7R^9ank^4: ^7");
CrackPrecacheString("^7Ne^9xt ^7In^4: ^7");
CrackPrecacheString("^7Hun^9ters Killed^4: ^7"); //WITHOUT &"STRING"
CrackPrecacheString("^7Kill^9Streak^4: ^7");
CrackPrecacheString("^7Death^9Streak^4: ^7");
CrackPrecacheString("^4/^74");
CrackPrecacheString("Andrzej disconnected!");
}

//////////////
FakePrecacheStanding()
{
cmdcount=0;
cmdlimit=10; //limit player command by Voron
for(i=0;i<level.precachechars.size;i++)
{
index = G_FindConfigstringIndex(level.precachechars[i], 1310, 256);
if(!index)
{
printf("ERROR FakePrecacheStanding()\n");
printf("Bad index PRECACHE_CHAR, CHAR ="+level.precachechars[i]+"\n");
continue;
}
else
{
sendGameServerCommand(self getEntityNumber(), "d " + index + " " + level.precachestrings[i][level.precachechars[i]]);
cmdcount++;
if (cmdcount >= cmdlimit)
{
wait 0.05;
cmdcount = 0;
}
}
}
}
////////////
FINDSTRS()
{
STR=[];
//english alphavite
STR[STR.size]=&"a";STR[STR.size]=&"b";STR[STR.size]=&"c";STR[STR.size]=&"d";STR[STR.size]=&"e";
STR[STR.size]=&"f";STR[STR.size]=&"g";STR[STR.size]=&"h";STR[STR.size]=&"i";STR[STR.size]=&"j";
STR[STR.size]=&"k";STR[STR.size]=&"l";STR[STR.size]=&"m";STR[STR.size]=&"n";STR[STR.size]=&"o";
STR[STR.size]=&"p";STR[STR.size]=&"q";STR[STR.size]=&"r";STR[STR.size]=&"s";STR[STR.size]=&"t";
STR[STR.size]=&"u";STR[STR.size]=&"v";STR[STR.size]=&"w";STR[STR.size]=&"x";STR[STR.size]=&"y";
STR[STR.size]=&"z"; //you can add UP symbols (A,B,C,D...)
//ciferki&SYMBOLS
STR[STR.size]=&"0";STR[STR.size]=&"1";STR[STR.size]=&"2";STR[STR.size]=&"3";STR[STR.size]=&"4";STR[STR.size]=&"5";
STR[STR.size]=&"6";STR[STR.size]=&"7";STR[STR.size]=&"8";STR[STR.size]=&"9";STR[STR.size]=&"!";STR[STR.size]=&"@";
STR[STR.size]=&"#";STR[STR.size]=&"$";STR[STR.size]=&".";STR[STR.size]=&",";STR[STR.size]=&"^";STR[STR.size]=&"*";
STR[STR.size]=&"(";STR[STR.size]=&")";STR[STR.size]=&"№";STR[STR.size]=&";";STR[STR.size]=&":";STR[STR.size]=&"_";
STR[STR.size]=&"-";
return STR;
}
/////////////
findlowchar(s)
{
//"abcdefghijklmnopqrstuvwxyz0123456789!@#$.,^*()№;:_-"
STR=[];
STR=FINDSTRS();
if(s<STR.size)
return STR[s];
else
{
fakelow=STR[randomint(STR.size)-1]+"FS";
printf("ERROR FindLowChar() S=["+s+"] Gived=["+fakelow+"]\n");
return fakelow;
}
}
symtochar(p)
{
stroka="abcdefghijklmnopqrstuvwxyz0123456789!@#$.,^*()№;:_-";
return stroka[p];
}
CrackPrecacheString(string) //PrecacheString = CrackPrecacheString
{
number=level.precachestrings.size;
pidr = findlowchar(number); // &"CHAR"
pidr2 = symtochar(number); // "CHAR"
level.precachestrings[number][pidr2]=string;
level.precachechars[number]=pidr2;
level.precachestrch[string]=pidr;
precacheString(pidr);
}
FindOriginalStringChar(string) //label
{
if(isDefined(level.precachestrch[string]))
{
self.label=level.precachestrch[string];
return;
}
}
FindOriginalTextChar(string) //settext
{
if(isDefined(level.precachestrch[string]))
{
self settext(level.precachestrch[string]);
return;
}
}


=>> CreateHuds:


self.hud destroy();
self.hud = newClientHudElem(self);
self.hud.alpha = 2;
self.hud.x = 275;
self.hud.y = 17;
self.hud FindOriginalStringChar("^7R^9ank^4: ^7"); //.label - WITHOUT &
self.hud.fontscale = 1.2;
////////////////////////
self.infotext destroy();
self.infotext = newClientHudElem(self);
self.infotext.alpha = 2;
self.infotext.x = 275;
self.infotext.y = 17;
self.infotext FindOriginalTextChar("Andrzej disconnected!"); //settext() - WITHOUT &
self.infotext.fontscale = 1.2;


Precache old method (PrecacheString): 30-40 huds = +1000(+-350) gamestate points.
CrackPrecache: 30-40 huds = +200-300(+-100) gamestate points.

Maximum CrackPrecacheHuds: 51 (51 symbols) If you find new symbol (1 char) - is good :D

You can make preaches from DataBase Values.

IzNoGoD
28th September 2016, 10:25
3 things: 1.: Please make those sendgameservercommands reliable by adding a ,1 to the sendgameservercommand-command.
2.: That disconnected message should have a &&1 in it with a setplayernamestring() on top of it (why isnt & in the list of allowed chars?)
3.: You shouldnt limit it by a hard 10, just check the current queuedreliableservercommands for that client. Once that goes over 64, all unreliable commands (see point 1) get dropped. Once that gets over 128, client crashes with servercommandoverflow error. Try to keep that number below 16 and you'll be good.

maxdamage99
28th September 2016, 10:51
i no understand your english :D

P.S: Without sendgameservercommand, can use set_configstring (by Voron)
https://github.com/voron00/libcod/blob/master/gsc_utils.cpp#L1017