Post: adding and subtracting
11-26-2015, 02:44 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); hey guys quick question

im trying to make something so i will show you an example of a function
best way to explain it


    onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");

self waittill("spawned_player");

if(isAlive(self))
{
level.playersalive +=1;
}
}

onPlayerDied()
{
self endon("disconnect");
level endon("game_ended");

self waittill("death");

level.playersalive -=1;
}

Function()
{
if(level.playersalive <= 1)
{
level thread DoThisThread();
}
}


thats basically what i want, i want the opposite of +=1 so that it takes away 1 when you die
-=1 doesnt work thats why im asking haha

much appreciated if someone knows how to answer this Smile
(adsbygoogle = window.adsbygoogle || []).push({});
11-26-2015, 03:02 PM #2
anthonything
Space Ninja
+=-1 , -=1, = level.playersalive - 1, = level.playersalive + -1, ...
11-26-2015, 03:58 PM #3
BullyWiiPlaza
Climbing up the ladder
If
    level.playersalive -=1;

isn't working, you can do
    level.playersalive += -1;

lol
11-26-2015, 04:11 PM #4
Loz
Vault dweller
Originally posted by OfficialCoolJay View Post
snip


get_all_alive_players_s() // look in _utility
or just use level.aliveplayers instead of level.playersalive

The following user thanked Loz for this useful post:

OfficialCoolJay
11-26-2015, 04:46 PM #5
jwm614
NextGenUpdate Elite
level.playersalive--;

The following user thanked jwm614 for this useful post:

OfficialCoolJay
11-27-2015, 03:38 AM #6
Originally posted by jwm614 View Post
level.playersalive--;


thanks worked man Smile

for people who are also curious this is an example function of how i use this:

    Init()
{
level.testcounter = 0;

level thread onPlayerSpawned();
}

onPlayerSpawned()
{
self waittill("spawned_player");

if(self isHost())
{
self thread TestCounter();
}
}

TestCounter()
{
level waittill("prematch_over");

for(;Winky Winky
{
if(self actionSlotOneButtonPressed())
{
level.testcounter +=1;
iPrintlnBold("Counter =", level.testcounter);
}

if(self actionSlotTwoButtonPressed())
{
level.testcounter --1;
iPrintlnBold("Counter =", level.testcounter);
}
wait 0.01;
}
}

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo