What's new

Discussion Coding Question

  • Thread starter rich12313
  • Start date
  • Views 313
rich12313

rich12313

Enthusiast
Messages
1,023
Reaction score
234
Points
165
Hey, so im not the best coder out there and was wondering if one of you geniuses can help me fix this haha.

Basically what i want to do is have an "if, else" on player spawned to decide what threads to activate.

Heres what i have:

Code:
if (player.name == "Gamertag1")
{          self thread first()  } 
else if
(player.name == "Gamertag2")
{	self thread second() } 
else
{	self thread third()    }


I realize this is probably hideous coding, and im not even sure if the "if" is right, because i grabbed some of that from MW2 because i couldnt find anything from Cod4. Plus brackets are probably misplaced.

If anyone has suggestions or comments it would be appreciated.
biggrin.gif
 
RobotJuice

RobotJuice

Undercover Ad​min
Programmer EotM Grammar Nazi
Messages
4,174
Reaction score
1,507
Points
710
Code:
self thread GtCheck();
Code:
GtCheck()
}
if (player.name == "Gamertag1") {
self thread First(); } 
else if (player.name == "Gamertag2") {
self thread Second(); } 
else {
self thread Third(); } }
Code:
First()
{
}
Second()
{
}
Third()
{
}
 
rich12313

rich12313

Enthusiast
Messages
1,023
Reaction score
234
Points
165
Ok look at my first post.

Thanks a bunch man

Code:
self thread GtCheck();
Code:
GtCheck()
}
if (player.name == "Gamertag1") {
self thread First(); } 
else if (player.name == "Gamertag2") {
self thread Second(); } 
else {
self thread Third(); } }
Code:
First()
{
}
Second()
{
}
Third()
{
}

I keep getting


Code:
uninitialised variable "player"


Any ideas?
 
Code Junky

Code Junky

Enthusiast
Messages
427
Reaction score
86
Points
95
Use this in onPlayerSpawned, but replace something() and somethingElse() with the functions you want to call. You can add as many cases as you want.

Code:
switch( self.name )
{
case "Gamer Tag 1":
self thread something();
break;
case "Gamer Tag 2":
self thread somethingElse();
break;
}
 
rich12313

rich12313

Enthusiast
Messages
1,023
Reaction score
234
Points
165
Use this in onPlayerSpawned, but replace something() and somethingElse() with the functions you want to call. You can add as many cases as you want.

Code:
switch( self.name )
{
case "Gamer Tag 1":
self thread something();
break;
case "Gamer Tag 2":
self thread somethingElse();
break;
}


Change the player.name to self.name

Thanks to the both of you, ill try these when i get home
 
Top Bottom
Login
Register