Post: my coding might be a bit wrong
12-28-2015, 05:19 PM #1
seanhellen
Are you high?
(adsbygoogle = window.adsbygoogle || []).push({}); Hi - I am building a gamemode, and I am wanting to be able to freeze the enemy in a tdm and unfreeze a team mate. I thought this would work, but it doesn't and I cant figure out why...can anyone spot why???

    StartTag()
{
foreach(player in level.players)
{
player TakeAllWeapons();
player giveWeapon("knife_held_mp");
player switchToWeapon("knife_held_mp");
player.maxhealth = 1000000;
player.health = player.maxhealth;
player thread Hit(player);
}
}

Hit(player)
{
player.Friendly = GetAssignedTeam(self);
player.Enemy = GetAssignedTeam(player);

for(;Winky Winky
{
if (player.health < player.maxhealth && player.Friendly != player.Enemy)
{
healthRegen = (self.maxhealth - self.health);
player.health += healthRegen;
player FreezeControls(true);
}
else if (player.health < player.maxhealth && player.Friendly == player.Enemy)
{
healthRegen = (self.maxhealth - self.health);
player.health += healthRegen;
player FreezeControls(false);
}
wait 0.2;
}
}


basically, if health goes down & team names dont match (opposite teams), then add health & freeze controls. If the teams match, then add health and un-freeze controls. This is the basic idea, but I've gone wrong somewhere :(

starttag is called in onplayerspawned and as it is here, I can go around and freeze anyone (friend or foe) and no-one dies (at least that bit works now...can knife as much as you want, wont die)

P.S. also as a side note, if anyone knows how to turn friendly fire on, that would be good too...tried a few ways I have found on here, but they dont work (settweakablevalues, setdvar & level.friendlyfire = 1)
(adsbygoogle = window.adsbygoogle || []).push({});
12-31-2015, 12:04 AM #2
Originally posted by seanhellen View Post
Hi - I am building a gamemode, and I am wanting to be able to freeze the enemy in a tdm and unfreeze a team mate. I thought this would work, but it doesn't and I cant figure out why...can anyone spot why???

    StartTag()
{
foreach(player in level.players)
{
player TakeAllWeapons();
player giveWeapon("knife_held_mp");
player switchToWeapon("knife_held_mp");
player.maxhealth = 1000000;
player.health = player.maxhealth;
player thread Hit(player);
}
}

Hit(player)
{
player.Friendly = GetAssignedTeam(self);
player.Enemy = GetAssignedTeam(player);

for(;Winky Winky
{
if (player.health < player.maxhealth && player.Friendly != player.Enemy)
{
healthRegen = (self.maxhealth - self.health);
player.health += healthRegen;
player FreezeControls(true);
}
else if (player.health < player.maxhealth && player.Friendly == player.Enemy)
{
healthRegen = (self.maxhealth - self.health);
player.health += healthRegen;
player FreezeControls(false);
}
wait 0.2;
}
}


basically, if health goes down & team names dont match (opposite teams), then add health & freeze controls. If the teams match, then add health and un-freeze controls. This is the basic idea, but I've gone wrong somewhere :(

starttag is called in onplayerspawned and as it is here, I can go around and freeze anyone (friend or foe) and no-one dies (at least that bit works now...can knife as much as you want, wont die)

P.S. also as a side note, if anyone knows how to turn friendly fire on, that would be good too...tried a few ways I have found on here, but they dont work (settweakablevalues, setdvar & level.friendlyfire = 1)


Lots and lots of redundancies in here, but what I put together should help, unless getAssignedTeam does something that I'm not seeing here, and I'm unsure why this is running forever and ever, but that's nothing I need to care about. If you have any more questions, feel free to ask.

    
Hit(player)
{
for(;Winky Winky
{
if (player.health < player.maxhealth) {
healthRegen = (self.maxhealth - self.health);
player.health += healthRegen;
player FreezeControls(player.pers["team"] != self.pers["team"]);
wait 0.2;
}
}
}
12-31-2015, 12:14 PM #3
seanhellen
Are you high?
Not sure but the arg for freezecontrols is a bool...woukd the team check there automatically return a true/false?

I am a bit of a newb with gsc and a no ice qt coding in general to be fair so i tend to get stuff working and then tidy it up afterwards...i know i should tidy as i go but hey lol
12-31-2015, 03:19 PM #4
Originally posted by seanhellen View Post
Not sure but the arg for freezecontrols is a bool...woukd the team check there automatically return a true/false?

I am a bit of a newb with gsc and a no ice qt coding in general to be fair so i tend to get stuff working and then tidy it up afterwards...i know i should tidy as i go but hey lol


Yes, what I wrote should work correctly, haven't tested it though.
And gotcha
12-31-2015, 06:50 PM #5
seanhellen
Are you high?
Originally posted by Sabojohn View Post
Yes, what I wrote should work correctly, haven't tested it though.
And gotcha


I have just tried it and unfortunately it didnt work...just lots of stabing going on lol.
And since you mentioned it, I don't know why I had the loop there either...so i took that out too.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo