level.variable++ levell.variable--

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

level.variable++ levell.variable--

Post by agentmad007 »

hello ,

if i write:

Code: Select all

level.variable = 0 
Then

Code: Select all

level.variable++
Will add +1.

My question is How to take out an unit of the level.variable ( sorta level.variable--)

my guess was:

Code: Select all

level.variable = 0
level.fix = 1

Code: Select all

level.variable = (level.variable - level.fix)
The console has not complained yet , but i am unsure if it will work as i want to.

Thx
Deadly and slient.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

--

Post by tltrude »

Here are a couple of thread fragments from the global/obj_dm.scr script. Notice the "level.bombs_planted" variable lines.
if (local.counter >= level.bomb_set_time)
{
iprintlnbold "A Bomb has been planted!"
if (level.planting_team == "allies")
self playsound dfr_objective_o
else
self playsound den_objective_o
thread bomb_waittill_defuse
thread bomb_waittill_explode
self.live = 1
level.bombs_planted ++
end
}

if (local.counter >= level.bomb_defuse_time)
{
iprintlnbold "A Bomb has been defused!"
if (level.defusing_team == "allies")
self playsound dfr_diffused_d
else
self playsound den_diffused_d
thread bomb_waittill_set //start first thread again
self.live = 0
level.bombs_planted --
end
}
Tom Trude,

Image
agentmad007
Brigadier General
Posts: 570
Joined: Tue Feb 24, 2004 3:52 pm

Post by agentmad007 »

Ok so the level.variable -- work lol.Thought it does not exist as i never corssed it in any scripts before.

THANKS
Deadly and slient.
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

if the other number never changes (say you're always going to add 5) then you don't need another variable.

level.number += 5 // adds 5 to level.number
level.number -= 5 // subracts...
level.number++ // adds one
level.number-- // subtracts...

if you're say adding the player's health to his angles (why you would do this is beyond me) you'd do it like that.

local.weird = ( $player[local.i].health + $player[local.i].angles )

just as an example of when to use variables to add stuff ;)
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

~`~`~ Script Error: cannot cast 'vector' to 'float' :( :P
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

local.weird = lizardkid :lol:
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

angles is a vecter?

*checks*

wow... i thought it was just a number :'(

while(local.weird == "lizardkid")
{
self.laugh
}
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

ERROR: Command Overflow: Possible Infinate loop in thread.

okok sorry! :twisted:
Post Reply