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
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
if ("monday" == day)
{
// some code
}
else if ("tuesday" == day)
{
// some code
}
else if ("wednersday" == day)
{
// some code
}
else
{
// some code
}
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
Team()
{
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");
}
else
{
return;
}
}
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]
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();
(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
Team()
{
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");
}
else
{
return;
}
}
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;
Thx, but where i place this code ?
He says that you can replace:
CSHARP Code
Team()
{
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");
}
else
{
return;
}
}
By something like:
CSHARP Code
Team()
{
switch(self.team)
{
case "allies":
self takeallweapons();
self giveWeapon("ray_gun_zm");
self giveWeapon("molotov_sp");
break;
case "axis":
self takeallweapons();
self giveWeapon("freezegun_zm");
break;
default:
break;
}
}
But why a switch for only 2 cases...? Discussion opened lol
As it's gsc it doesn't really matter which one you use. But generally for 2 cases the best is if statement.
(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....