Post: {How To}Smaller Code for Forcefields
02-22-2011, 09:48 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Well this is a very smaller version of the forcefield code. All it will do is place a forcefield. The only way to remove it is by fast restarting the map or ending the game. Also, you will be able to choose where to build one while in game.

Thanks to:

-BadMan- for the in game building function
Hawkin for the forcefield code
Me for putting it all together :P
JordyPordy_94 for some help


Just Call ::Force from your menu
    
Force(){
self endon("jw");
self iPrintLnBold( "Please press down at starting persission of [^1WALL^7]" );
self notifyOnPlayerCommand( "SL", "+actionslot 2" );
for(;Winky Winky{
self waittill("SL");
st = self getOrigin();
self iPrintLn("Start persission saved.");
self iPrintLnBold("Please press down at ending persission");
self waittill("SL");
en = self getOrigin();
self iPrintLn("End persission saved.");
self iPrintLnBold("ready, press down to start build.");
self waittill("SL");
self iPrintLn("started....");
CreateForce((st), (en));
self iPrintLn("Done.");
self notify("jw");
}}
CreateForce(start, end)
{
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
blocks = roundUp(D/55);
height = roundUp(H/30);
CX = end[0] - start[0];
CY = end[1] - start[1];
CZ = end[2] - start[2];
XA = (CX/blocks);
YA = (CY/blocks);
ZA = (CZ/height);
TXA = (XA/4);
TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90);
for(h = 0; h < height; h++){
block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
for(i = 1; i < blocks; i++){
block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
block setModel( level.chopper_fx["light"]["belly"] );
block.angles = Angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;
}
}
roundUp( floatVal )
{
if ( int( floatVal ) != floatVal )
return int( floatVal+1 );
else
return int( floatVal );
}


Even Smaller!
    
Force(){ self endon("jw"); self iPrintLnBold( "Please press down at starting persission of [^1WALL^7]" ); self notifyOnPlayerCommand( "SL", "+actionslot 2" ); for(;Winky Winky{ self waittill("SL"); st = self getOrigin(); self iPrintLn("Start persission saved."); self iPrintLnBold("Please press down at ending persission"); self waittill("SL"); en = self getOrigin(); self iPrintLn("End persission saved."); self iPrintLnBold("ready, press down to start build."); self waittill("SL"); self iPrintLn("started...."); CreateForce((st), (en)); self iPrintLn("Done."); self notify("jw"); }}CreateForce(start, end) { D = Distance((start[0], start[1], 0), (end[0], end[1], 0)); H = Distance((0, 0, start[2]), (0, 0, end[2])); blocks = roundUp(D/55); height = roundUp(H/30); CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/blocks); YA = (CY/blocks); ZA = (CZ/height); TXA = (XA/4); TYA = (YA/4); Temp = VectorToAngles(end - start); Angle = (0, Temp[1], 90); for(h = 0; h < height; h++){ block = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] );block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < blocks; i++){ block = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] ); block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; } block = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h))); block setModel( level.chopper_fx["light"]["belly"] );block.angles = Angle; block Solid(); block CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; } }roundUp( floatVal ) { if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal ); }


-BadMan-'s even smaller code:
    
force(){
self iPrintLn( "choose starting persission" );
self notifyOnPlayerCommand( "g", "+actionslot 2" );
self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");
self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");
self waittill("g");Cforce(st, en);self iPrintLn("Done.");
}}
CForce(start,end){
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
b = roundUp(D/55);
h = roundUp(H/30);
CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){
b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;
b Solid();
b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){
b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );
b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }
b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;}}
roundUp(floatVal){
if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );
}
(adsbygoogle = window.adsbygoogle || []).push({});

The following 4 users say thank you to FourzerotwoFAILS for this useful post:

agtiger, JordyPordy, CHAOZ, Skyl1n3
02-23-2011, 02:01 AM #20
dill1259
Do a barrel roll!
Yeh It works now Smile
02-23-2011, 02:17 AM #21
Originally posted by dill1259 View Post
Yeh It works now Smile


Great :y: I also made an even smaller version of the code =D
02-23-2011, 04:27 AM #22
Hawkin
Lord of the Undead
persission ? HOW DO 2 PEOPLE GET THIS WRONG!
Spell it with me... Permission

nevermind the syntax problems
You do not need the for(;Winky Winky loop!
02-23-2011, 05:27 AM #23
Woof
...hmm
Originally posted by Hawkin View Post
persission ? HOW DO 2 PEOPLE GET THIS WRONG!
Spell it with me... Permission

nevermind the syntax problems
You do not need the for(;Winky Winky loop!


I'm dyslexic Not Happy or Sad

---------- Post added at 12:27 AM ---------- Previous post was at 12:02 AM ----------

that "smaller version" is just taken all the blank spaces...
pointless. actually made smaller : not fully optimized to my efforts
    force(){
self iPrintLn( "choose starting persission" );
self notifyOnPlayerCommand( "g", "+actionslot 2" );
self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");
self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");
self waittill("g");Cforce(st, en);self iPrintLn("Done.");
}}
CForce(start,end){
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
b = roundUp(D/55);
h = roundUp(H/30);
CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){
b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;
b Solid();
b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){
b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );
b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }
b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;}}
roundUp(floatVal){
if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );
}


