Call of Duty 4: Custom Dvars: Difference between revisions
No edit summary |
m (Protected "Call of Duty 4: Custom Dvars" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite))) |
||
(One intermediate revision by the same user not shown) | |||
Line 89: | Line 89: | ||
[[Category:Call of Duty 4]] | [[Category:Call of Duty 4]] | ||
[[Category:Modding]] | [[Category:Modding]] | ||
Latest revision as of 11:37, 6 July 2011
By Drofder2004
if(getdvar("<dvar>") == "") setdvar("<dvar>", "<default>");
(Code above in pseudocode)
"If dvar <dvar> is equal to nothing (if it doesn't exist)...
...create dvar with default value"
Thats the bare basics.
Next you can create minimum and maximum values (if the dvar is numeric)
if(getDvar("<dvar>") == "") setDvar("<dvar>", "<default>"); else if(getDvarInt("<dvar>") > 10) setDvar("<dvar>", 10); else if(getDvarInt("<dvar>") < 0) setDvar("<dvar>", 0);
Again, pseudocode, starting at line 3 (continued from above).
...else, if the dvar is greater than 10, set the dvar to 10, or
...if the dvar is less than 0, set it to 0.
Make sure you get you note the usage of getDvar and getDvarInt (also, you can use getDvarFloat, to retrieve decimal values).
And finally, using the dvar in your script. Now, there are many ways to use the dvar, but the main way is to use it as a variable.
if(getDvar("<dvar>") == "") setDvar("<dvar>", "<default>"); else if(getDvarInt("<dvar>") > 10) setDvar("<dvar>", 10); else if(getDvarInt("<dvar>") < 0) setDvar("<dvar>", 0); <variable> = getDvarInt("<dvar>");
Remeber, use the correct 'getDvar', use...
- getDvar for TEXT based dvars (example:
getDvar("g_gametype");
) - getDvarInt for INTEGERS (whole number, example:
getDvarInt("scr_forcerespawn");
) - getDvarFloat for FLOATS (decimals, example:
getDvarFloat("scr_hq_timelimit");
)
For example,
main() { while(getDvar("wait") != 0) { wait 1; } iprintln("Wait dvar is equal to 0"); }
The while()
in the above script will keep waiting 1 second, until the dvar is changed to 0, once changed, the main function will continue.
Now you know dvars!