Post: Good Mod Utility Functions & Cryptography
07-23-2012, 12:34 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); I made these in about 30 minutes. Now they probably arn't useful to noobs of scripting, but to really advanced people I think they will do a great help in creating more advanced mods. First will be the source, and the second will be syntax's on how to use them. They're functions I made from scratch (except the getName thanks to kbrizzle) so I hope you use them to your advantage. Happy

My Utilities

    
#include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;

strReplace(string, char, val)
{
array = strTok(string, char);
stringBuilder = "";
if(array.size >= 1)
{
for(i=0;i<array.size;i++)
{
if(i<(array.size - 1))
stringBuilder += (array[i] + val);
else
stringBuilder += array[i];
}
return stringBuilder;
}
return string;
}

strToArray(string)
{
array = [];
for(i=0;i<string.size;i++)
array[i] = GetSubStr( string, i, (i+1) );
return array;
}

arrayToStr(buffer)
{
string = "";
for(i=0;i<buffer.size;i++)
string += buffer[i];
return string;
}

arrayReverse(buffer)
{
array = [];
for(i=0;i<buffer.size;i++)
array[buffer.size - 1 - i] = buffer[i];
return array;
}

strReverse(string)
{
buffer = strToArray(string);
buffer = arrayReverse(buffer);
output = "";
for(i=0;i<buffer.size;i++)
output += buffer[i];
return output;
}

//thanks to kbrizzle for this one
getRealName(){nT=getSubStr(self.name,0,self.name.size);for (i=0;i<nT.size;i++) { if (nT[i]=="]") break; }if (nT.size!=i) nT=getSubStr(nT,i+1,nT.size);return nT;}
//thanks to kbrizzle for this one

isInt(var){x = Int( var ); if(var == "0" && x == 0) return true; else if(x > 0) return true;else return false;}

roundFloat(float)
{
number = strTok(float, ".");
if(number.size > 1)
{
real = Int(number[0]);
deci = number[1];
buildDec = strToArray(deci);
if(Int(buildDec[0]) >= 5)
return (Int(real + 1));
else
return (Int(real));
}
return float;
}

getPower(x, num)
{
y = x;
for(i=0;i<(num-1);i++)
{
y = x * y;
}
return y;
}

getRoot(x, power)
{
numberOfCycles = 99; //higher for better accuraccy but pretty slow aswell.
y = numberOfCycles * (getPower(10,power));
for (i = 0; i < numberOfCycles; i++)
{
y = (1/power) * (((power - 1) * y) + (x / getPower(y, (power - 1))));
}
return y;
}

//#REGION CRYPTOGRAPHY

crypt(string, type)
{
output = "";
switch(type)
{
case "e":
charList = strToArray(string);
for(i=0;i<charList.size;i++)
{
for(j=0;j<level.charList.size;j++)
{
if(charList[i] == level.charList[j])
output += ((j+1) * 2);
}
if(i < (charList.size - 1) )
output += ":";
}
break;

case "d":
blocks = strTok(string, ":");
for(i=0;i<blocks.size;i++)
output += level.charList[Int((Int(blocks[i])/2) - 1)];
break;

default: break;
}
return output;
}

enumerateCharacters()
{
level.charList = strToArray("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789!@#$%^&*()_+-=/\? [{}]<>,.|~`");
}

//#END REGION




strReplace:
    
text = strReplace( <string>, <chars to replace>, <new chars> );


strToArray:
    
array = [];
array = strToArray("test array");


arrayToStr:
    
list[0] = "l";
list[1] = "o";
list[2] = "l";
string = arrayToStr(list);


arrayReverse:
    
list[0] = 1;
list[1] = 2;
list[2] = 3;
array = arrayReverse(list);
array[0] = 3;
array[1] = 2;
array[2] = 1;


strReverse:
    
string = "hi";
string = strReverse(string);
// "ih"


isInt:
    
if(!isInt("hi"))
self iPrintlnBold("hi isn't an int");
if(isInt(5))
//do shit


roundFloat:
    
