![]() |
Just going to mess around with some stuff
hey, im Nightmare, and yes, im new to scripting, so now im going to try to learn to script.
im trying to make a weapon that will overheat, this is what i have so far: PHP Code:
|
Needs some work ;)
One thing I noticed right away was you were doing if ( var = ! var2 ) use if ( var != var2 ) |
Quote:
|
Well try to change the key pressed part to this,
function onKeyPressed() { if (keydown2(getkeycode("s"),true)) { if (this.active) { if (this.overheat = !100) { //shoot functions.. havent gotten that far.. this.overheat +=1; } } } } |
PHP Code:
|
Quote:
PHP Code:
|
Well hes saying it over heats, so im guessing you needed to charge it ;O?
|
For guns you would want something like this:
PHP Code:
|
Quote:
|
Quote:
If you knew GS1, it's basically equivelant to a variable with no prefix, which is lost after the function is over. temp.k just told me true/false the key is pressed. I could have eliminated this and made it into an if statement; this was just easier and simpler. this.isKeyPressed tells me if LAST time around it was pressed, so I can tell if it is being held down, or touched once. This is so you can have modes such as single, automatic, etc. |
in essence, it causes a fraction of a fraction of less lag, (Which adds up quick) It basically saves Memory, (RAM Memory Space).
this.var is saved until it is updated again. temp.var is saved until the function, that it was called in, ends. =] |
*knocks on wood*
|
Quote:
|
Quote:
|
Function parameters are also automatically temp. variables and can be referenced as such.
Once you declare a temp. variable you can reference it without the prefix and it will not be a global. Because of this for most functions I prefer to declare all my temp.variable = 0; at the beginning of the function. Ex: PHP Code:
|
| All times are GMT +2. The time now is 09:02 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.