View Single Post
  #3  
Old 08-04-2008, 02:24 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xXziroXx View Post
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.
Reply With Quote