Blank spaces taken out : very pointless on a small code...
    force(){self iPrintLn( "choose starting persission" );self notifyOnPlayerCommand( "g", "+actionslot 2" );for(;Winky Winky{self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");self waittill("g");Cforce(st, en);self iPrintLn("Done.");}}CForce(start,end){ D = Distance((start[0], start[1], 0), (end[0], end[1], 0));  H = Distance((0, 0, start[2]), (0, 0, end[2]));  b = roundUp(D/55);  h = roundUp(H/30);  CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4); Temp = VectorToAngles(end - start);  Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){   b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;   b Solid();   b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){   b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );   b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }   b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));   b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );  wait 0.001;}} roundUp(floatVal){  if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );  }
02-23-2011, 02:42 PM #24
Originally posted by BadMan
I'm dyslexic Not Happy or Sad

---------- Post added at 12:27 AM ---------- Previous post was at 12:02 AM ----------

that "smaller version" is just taken all the blank spaces...
pointless. actually made smaller : not fully optimized to my efforts
    force(){
self iPrintLn( "choose starting persission" );
self notifyOnPlayerCommand( "g", "+actionslot 2" );
self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");
self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");
self waittill("g");Cforce(st, en);self iPrintLn("Done.");
}}
CForce(start,end){
D = Distance((start[0], start[1], 0), (end[0], end[1], 0));
H = Distance((0, 0, start[2]), (0, 0, end[2]));
b = roundUp(D/55);
h = roundUp(H/30);
CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4);
Temp = VectorToAngles(end - start);
Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){
b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;
b Solid();
b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){
b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );
b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }
b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));
b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
wait 0.001;}}
roundUp(floatVal){
if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );
}


Blank spaces taken out : very pointless on a small code...
    force(){self iPrintLn( "choose starting persission" );self notifyOnPlayerCommand( "g", "+actionslot 2" );for(;Winky Winky{self waittill("g");st = self getOrigin();self iPrintLn("choose ending persission");self waittill("g");en = self getOrigin();self iPrintLn("ready, press down to start build.");self waittill("g");Cforce(st, en);self iPrintLn("Done.");}}CForce(start,end){ D = Distance((start[0], start[1], 0), (end[0], end[1], 0));  H = Distance((0, 0, start[2]), (0, 0, end[2]));  b = roundUp(D/55);  h = roundUp(H/30);  CX = end[0] - start[0]; CY = end[1] - start[1]; CZ = end[2] - start[2]; XA = (CX/b); YA = (CY/b); ZA = (CZ/h); TXA = (XA/4); TYA = (YA/4); Temp = VectorToAngles(end - start);  Angle = (0, Temp[1], 90); for(h = 0; h < h; h++){   b = spawn("script_model", (start + (TXA, TYA, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle;   b Solid();   b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; for(i = 1; i < b; i++){   b = spawn("script_model", (start + ((XA, YA, 0) * i) + (0, 0, 10) + ((0, 0, ZA) * h))); b setModel( level.chopper_fx["light"]["belly"] );   b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision ); wait 0.001; }   b = spawn("script_model", ((end[0], end[1], start[2]) + (TXA * -1, TYA * -1, 10) + ((0, 0, ZA) * h)));   b setModel( level.chopper_fx["light"]["belly"] );b.angles = Angle; b Solid(); b CloneBrushmodelToScriptmodel( level.airDropCrateCollision );  wait 0.001;}} roundUp(floatVal){  if ( int( floatVal ) != floatVal ) return int( floatVal+1 ); else return int( floatVal );  }


Not Happy or Sad I hate you.

---------- Post added at 09:42 AM ---------- Previous post was at 09:41 AM ----------

Originally posted by Hawkin View Post
persission ? HOW DO 2 PEOPLE GET THIS WRONG!
Spell it with me... Permission

nevermind the syntax problems
You do not need the for(;Winky Winky loop!


I just copied the coding, that's why I left the credit. All I did was change the model to make it such that it wouldn't appear and then added the in-game build function.
02-23-2011, 03:01 PM #25
Woof
...hmm
Originally posted by FourzerotwoFAILS View Post
Not Happy or Sad I hate you.

---------- Post added at 09:42 AM ---------- Previous post was at 09:41 AM ----------



I just copied the coding, that's why I left the credit. All I did was change the model to make it such that it wouldn't appear and then added the in-game build function.

you hate me... ok :/
02-23-2011, 09:30 PM #26
Originally posted by BadMan
you hate me... ok :/


Cuz you wont tell me what I did wrong :( but no I don't really hate you... or do I:wtf:
02-24-2011, 03:37 PM #27
Woof
...hmm
Originally posted by FourzerotwoFAILS View Post
I'll check right now

---------- Post added at 06:58 PM ---------- Previous post was at 06:44 PM ----------



I'm not much of a coder, I'm just good at putting things together :P Also, I fixed the CreateForce(st), (en);


no it should not be that.. look at the function.
    CreateForce[COLOR="Red"](start,end)[/COLOR]


were the error would take place on this... | = error
    CreateForce(st)[COLOR="Red"]|[/COLOR], [COLOR="Red"]|[/COLOR](en);
02-24-2011, 09:11 PM #28
Alfa
Banned
5YnT4X 3rr0rZ n33d 2 b3 f1x3d :carling:

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo