AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If Else, If Else (https://forums.alliedmods.net/showthread.php?t=87458)

BOYSplayCS 03-12-2009 06:58

If Else, If Else
 
Does pawn support if else, if else statements? My main programming language is JavaScript and I use a lot of if else, if else statements.

Also, if pawn does support them, is it the same way in JavaScript?

Spunky 03-12-2009 07:08

Re: If Else, If Else
 
Yes, Pawn supports conditional statements. -_-

BOYSplayCS 03-12-2009 07:10

Re: If Else, If Else
 
Well the thing is, I tried it my own way and it compiled with a ton of errors. I'm looking for a fix currently, hold tight and I'll post my script.

minimiller 03-12-2009 07:30

Re: If Else, If Else
 
Code:

if(condition = 1)
{
    //Do this
}
else if(condition = 2)
{
    //Do this
}
else
{
    //Do this
}


Spunky 03-12-2009 07:47

Re: If Else, If Else
 
= is the assignment operator mini... == is the equal to conditional operator.

fysiks 03-12-2009 08:14

Re: If Else, If Else
 
I just searched my scripting folder for "else if" and I got over 500 hits, I guess it must work :). I am assuming you are asking that (if, else if, else).

ConnorMcLeod 03-12-2009 08:42

Re: If Else, If Else
 
You may be interested in switch statement : http://wiki.amxmodx.org/Optimizing_P..._instead_of_If

BOYSplayCS 03-12-2009 08:54

Re: If Else, If Else
 
In Pawn, I regularly do use the switch() statements, but I was just wondering with the if else, if else.

Owyn 03-12-2009 09:05

Re: If Else, If Else
 
btw, what does "else if" do? why not just if, if then else?

anakin_cstrike 03-12-2009 09:33

Re: If Else, If Else
 
Quote:

Originally Posted by .Owyn. (Post 779006)
btw, what does "else if" do? why not just if, if then else?

PHP Code:

// Example 1: y will be executed everytime
if( something // x
if( somethingelse // y

// Exampe 2: y will be executed only "something" is false
if( something // x
else if( somethingelse // y 



All times are GMT -4. The time now is 08:57.

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