Post: GSC Tutorial: Tutorial 1: Variables And The Basics
04-24-2011, 07:49 AM #1
pcfreak30
>> PCFreak30.com Happy<<
(adsbygoogle = window.adsbygoogle || []).push({}); Ok everyone. For now this is the only tut in this hopeful series I will share with NGU.

If you want anymore, give feedback here or on my blog.

Enjoy.

Originally posted by another user
Ok, so I originally WAS going to do this as a video series, but then I thought about it, and decided on a blog-based series.

If I get enough feedback, I will continue . Lets begin..



Background Information:

I have beeen recently corrected in the fact that mostly ALL COD games use the QUAKE game engine.

In a game there are 2 parts. The content and the engine. The engine can be thought up as the frame of a car. It the foundation and it is what makes it “work”. The content are the seats and internals. They are what you can interact and have fun with.

You can have just the engine, and no content to play, or have the content but nothing to run it. In call of duty, the content files are in a format called FastFiles, or ff files (file extension). They are compressed with zlib compression. They hold game models, audio, game settings, video, challenges and stuff, and picture/textures.

The game developers update the game by providing a patch_mp.ff file. Since this fastfile is on HDD and not disk, we can modify it and create “mods”. The game also has a order in how it searches for content. If it is in the patch, it takes priority over that file to the one(s) on disc. You can rename the files to something else and it will do the same.

COD is also know for horrible debugging. It gives almost no information to a scripting error..



The Basics:

Thing back to algebra, were you solved for X. Now put those teachings to this as it is similar.

A variable contains a value, its that simple. Noe for the more complex thing is what type of value?

The following are data types, also know as value types:

Integer which is a number
String which is text
Boolean with is simply true or false
Float which is a decimal like .12345
An array, which is a slightly harder thing to explain and we will soon cover it.


test = 2;



That sets a integer value of 2 to the variable “test”. The semi-colon means the end of a line.



test = “hello”;



This sets “test” to the string (text) “hello”.



test = true;



This sets “test” to the boolean value of true.



test = false;



This sets “test” to the boolean value of false.



Now about arrays. Arrays are a set of data. They are like a group of variables in a way.

Arrays use what are called “keys” and “values”. You use a key to access a value. Arrays are also like matrices. Array keys can be strings or integers.



arraya = [];

Sets the variable “arraya” to an array.



arraya["key1"] = “hello”;



That creates an array element with a key of “key1″ and a value of “hello”.



arraya[0] = “hello”;

That creates an array element with a key of 0 and a value of “hello”.



In arrays, when looping or iterating though them, the key always starts at 0. Now I know you thinking, “wait! hold up, I what about array keys being strings?”. Well that IS true, but you can also access using a integer key based on the position of the array element in the group, as well as the key you used yourself. This will be mostly used in for loops and getting the size of an array (how many elements it has)..



Here is a example array set:

b= [];

b["a"] = 1;

b[2] = true;

b["pcfreak"] = “is cool”;



This can be shown in a diagram view:



b

“a” = 1


2 = true


“pcfreak” = “is cool”




You can do multi-dimensional arrays to. Thats simple nesting arrays, or one array inside another.



a= [];

a[0] = [];

a["hi"] = “test”;



To access the value test, you would do=



varc =a[0]["hi"];

That returns the element with the key of “hi” which is under the key of 0 as well to the variable “varc”. The key of 0 also has a value of an array..



A diagram could be shown as:



a

0


“hi” = “test”




Well that about covers this tutorial. If you liked. it, please comment. If I get enough feedback I shall continue. If you have any questions about this tutorial, do ask away.



Have fun coding ..


Source: You must login or register to view this content.

See Ya..
(adsbygoogle = window.adsbygoogle || []).push({});

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

.Pluto, add_me, Amazingpwner, Casper_HD, echo_destroyer, KeithH4666
04-24-2011, 06:43 PM #11
Originally posted by pcfreak30 View Post
What would be the fun in that. I don't like limiting myself..


I don't know why but this was always my favourite example of arrays from MW2. Very simple but very clever. I think it was all the brackets at the end Winky Winky

    ChangeAppearance(Type,MyTeam)
{
ModelType=[];
ModelType[0]="GHILLIE";
ModelType[1]="SNIPER";
ModelType[2]="LMG";
ModelType[3]="ASSAULT";
ModelType[4]="SHOTGUN";
ModelType[5]="SMG";
ModelType[6]="RIOT";
if(Type==7)
{
MyTeam=randomint(2);
Type=randomint(7);
}
team=get_enemy_team(self.team);
if(MyTeam)team=self.team;
self detachAll();
[[game[team+"_model"][ModelType[Type]]]]();
}
04-24-2011, 07:20 PM #12
Blackstorm
Veni. Vidi. Vici.
Keep up with these, it's good for teh noobs. Smile
04-24-2011, 08:08 PM #13
.Kane.
Banned
Originally posted by I
It helps to know how to code GSC for future purposes and maybe you can impress a girl with it?
Like
if (girl == "Insert Name" && Hotness == 100/100)
Self.isHot();
else
Envy'sHer();

Say that and she will be all over you.


its actually C++/python not gsc.
04-24-2011, 08:10 PM #14
Merkii
Former Staff
Originally posted by Kane212
its actually C++/python not gsc.


:shh: Jew mean my code above?
04-24-2011, 08:22 PM #15
seb5594
Proud Former Admin
why you post it too late?
can you do gsc on 1.12? Awesome face
04-25-2011, 01:45 AM #16
anddrew
League Champion
Originally posted by I
It helps to know how to code GSC for future purposes and maybe you can impress a girl with it?
Like
if (girl == "Insert Name" && Hotness == 100/100)
Self.isHot();
else
Envy'sHer();

Say that and she will be all over you.


strangly enough, I doubt that.
04-25-2011, 08:28 AM #17
Merkii
Former Staff
Originally posted by anddrew View Post
strangly enough, I doubt that.


Why she will have a nerdgasm and when she does hand her the controller and make sure vibrator mode is ON!
04-25-2011, 08:34 AM #18
pcfreak30
>> PCFreak30.com Happy<<
Originally posted by I
Why she will have a nerdgasm and when she does hand her the controller and make sure vibrator mode is ON!


Stay on topic.

Thanks..
04-27-2011, 07:39 PM #19
GangstaCupcake1
HELLO FRIEND Happy
Very nice tutorial man. You're doing very good to help out the community

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo