AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need a little help with an "if else" statement (https://forums.alliedmods.net/showthread.php?t=3324)

kingpin 07-03-2004 15:14

need a little help with an "if else" statement
 
cansomeone throw me a quick line on an if else statement where

Code:
public plugin_precache() if(get_cvar_num("sv_blah is one") {     spritethingy = precache_model("some sprite");     return PLUGIN_HANDLED } else {     spritethingy = precache_model("some other sprite");     return PLUGIN_CONTINUE; }

thanx.

so If sv_blah is set to one in server then it should precache and use sprite x otherwise sprite y.

Dygear 07-03-2004 15:35

Re: need a little help with an "if else" statemen
 
Code:
public plugin_precache()[{     if(get_cvar_num("sv_blah is one") {         spritethingy = precache_model("some sprite");         return PLUGIN_HANDLED     }else{         spritethingy = precache_model("some other sprite");         return PLUGIN_CONTINUE;     }   }

Try that.

kingpin 07-03-2004 15:50

hmm thanx but I stil get the same error that I was able to work it down to :
Code:

warning 209: function "plugin_precache" should return a value

Dygear 07-03-2004 16:01

Code:
public plugin_precache()[{     if(get_cvar_num(sv_blah == "1") {         spritethingy = precache_model("some sprite");         return PLUGIN_HANDLED     }else{         spritethingy = precache_model("some other sprite");         return PLUGIN_CONTINUE;     }     }

kingpin 07-03-2004 16:11

Quote:

Originally Posted by Dygear
Code:
public plugin_precache()[{     if(get_cvar_num(sv_blah<b> == "1"</b>) {         spritethingy = precache_model("some sprite");         return PLUGIN_HANDLED     }else{         spritethingy = precache_model("some other sprite");         return PLUGIN_CONTINUE;     }     }

damnit gotta stop forgetting some stuff.... was fogetting the == "1" part.

Dygear 07-03-2004 16:14

LOL, so it worked.
I helped, im happy!

Quote:

Originally Posted by kingpin
hmm thanx but I stil get the same error that I was able to work it down to :
Code:

warning 209: function "plugin_precache" should return a value

Really, that code should of fixed an error, you wear missing a set of curly brackets.
This code wll now fix the rest of that, you can not say "sv_blah is one" it must be "sv_blah == "1""

kingpin 07-03-2004 16:16

thanx dy :)

Dygear 07-03-2004 16:16

:P Glad I could help, even tho I am a noobie.

*edit made both I caped*
*edit added these edits*

kingpin 07-03-2004 16:17

lmao yeah ofcourse... u noob :twisted: lol now goto sleep already before u fall over.

Dygear 07-03-2004 16:18

actualy does this help move my rank up, from like noobie to like better-then-your-average-noob ?


All times are GMT -4. The time now is 14:45.

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