AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   while loop (https://forums.alliedmods.net/showthread.php?t=351)

MagicShot 03-19-2004 18:42

while loop
 
How would you write a "while loop"? :?

BAILOPAN 03-19-2004 19:11

while (condition)
{
//code
}



ex.. loop from 0 to 50
new i = 0
while (i++ < 50) {
//stuff
}

QwertyAccess 03-19-2004 19:29

i see a new OLO

Freecode 03-19-2004 19:43

Quote:

Originally Posted by QwertyAccess
i see a new OLO

dont gotta be OLO to know this.

tnsk8er27 03-19-2004 20:12

lol i know


i coulda told him how LOL

MagicShot 03-19-2004 21:27

hmm
 
Thanx Bail!
How Does this Look?

Code:
weapname() {     new i = 0     while (i++ < 50) {         if (weaponname[i][0] == weap) {             curweap = i             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE }

BAILOPAN 03-19-2004 21:40

I think you need to read a bit about multidim character arrays...

if weaponname[X][], X goes up to 50, it'll work, but since I don'tknow what you're doing, eh. weap isn't even defined, what is it?

MagicShot 03-19-2004 21:59

Umm
 
Its part of that weap thing I am working on.. Most Current Source is here to see what it looks like.. Keep in mind.. Most of the Basics are there but not complete yet.. I think it the basics shoudl I think work. :?

:idea: :arrow: http://forums.alliedmods.net/showthr...p?t=216&page=2

PM 03-20-2004 03:23

Quote:

Originally Posted by BAILOPAN
while (condition)
{
//code
}



ex.. loop from 0 to 50
new i = 0
while (i++ < 50) {
//stuff
}

most people use for loops for that kind of looping :)
Code:
new i; for (i = 0; i <= 50; ++i) {    // stuff }
that should be more readable for people new to scripting...

Peli 03-20-2004 03:37

Hello , I'm trying to learn scripting and I have a question for you PM ,
Code:
new i; for (i = 0; i <= 50; ++i) {    // stuff }
What does that do? I know it's an example and not a plugin but explain to me a bit more I'm new :)


All times are GMT -4. The time now is 20:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.