roundFloat(3.2); //output = 3
roundFloat(3.Cool Man (aka Tustin); //output = 4


getPower:
    
getSquare( <number>, <power> );


getRoot:
    
getSquareRoot( <number>, <nth root> );

//this is one I made my self, and the "nth" part was hard to interpret into code :p


crypt:
    
crypt( <string>, <type> );

//if type = "e" it will encrypt the string
//if type = "d" it will decrypt the string
(adsbygoogle = window.adsbygoogle || []).push({});

The following 6 users say thank you to Jakes625 for this useful post:

Choco, forflah123, Fox243, Harry, Taylor, Vanz
07-23-2012, 02:26 AM #2
Harry
Former Staff
Originally posted by GAMER View Post
I made these in about 30 minutes. Now they probably arn't useful to noobs of scripting, but to really advanced people I think they will do a great help in creating more advanced mods. First will be the source, and the second will be syntax's on how to use them. They're functions I made from scratch (except the getName thanks to kbrizzle) so I hope you use them to your advantage. Happy

My Utilities

    
#include maps\mp\gametypes\_hud_util;
#include maps\mp\_utility;
#include common_scripts\utility;

strReplace(string, char, val)
{
array = strTok(string, char);
stringBuilder = "";
if(array.size >= 1)
{
for(i=0;i<array.size;i++)
{
if(i<(array.size - 1))
stringBuilder += (array[i] + val);
else
stringBuilder += array[i];
}
return stringBuilder;
}
return string;
}

strToArray(string)
{
array = [];
for(i=0;i<string.size;i++)
array[i] = GetSubStr( string, i, (i+1) );
return array;
}

arrayToStr(buffer)
{
string = "";
for(i=0;i<buffer.size;i++)
string += buffer[i];
return string;
}

arrayReverse(buffer)
{
array = [];
for(i=0;i<buffer.size;i++)
array[buffer.size - 1 - i] = buffer[i];
return array;
}

strReverse(string)
{
buffer = strToArray(string);
buffer = arrayReverse(buffer);
output = "";
for(i=0;i<buffer.size;i++)
output += buffer[i];
return output;
}

//thanks to kbrizzle for this one
getRealName(){nT=getSubStr(self.name,0,self.name.size);for (i=0;i<nT.size;i++) { if (nT[i]=="]") break; }if (nT.size!=i) nT=getSubStr(nT,i+1,nT.size);return nT;}
//thanks to kbrizzle for this one

isInt(var){x = Int( var ); if(var == "0" && x == 0) return true; else if(x > 0) return true;else return false;}

getSquare(x)
{
return (x * x);
}

getSquareRoot(x, numberOfCycles)
{
y = numberOfCycles * 100;
for (i = 0; i < numberOfCycles; i++)
{
y = .5 * (y + (x / y));
}
return y;
}

//#REGION CRYPTOGRAPHY

crypt(string, type)
{
output = "";
switch(type)
{
case "e":
charList = strToArray(string);
for(i=0;i<charList.size;i++)
{
for(j=0;j<level.charList.size;j++)
{
if(charList[i] == level.charList[j])
output += ((j+1) * 2);
}
if(i < (charList.size - 1) )
output += ":";
}
break;

case "d":
blocks = strTok(string, ":");
for(i=0;i<blocks.size;i++)
output += level.charList[Int((Int(blocks[i])/2) - 1)];
break;

default: break;
}
return output;
}

enumerateCharacters()
{
level.charList = strToArray("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789!@#$%^&*()_+-=/\? [{}]<>,.|~`");
}

//#END REGION




strReplace:
    
text = strReplace( <string>, <chars to replace>, <new chars> );


strToArray:
    
array = [];
array = strToArray("test array");


arrayToStr:
    
list[0] = "l";
list[1] = "o";
list[2] = "l";
string = arrayToStr(list);


arrayReverse:
    
list[0] = 1;
list[1] = 2;
list[2] = 3;
array = arrayReverse(list);
array[0] = 3;
array[1] = 2;
array[2] = 1;


strReverse:
    
string = "hi";
string = strReverse(string);
// "ih"


isInt:
    
if(!isInt("hi"))
self iPrintlnBold("hi isn't an int");
if(isInt(5))
//do shit


getSquare:
    
getSquare( <number to square> );


getSquareRoot:
    
getSquareRoot( <number to sqrRoot>, <number of cycles> );

//this is one I made my self and based off of a cycle method the more cycles the more accurate.


crypt:
    
crypt( <string>, <type> );

//if type = "e" it will encrypt the string
//if type = "d" it will decrypt the string


Well i can honestly say i don't understand this fully, but i learnt a couple things. Thank you :love:
07-23-2012, 03:00 AM #3
Originally posted by Hxrry View Post
Well i can honestly say i don't understand this fully, but i learnt a couple things. Thank you :love:


no problem man, if you need help with any of the functions let me know.

The following user thanked Jakes625 for this useful post:

Harry
07-23-2012, 01:45 PM #4
Originally posted by GAMER View Post
I think they will do a great help in creating more advanced mods.


I look forward to your next patch release "COD4: The Math Patch" :cry:

And the //#REGION CRYPTOGRAPHY one has been posted before ( by Blackstorm? ) , or something very similar. It's pointless as it can be broken by all but the stupidest of noobs :P

The following user thanked x_DaftVader_x for this useful post:

aerosoul94
07-23-2012, 05:25 PM #5
Originally posted by x. View Post
I look forward to your next patch release "COD4: The Math Patch" :cry:

And the //#REGION CRYPTOGRAPHY one has been posted before ( by Blackstorm? ) , or something very similar. It's pointless as it can be broken by all but the stupidest of noobs :P


lol.

no the math and other functions are more for physics. We have yet to master physics in the quake 3 engine so this might help. Like all the shit novemberdoddy made. He's a fucking genius :p

and the cryptography part was just something I made in like 10 minutes to see if I could it.
I am using it in my zombie patch I made for a very funny reason. Lets just say... the leachers will get made fun of if they change my name :carling:

The following user thanked Jakes625 for this useful post:

x_DaftVader_x
07-23-2012, 06:49 PM #6
Originally posted by GAMER View Post
Like all the shit novemberdoddy made. He's a fucking genius


I'm with you on that one :y:
07-23-2012, 06:54 PM #7
Originally posted by x. View Post
I'm with you on that one :y:


now I'm not saying your bad by this, but all the amazing people really went unnoticed...

craigschrist8239, NTAuthority, Swifteh, NovemberDoddy.

as far as gsc goes... as I know NTA, Craig, and Aero have really helped out with the ff itself :p
07-23-2012, 07:10 PM #8
Originally posted by GAMER View Post
now I'm not saying your bad by this, but all the amazing people really went unnoticed...

craigschrist8239, NTAuthority, Swifteh, NovemberDoddy.



lol, none of us on here deserve any recognition for what we do in comparison with the PC modders.

There are plenty of others, Tally, Demonseed, Brax, Sledgehammer, MetPl, the list goes on.

They just aren't known on here but what they did was absolutely amazing.

I mean, remember this, it took TWO YEARS to finish.. unbelievable... And look at the top comment, it says it all really..

07-23-2012, 07:46 PM #9
Originally posted by x. View Post
lol, none of us on here deserve any recognition for what we do in comparison with the PC modders.

There are plenty of others, Tally, Demonseed, Brax, Sledgehammer, MetPl, the list goes on.

They just aren't known on here but what they did was absolutely amazing.

I mean, remember this, it took TWO YEARS to finish.. unbelievable... And look at the top comment, it says it all really..



I just gave a few, but definately legends in my book. and that mod was amazing. I played it on a server once :p

but the only reason that was possible was because the company's allowed mods. After MW2 they took the "open source" off of their mods leaving to people having to find it out. Companies are greedy and even took modders ideas... when MW3 came out and I saw pet pavelow, strafe run I was just disgusted. The real genius's will never be known :fa:

edit: what about killingdyl D=

The following user thanked Jakes625 for this useful post:

forflah123
07-23-2012, 08:06 PM #10
Originally posted by GAMER View Post
when MW3 came out and I saw pet pavelow, strafe run I was just disgusted.


MW3 is a disgrace, it was just a cheap cash in that was knocked together in 10 months as a spoiler to BF3 ( or thats what I read anyway). They basically killed Call of Duty with that game, which is why I don't understand this sites insistance on copying it with the Elite thing..


Originally posted by GAMER View Post
killingdyl


Yep, another Genius, and there's AgentGod who made the MW2 ModLoader and I have a patch somewhere by a Spanish modder that is pretty awesome but I don't remember his name...

And don't forget Zeroy, that guy's a fucking machine !

Edit: Just remembered PezzaLucifer and his PezBots !

The following user thanked x_DaftVader_x for this useful post:

forflah123

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo