Post: Tutorial #1: Making Your First Code
08-05-2012, 08:58 PM #1
KingcreekS
NOTHING IS IMPOSSIBL
(adsbygoogle = window.adsbygoogle || []).push({});
It is a tutorial for people that want to get into coding community , so i hope you enjoy , peace!

Now, its time to create our _tutorial file. Save your edited _load.gsc and click on "New" in your notepad, add this on the blank file:

    
init()
{
level thread onPlayerConnect();
}

onPlayerConnect()
{
for( ; ; )
{
level waittill( "connected", player );
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon( "disconnect" );
for( ; ; )
{
self waittill( "spawned_player" );
}
}



The previous code is a simple and good way to start building your mod. Click on "save as" and save it on your mods mp folder as _tutorial.gsc, after doing that there will be 2 files on your mp folder: _load and _tutorial. Now lets make our first code: something that removes all player weapons and perks on spawn, inform your teammates that you have spawned and give a bag.

In _tutorial.gsc file there is a thread called onPlayerSpawned(), inside it there is a self waittill( "spawned_player");, after it we´ll add codes that will play after we have spawned. So lets add the commands that remove our perks and weapons:

    
onPlayerSpawned()
{
self endon( "disconnect" );
for( ; ; )
{
self waittill( "spawned_player" );
self takeAllWeapons(); //takes all your weapons
self clearPerks(); //removes all your perks
}
}



Now, lets add the rest of the code in an own created function, named TutorialThread() for example and place inside the command that will inform our teammates that we have spawned, the full file would look like this:

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

init()
{
level thread onPlayerConnect();
}

onPlayerConnect()
{
for( ; ; )
{
level waittill( "connected", player );
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon( "disconnect" );
for( ; ; )
{
self waittill( "spawned_player" );
self takeAllWeapons(); //takes all your weapons
self clearPerks(); //removes all your perks
self thread TutorialThread(); //execute the thread we wanted to make
}
}

TutorialThread()
{
self PingPlayer(); // Red ! on radar for your teammates, the effect finishes after a few seconds
}


After this, we´ll give the and switch to it.

    
TutorialThread()
{
self PingPlayer(); //red ! on radar for your teammates, the effect finishes after a few seconds
wait ( 0.05 ); //wait a bit, Smile
self giveWeapon( "onemanarmy_mp", 0, false ); //the first is the weapon name, the second is the camo and the false is because is not akimbo
wait ( 0.05 ); //wait to remove bugs
self switchToWeapon( "onemanarmy_mp", 0, false ); //switch to it
}



Save and load your mod on Liberation. Congratulations¡¡¡ You have built your first mod and your first easy code.



CREDITS TO:
YAMATO
(adsbygoogle = window.adsbygoogle || []).push({});

The following 5 users say thank you to KingcreekS for this useful post:

chris2k7sears, KCxFTW, Mr-Speedy, Pro Era, Uk_ViiPeR
08-05-2012, 09:01 PM #2
TL;dr but :y:
08-05-2012, 09:03 PM #3
Mr-Speedy
U wont @ me doe
TL;dr but :y: :carling:
08-05-2012, 10:50 PM #4
Tutorial #1:

Making your firs title.

You must login or register to view this content.


all jokes aside man, good job :y:
08-05-2012, 10:55 PM #5
IVI40A3Fusionz
Former Gaming Squad Member
This is nothing personal to anyone but it really ticks me off when i see coding like this,

    
for( ; ; )


Or other lines of code with spacing that's not really needed :\ i have no idea why but it just annoys me maybe i have a Coding OCD :p.

The following user thanked IVI40A3Fusionz for this useful post:

KingcreekS
08-19-2012, 10:55 PM #6
Skurt
Do a barrel roll!
I want to be #1 :fa:
08-19-2012, 11:10 PM #7
SKATEorDIE____
CrimeCityGangsta
Originally posted by CodySimpson View Post
Save and load your mod on Liberation.


lol it´s the MW2 section... did i miss sth or do we have liberation now? Happy

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo