cheatcodes

Started by habi, Apr 13, 2020, 11:05 AM

Previous topic - Next topic

habi

CHEATCODES
hey guys, you might not like this but any way. here is a snippet for using cheatcodes in game.

below is script for client and server
[spoiler]Clientside
1. cheat_keybinds.nut
[noae]Console.Print("Key bindings starting...");
A<-KeyBind(0x41);
B<-KeyBind(0x42);
C<-KeyBind(0x43);
D<-KeyBind(0x44);
E<-KeyBind(0x45);
F<-KeyBind(0x46);
G<-KeyBind(0x47);
H<-KeyBind(0x48);
I<-KeyBind(0x49);
J<-KeyBind(0x4A);
K<-KeyBind(0x4B);
L<-KeyBind(0x4C);
M<-KeyBind(0x4D);
N<-KeyBind(0x4E);
O<-KeyBind(0x4F);
P<-KeyBind(0x50);
Q<-KeyBind(0x51);
R<-KeyBind(0x52);
S<-KeyBind(0x53);
T<-KeyBind(0x54);
U<-KeyBind(0x55);
V<-KeyBind(0x56);
W<-KeyBind(0x57);
X<-KeyBind(0x58);
Y<-KeyBind(0x59);
Z<-KeyBind(0x5A);
Console.Print("Key bindings done");
Console.Print("Now hooking function");
function GetLetter( key )
{
switch( key )
{
case A : return "A" ;
case B : return "B" ;
case C : return "C" ;
case D : return "D" ;
case E : return "E" ;
case F : return "F" ;
case G : return "G" ;
case H : return "H" ;
case I : return "I" ;
case J : return "J" ;
case K : return "K" ;
case L : return "L" ;
case M : return "M" ;
case N : return "N" ;
case O : return "O" ;
case P : return "P" ;
case Q : return "Q" ;
case R : return "R" ;
case S : return "S" ;
case T : return "T" ;
case U : return "U" ;
case V : return "V" ;
case W : return "W" ;
case X : return "X" ;
case Y : return "Y" ;
case Z : return "Z" ;
default: return null;
}
}
Console.Print("done.");
[/noae]
2. cheat.nut
[noae]dofile("cheat_keybinds.nut");
cheats<-{
codes=["ASPIRINE","PANZER","PRECIOUSPROTECTION","NUTTERTOOLS","PROFESSIONALTOOLS",
"THUGSTOOLS","LEAVEMEALONE","TRAVELINSTYLE","GETTHEREQUICKLY","ALOVELYDAY",
"CATSANDDOGS","APLEASANTDAY","SEAWAYS","COMEFLYWITHME","ICANTTAKEITANYMORE",
"THELASTRIDE","ROCKANDROLLCAR","BETTERTHANWALKING","GETTHEREFAST","RUBBISHCAR",
"GRIPISEVERYTHING","LOOKLIKELANCE","MYSONISALAWYER","LOOKLIKEHILARY",
"ROCKANDROLLMAN","WELOVEOURDICK","ONEARMEDBANDIT","IDONTHAVETHEMONEYSONNY","FOXYLITTLETHING",
"CANTSEEATHING","ABITDRIEG","LIFEISPASSINGMEBY","BOOOOOORING","LEAVEMEALONE",
"YOUWONTTAKEMEALIVE","CHEATSHAVEBEENCRACKED","GETTHEREVERYFASTINDEED","GETTHEREAMAZINGLYFAST",
"AHAIRDRESSERSCAR","BIGBANG"],
clear=function(){this.content=""},
get=function(){
foreach( cheat in this.codes )
{
if( this.content.find( cheat ) != null )
{
return cheat;
}
}
},
getindex=function( cheat ){
return this.codes.find( cheat );
},
lastcall=Script.GetTicks(),content=""
};


function onTyped( key )
{
local currentCall=Script.GetTicks();
if( currentCall - ::cheats.lastcall > 3000 )
{
::cheats.clear();
}

local letter = GetLetter( key );
if( letter )
{
::cheats.content+=letter;
local cheat_code = cheats.get();
if( cheat_code )
{
SendDataToServer( StreamType.CHEATCODE, cheats.getindex(cheat_code) );
::cheats.clear();
}
}

::cheats.lastcall=currentCall;
}
[/noae]
3. main.nut
[noae]enum StreamType
{ CHEATCODE=0x18
}
dofile("cheat.nut");
function KeyBind::OnDown( key )
{
onTyped( key );
}
[/noae]
Server side
1.cheatcode.nut
[noae]cheat_vehicles<-[];cheat_activated<-false;
codes<-["ASPIRINE","PANZER","PRECIOUSPROTECTION","NUTTERTOOLS","PROFESSIONALTOOLS",
"THUGSTOOLS","LEAVEMEALONE","TRAVELINSTYLE","GETTHEREQUICKLY","ALOVELYDAY",
"CATSANDDOGS","APLEASANTDAY","SEAWAYS","COMEFLYWITHME","ICANTTAKEITANYMORE",
"THELASTRIDE","ROCKANDROLLCAR","BETTERTHANWALKING","GETTHEREFAST","RUBBISHCAR",
"GRIPISEVERYTHING","LOOKLIKELANCE","MYSONISALAWYER","LOOKLIKEHILARY",
"ROCKANDROLLMAN","WELOVEOURDICK","ONEARMEDBANDIT","IDONTHAVETHEMONEYSONNY","FOXYLITTLETHING",
"CANTSEEATHING","ABITDRIEG","LIFEISPASSINGMEBY","BOOOOOORING","LEAVEMEALONE",
"YOUWONTTAKEMEALIVE","CHEATSHAVEBEENCRACKED","GETTHEREVERYFASTINDEED","GETTHEREAMAZINGLYFAST",
"AHAIRDRESSERSCAR","BIGBANG"];
function onCheatCode( player, cheat_code_index )
{
local cheat_code = codes[cheat_code_index];
switch( cheat_code )
{
case "PANZER":
{
local panzer = CreateVehicle( 162 ,player.Pos+Vector(5,5,7 ),player.Angle,46,2);
cheat_vehicles.push( panzer.ID );
panzer.Immunity=127;cheat_activated=true;
}
break;
case "NUTTERTOOLS":
{
player.SetWeapon( 29, 21 );
player.SetWeapon( 29, 21 );
player.SetWeapon( 33, 500 );
player.SetWeapon( 26, 150 );
player.SetWeapon( 25, 100 );
player.SetWeapon( 20, 30 );
player.SetWeapon( 18, 40 );
player.SetWeapon( 12, 10 );
player.SetWeapon( 11, 1 );
Announce("Weapon cheat",player,0);
}
break;
case "PROFESSIONALTOOLS":
{

player.SetWeapon( 29, 21 );
player.SetWeapon( 30, 5 );
player.SetWeapon( 26, 150 );
player.SetWeapon( 24, 100 );
player.SetWeapon( 21, 25 );
player.SetWeapon( 18, 40 );
player.SetWeapon( 13, 10 );
player.SetWeapon( 10, 1 );
Announce("Weapon cheat",player,0);
}
break;
case "THUGSTOOLS":
{
player.SetWeapon( 28, 25 );
player.SetWeapon( 31, 20 );
player.SetWeapon( 27, 240 );
player.SetWeapon( 22, 300 );
player.SetWeapon( 19, 75 );
player.SetWeapon( 17, 100 );
player.SetWeapon( 15, 10 );
player.SetWeapon( 6, 1 );
player.SetWeapon( 1, 1 );
Announce("Weapon cheat",player,0);
}
break;
case "ASPIRINE":
{
player.Health = 100;
Announce("Health cheat",player,0);
}break;
case "PRECIOUSPROTECTION":
{
player.Armour = 100;
Announce("Armor cheat",player,0);
}
break;
case "TRAVELINSTYLE":
{
local vehicle = CreateVehicle( 234 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}
break;
case "GETTHEREQUICKLY":
{
local vehicle = CreateVehicle( 235 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}
break;
case "THELASTRIDE":
{
local vehicle = CreateVehicle( 172 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "ROCKANDROLLCAR":
{
local vehicle = CreateVehicle( 201 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "BETTERTHANWALKING":
{
local vehicle = CreateVehicle( 187 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "GETTHEREFAST":
{
local vehicle = CreateVehicle( 206 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "GETTHEREVERYFASTINDEED":
{
local vehicle = CreateVehicle( 232 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "GETTHEREAMAZINGLYFAST":
{
local vehicle = CreateVehicle( 233,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "RUBBISHCAR":
{
local vehicle = CreateVehicle( 138 ,player.Pos+Vector(5,5,7 ),player.Angle,rand()%94,rand()%94);
cheat_vehicles.push( vehicle.ID );cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "GRIPISEVERYTHING":
{
SetPerfectHandling( true ); cheat_activated=true;
Announce("Cheat activated",player,0);
}break;
case "CATSANDDOGS":
{
SetWeather(2);cheat_activated=true;
AnnounceAll("Weather cheat",0);
}
break;
case "APLEASANTDAY":
{
SetWeather(0);
AnnounceAll("Weather cheat",0);
}
break;
case "ALOVELYDAY":
{
SetWeather(4);
AnnounceAll("Weather cheat",0);
}
break;
case "CANTSEEATHING":
{
SetWeather(3);
AnnounceAll("Weather cheat",0);
}
break;
case "ABITDRIEG":
{
SetWeather(1);
AnnounceAll("Weather cheat",0);
}
break;
case "LIFEISPASSINGMEBY":
{
SetTimeRate(80);cheat_activated=true;
AnnounceAll("Weather cheat",0);
}
break;
case "SEAWAYS":
{
SetDriveOnWater( true );cheat_activated=true;
Announce("Cheat activated",player,0);
}
break;
case "COMEFLYWITHME":
{
SetFlyingCars( true );cheat_activated=true;
Announce("Cheat activated",player,0);
}
break;
case "BOOOOOORING":
{
SetGamespeed( 0.32 );cheat_activated=true;
Announce("Cheat activated",player,0);
}
break;
case "ICANTTAKEITANYMORE":
{
player.Health = 0;
Announce("Cheat activated",player,0);
}
break;
case "LEAVEMEALONE":
{
player.SetWantedLevel( 0 );
Announce("Wanted level cheat",player,0);
}
break;
case "YOUWONTTAKEMEALIVE":
{
local s = player.WantedLevel;
local w= (s==6||s==5)?6:s<5 && s>=0?s+2:2;
player.SetWantedLevel( w );
Announce("Wanted level cheat",player,0);
}
break;
case "LOOKLIKELANCE":player.Skin=116; break;
case "MYSONISALAWYER":player.Skin=109; break;
case "LOOKLIKEHILARY":player.Skin=111; break;
case "ROCKANDROLLMAN":player.Skin=108; break;
case "WELOVEOURDICK":player.Skin=118; break;
case "ONEARMEDBANDIT":player.Skin=113; break;
case "IDONTHAVETHEMONEYSONNY":player.Skin=115; break;
case "FOXYLITTLETHING":player.Skin=117; break;
case "CHEATSHAVEBEENCRACKED":player.Skin=107;break;
case "AHAIRDRESSERSCAR":Pink(); AnnounceAll("Cheat activated",0);break;
case "BIGBANG":bigbang(); AnnounceAll("Cheat activated",0);break;
default:
break;
}
}


function cheatReset()
{
if( cheat_activated == false ) return;
SetDriveOnWater( false );
SetFlyingCars( false );
SetWeather(0);
SetPerfectHandling( false );
SetTimeRate( 1000 );
SetGamespeed(1);
local veh
foreach( id in cheat_vehicles )
{
veh = FindVehicle( id );
if( veh )veh.Delete();
cheat_vehicles.remove( id );
}
}
function bigbang()
{
local i,veh,model;
for( i = 1; i <= GetVehicleCount(); i++ )
{
veh = FindVehicle( i );
if( veh )
{
veh.Kill();
}
}
}
function Pink()
{
local i,veh,model;
for( i = 1; i <= GetVehicleCount(); i++ )
{
veh = FindVehicle( i );
if( veh )
{
model = veh.Model;
if( !O(model,146,137,150,156,157,158,163,168,178,188,200,216) )
{
veh.Colour1=5;
veh.Colour2=0;
}
}
}
}
function O(t,...)
{
foreach(val in vargv)
{
if(t==val)return 1;
}
return 0;
}
[/noae]
2. main.nut
[noae]enum StreamType
{
CHEATCODE=0x18
}
function onScriptLoad()
{
    dofile("scripts/cheatcode.nut");
}
function onClientScriptData( player )
{
    // receiving client data
    local stream = Stream.ReadByte();
    switch ( stream )
    {
case StreamType.CHEATCODE:
{
onCheatCode( player, Stream.ReadInt());
}
break;
default:
break;

    }
}
[/noae]
[/spoiler]

A screenshot
[spoiler][/spoiler]

You just need to type the cheat codes. ASPIRINE, PRECIOUSPROTECTION, *adding bigbang* and that is all.
you can type the codes even in the 'menu' ( esc key )
Good luck!