Quote:
Originally Posted by xXziroXx
I always do something like this whenever I know I'll use a class for both NPC's and players:
PHP Code:
function myFunction()
{
if (objecttype() == "TServerPlayer") temp.obj = "player";
else if (objecttype() == "TServerNPC") temp.obj = "this";
(@obj).variable = 666;
(@obj).triggerAnotherCoolFunction();
}
Etcetera etcetera.
|
Not necessary. If this.objecttype() is returning TServerPlayer, then "this." is already pointing to the player. Therefore, the whole "temp.obj" thing is redundant and you could just use "this." to refer to whatever you joined the class to, regardless of what it is.