Post: Tutorial: How to Make a Function! (Basic)
03-02-2013, 11:34 PM #1
(adsbygoogle = window.adsbygoogle || []).push({});
Hey Guys, Welcome to My Tutorial!
[/B][/CENTER]

This is a Very Basic Tutorial on How to Make Script for MW2, Today we Will make A Simple Drug Code! We will start With The Basics, And then progress Winky Winky

Video of the Outcome:
No video Yet, Record and it will be much apreciated!

First off we need a Function Name, For ex: subarudemonsTut, So:

subarudemonsTut()


But now we need to add the Function Beggining, So:

subarudemonsTut()
{
}


Now we're going to need to add A ending Function, Unless you want this on-going dont do this!


subarudemonsTut()
{
self endon("death");
self endon("disconnect");
}


Or altenitivly, If you want to end it on a Command, Do This:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");

//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}


Ok, So now we've got a Function, That basically does nothing >:< But now Lets say if we're going to Activate the Function upon Button Press, Lets do this:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
}


Now, Im going to add A Welcome Script, So we Know that we Have Activated it, So:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
self notify("StopPlease");
self iPrintLnBold("^2Drug Code: ^6Activated!");
wait 3;
self iPrintLnBold("^1To stop, ^2Press: ^6[{+smoke}]");
if(self isButtonPressed == ("+smoke"))
{
self notify("StopPlease");
self setVisionNakedForPlayer("default");
self setPlayerAngles( HighModeAngle + ( 0, 0, 0 ) );
}
}


Now were going to add the "Drug Look" So it dosent Look like we're just Demented Winky Winky So... Yet Again:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
self notify("StopPlease");
self iPrintLnBold("^2Drug Code: ^6Activated!");
wait 3;
self iPrintLnBold("^1To stop, ^2Press: ^6[{+smoke}]");
if(self isButtonPressed == ("+smoke"))
{self notify("StopPlease");
self setVisionNakedForPlayer("default");
self setPlayerAngles( HighModeAngle + ( 0, 0, 0 ) );
}
self setClientDvar("cg_laserForceOn","1");
self setClientDvar("cg_fov","99");
}


Ok, Now we have got Laser Aim and a Incredibly Long Gun (Promod)! But now we're going to make the Player's Crosshair rotate Every Second, So:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
self notify("StopPlease");
self iPrintLnBold("^2Drug Code: ^6Activated!");
wait 3;
self iPrintLnBold("^1To stop, ^2Press: ^6[{+smoke}]");
if(self isButtonPressed == ("+smoke"))
{
self notify("StopPlease");
self setVisionNakedForPlayer("default");
self setPlayerAngles( HighModeAngle + ( 0, 0, 0 ) );
}
self setClientDvar("cg_laserForceOn","1");
self setClientDvar("cg_fov","99");
for( ; ; )
{
self setPlayerAngles( HighModeAngle + ( 0, 0, 45 ) );
wait 10;
self setPlayerAngles( HighModeAngle + ( 0, 0, 90 ) );
wait 10;
self setPlayerAngles( HighModeAngle + ( 0, 45, 90) );
wait 10;
self setPlayerAngles( HighModeAngle + ( 0, 90, 90 ) );
wait 10;
self setPlayerAngles( HighModeAngle + ( 45, 90, 90 ) );
wait 10;
self setPlayerAngles( HighModeAngle + ( 90, 90, 90 ) );
wait 10;
}


Ok, So we're Nearly done... But now im going to add custom visions and add some Flashing Text, To make it a little bit more Drugified Winky Winky Sooo:

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
self notify("StopPlease");
self iPrintLnBold("^2Drug Code: ^6Activated!");
wait 3;
self iPrintLnBold("^1To stop, ^2Press: ^6[{+smoke}]");
if(self isButtonPressed == ("+smoke"))
{
self notify("StopPlease");
self setVisionNakedForPlayer("default");
self setPlayerAngles( HighModeAngle + ( 0, 0, 0 ) );
}
self setClientDvar("cg_laserForceOn","1");
self setClientDvar("cg_fov","99");
self thread ("FunkyText");
for( ; ; )
{
self setPlayerAngles( HighModeAngle + ( 0, 0, 45 ) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 0, 90 ) );
self setVisionNakedForPlayer("airport_green");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 45, 90) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 90, 90 ) );
self setVisionNakedForPlayer("ac130_inverted");
wait 1;
self setPlayerAngles( HighModeAngle + ( 45, 90, 90 ) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 90, 90, 90 ) );
self setVisionNakedForPlayer("black_bg");
wait 1;
}
FunkyText()
{
self endon("death");
for( ; ; )
notifyData=spawnstruct();
notifyData.titleText="Bro, Get off the Coke!";
notifyData.glowColor =(0,0,1);
notifyData.sound="mp_level_up";
notifyData.duration=4;
notifyData.font="hudbig";
self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
wait 1;
notifyData=spawnstruct();
notifyData.titleText="Bro, Get off the Coke!";
notifyData.glowColor =(1,0,0);
notifyData.sound="mp_level_up";
notifyData.duration=4;
notifyData.font="hudbig";
self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
wait 1;
}


