Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Team code bug
#1
Hello,

For some time I make a mod on black ops. but I have a problem with this script.

Code:
Team()
{
else if (self.team == allies)
{
self takeallweapons();
self giveWeapon("ray_gun_zm");
self giveWeapon("molotov_sp");
}

else if(self.team == axis)
{
self takeallweapons();
self giveWeapon("freezegun_zm");
}
}

If someone could tell me where the problem is. (after the console is a problem with else if (self.team == allies))

Thanks,

Elite killer
Reply

#2
Hello,

else if (self.team == allies)

Why it starts with "else if()" and not with "if (...)" ?

Maybe that is the error.

***********
Usualy, conditions are as follow:
CSHARP Code
  1. if ("monday" == day)
  2. {
  3. // some code
  4. }
  5. else if ("tuesday" == day)
  6. {
  7. // some code
  8. }
  9. else if ("wednersday" == day)
  10. {
  11. // some code
  12. }
  13. else
  14. {
  15. // some code
  16. }
Reply

#3
Indeed as the above person posted, there has to be an if statement first, before you can have an else if statement. Try:

COD Code
  1. Team()
  2. {
  3. if (self.team == "allies")
  4. {
  5. self takeallweapons();
  6. self giveWeapon("ray_gun_zm");
  7. self giveWeapon("molotov_sp");
  8. }
  9.  
  10. else if(self.team == "axis")
  11. {
  12. self takeallweapons();
  13. self giveWeapon("freezegun_zm");
  14. }
  15.  
  16. else
  17. {
  18. return;
  19. }
  20. }


I put "" around axis and allies because they should be there, the else statement is probably not needed because there are no other teams than allies or axis, but just to be sure.[/php]
Reply

#4
then
now it works in the code onPlayerSpawned ()

Here is my code :

Code:
onPlayerSpawned()
{
    self endon("disconnect");
    for(;;)
    {
        self waittill("spawned_player");
                self thread Team();
Reply

#5
(10-03-2012, 16:11)Madnesslink5 Wrote: Indeed as the above person posted, there has to be an if statement first, before you can have an else if statement. Try:

COD Code
  1. Team()
  2. {
  3. if (self.team == "allies")
  4. {
  5. self takeallweapons();
  6. self giveWeapon("ray_gun_zm");
  7. self giveWeapon("molotov_sp");
  8. }
  9.  
  10. else if(self.team == "axis")
  11. {
  12. self takeallweapons();
  13. self giveWeapon("freezegun_zm");
  14. }
  15.  
  16. else
  17. {
  18. return;
  19. }
  20. }


I put "" around axis and allies because they should be there, the else statement is probably not needed because there are no other teams than allies or axis, but just to be sure.[/php]


Why 'return;' ?
Just use "switch(self.team)", its better;
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply

#6
Thx, but where i place this code ?
Reply

#7
He says that you can replace:
CSHARP Code
  1. Team()
  2. {
  3. if (self.team == "allies")
  4. {
  5. self takeallweapons();
  6. self giveWeapon("ray_gun_zm");
  7. self giveWeapon("molotov_sp");
  8. }
  9.  
  10. else if(self.team == "axis")
  11. {
  12. self takeallweapons();
  13. self giveWeapon("freezegun_zm");
  14. }
  15.  
  16. else
  17. {
  18. return;
  19. }
  20. }


By something like:
CSHARP Code
  1. Team()
  2. {
  3. switch(self.team)
  4. {
  5. case "allies":
  6. self takeallweapons();
  7. self giveWeapon("ray_gun_zm");
  8. self giveWeapon("molotov_sp");
  9. break;
  10. case "axis":
  11. self takeallweapons();
  12. self giveWeapon("freezegun_zm");
  13. break;
  14. default:
  15. break;
  16. }
  17. }


But why a switch for only 2 cases...? Discussion opened lol
Reply

#8
As it's gsc it doesn't really matter which one you use. But generally for 2 cases the best is if statement.
[Image: azuw.jpg]
Reply

#9
(10-06-2012, 19:29)zxz0O0 Wrote: As it's gsc it doesn't really matter which one you use. But generally for 2 cases the best is if statement.

Well, cases looks better than if statements lol....
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Call of Duty loser calls in SWAT team hoax on kid who beat him RaZ 3 4,088 04-24-2014, 19:31
Last Post: Casper
  Help Code color crosshairs koren30 3 4,025 10-02-2013, 19:26
Last Post: koren30
Question Help Team DAMAGE offhand E-losev 0 2,432 09-17-2013, 12:03
Last Post: E-losev
  Help choose 2 random players?(1 each team) 26hz 6 4,662 09-12-2013, 17:32
Last Post: Yamato
  Help need help?how to make plugins code hXnarutoXone 12 8,578 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Need Help with C# code tubwux 2 3,319 08-27-2013, 18:18
Last Post: tubwux
  [Request] Compile this code please dozsa0 4 4,147 08-10-2013, 21:02
Last Post: Nukem
  Compile this code please First_Semyon 12 9,710 08-08-2013, 14:53
Last Post: Bandarigoda123
  Compile please this code First_Semyon 8 5,651 07-28-2013, 01:52
Last Post: First_Semyon
  Code of vector Bloodfocus 1 2,415 06-23-2013, 11:54
Last Post: Yamato

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.