Ok guys, You have made your own Drug Code, But obviously it will work with any other idea of a mod.. This is just Basics to lift you Poeple who Need help Of the Ground! So yea, Here is the Function (If you use, Please give Credits):

subarudemonsTut()
{
self endon("death");
self endon("ByeFunction");
self iPrintLn("^2Press: [{+actionslot 1}] To Activate!");
if(self isButtonPressed == ("+actionslot 1"))
{
self thread("TrolledYouLol");
}
//This function Is so that we Don't get Any Errors!
wait 210;
self notify("ByeFunction");
}
TrolledYouLol()
{
self endon("death");
self notify("StopPlease");
self iPrintLnBold("^2Drug Code: ^6Activated!");
wait 3;
self iPrintLnBold("^1To stop, ^2Press: ^6[{+smoke}]");
if(self isButtonPressed == ("+smoke"))
{
self notify("StopPlease");
self setVisionNakedForPlayer("default");
self setPlayerAngles( HighModeAngle + ( 0, 0, 0 ) );
}
self setClientDvar("cg_laserForceOn","1");
self setClientDvar("cg_fov","99");
self thread ("FunkyText");
for( ; ; )
{
self setPlayerAngles( HighModeAngle + ( 0, 0, 45 ) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 0, 90 ) );
self setVisionNakedForPlayer("airport_green");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 45, 90) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 0, 90, 90 ) );
self setVisionNakedForPlayer("ac130_inverted");
wait 1;
self setPlayerAngles( HighModeAngle + ( 45, 90, 90 ) );
self setVisionNakedForPlayer("abstract");
wait 1;
self setPlayerAngles( HighModeAngle + ( 90, 90, 90 ) );
self setVisionNakedForPlayer("black_bg");
wait 1;
}
FunkyText()
{
self endon("death");
for( ; ; )
notifyData=spawnstruct();
notifyData.titleText="Bro, Get off the Coke!";
notifyData.glowColor =(0,0,1);
notifyData.sound="mp_level_up";
notifyData.duration=4;
notifyData.font="hudbig";
self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
wait 1;
notifyData=spawnstruct();
notifyData.titleText="Bro, Get off the Coke!";
notifyData.glowColor =(1,0,0);
notifyData.sound="mp_level_up";
notifyData.duration=4;
notifyData.font="hudbig";
self thread maps\mp\gametypes\_hud_message::notifyMessage(notifyData);
wait 1;
}


If this Code dosent work for any reason, Tell me... As i made this upon my Knowledge, And no Testing![/B]

The following 5 users groaned at SUBARUDEMON for this awful post:

ϟ c0rruption ϟ, 247Yamato, blackhawk2299, Midnight, Restxrt Modz
03-06-2013, 06:45 PM #20
Originally posted by XD View Post
no problems bro Little things can turn up being the biggest


Originally posted by XD View Post
Dont worry about taylor and Ro.
there good coders and they shouldnt be doing this to People who dont know how to code
++ they started like you and ended up like They are now but thats not the point, the point is dont give up because of peoples shitty thoughts
what matters is what you know and try to help people with things.
dont give up ill try to help you out trew the side but i cant promise you work like they do


Originally posted by SUBARUDEMON View Post
Thanks for telling me how to fix, I wasnt even going to use the drug script anyway... It was something random... Because i am random Winky Winky


Originally posted by XD View Post
BTW Ima fix this 1 for you

iHcXDFix()
{
self iPrintLn("^4Press: [{+actionslot 1}] To Spam");
self notifyOnPlayerCommand( "iHcXD". "+actionslot 1" );
{
self waittill("iHcXD");self thread iHcSpam( iHc );
}
}
iHcSpam(){iHc iPrintln("This is a simple fix so dont hate");}


Originally posted by SUBARUDEMON View Post
Cheers for the Advice bro! And i Agree, Yes... It may have errors, I litteraly typed on NGU so its not as easy as in Notepad++! Plus, I was only trying to help the people who arn't as Good as me,You,Ro or even Taylor to get of the Ground, Thanks again :love:


arent you two cute, saying some of the best coders of c++ in this time are hating on a very bad, poorly coded, and error filled code. its called constructive critisim. its meant to help the bad coders like both of you who dont know what your doing/talking about learn the correct things to do. neither of you have the correct way to approach this, and need to respect taylor and ro, because their both personal friends of mine and the community and have contributed way more then just a crappy thread that shows people numerous bad errors.

The following user thanked blackhawk2299 for this useful post:

backstop12
03-07-2013, 12:03 AM #21
ByteSource
League Champion
Originally posted by blackhawk2299 View Post
arent you two cute, saying some of the best coders of c++ in this time are hating on a very bad, poorly coded, and error filled code. its called constructive critisim. its meant to help the bad coders like both of you who dont know what your doing/talking about learn the correct things to do. neither of you have the correct way to approach this, and need to respect taylor and ro, because their both personal friends of mine and the community and have contributed way more then just a crappy thread that shows people numerous bad errors.

theres no reason for you to talk because if it wasnt for them u will never would of haved that 1.11 patch i know the helped you with it thats why you succeeded. see this kid didnt get there help so i wouldnt start talking im not trying to have a arguement with you its just the truth

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo