View Single Post
  #4  
Old 01-18-2008, 07:32 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Do clientside, just make it so when you kill a baddy it dies on other player's clients too. Its not hard.
Quote:
Originally Posted by DustyPorViva
but since you can only send data to the clientside through attr's...
When an npc is created on clientside it would have an ID variable which you can use to locate it from any client. Thats how you go from serverside to clientside.
PHP Code:
// Script in the NPC
public function sendserverkill(omitleveln) {
  for (
temp.iallplayers) {
    if (
i.account == omit || i.level.name != leveln)
      continue;
    
with (iSystem.clientfunction2(null"npcfunction"this.id"onServerKill");
  }
}
//#CLIENTSIDE
function onServerKill() {
  
// When the kill message is received from server.
}
function 
sendserverkill() {
  
System.serverfunction2(null"npcfunction"this.levelthis.id"sendserverkill"player.accountthis.level);

It is using this class:
PHP Code:
// Serverside to Clientside Function
public function clientfunction(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
temp.out 0;

  
triggerclient("gui"this.name"clientfunction"fobjfnamep0p1p2p3p4p5p6p7p8p9);
  
waitfor(this"ClientFunctionEnd"5);
  
temp.out thiso.cfreturn;
  
thiso.cfreturn null;
  return 
temp.out;
}
public function 
clientfunction2(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
triggerclient("gui"this.name"clientfunction2"fobjfnamep0p1p2p3p4p5p6p7p8p9);
}
public function 
npcfunction(p0p1p2p3p4p5p6p7p8p9) {
  
temp.obj findlevel(p0);
  for (
temp.iobj.npcs) {
    if (
i.id == p1) {
      
i.(@ p2)(p3p4p5p6p7p8p9);
      break;
    }
  }
}
function 
onActionServerSide() {
  if (
params[0] == "end") {
    
thiso.cfreturn params[1];
    
trigger("ClientFunctionEnd"null);
  }
  else if (
params[0] == "serverfunction") {    
    if (
params[1] != null)
      
triggerclient("gui"this.name"end"makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
    else 
      
triggerclient("gui"this.name"end"makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
  }
  else if (
params[0] == "serverfunction2") {
    if (
params[1] != null)
      
makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
    else 
      
makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
  }
}
//#CLIENTSIDE
function onActionClientSide() {
  if (
params[0] == "end") {
    
thiso.sfreturn params[1];
    
trigger("ServerFunctionEnd"null);
  }
  else if (
params[0] == "clientfunction") {    
    if (
params[1] != null)
      
triggerserver("gui"this.name"end"makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
    else 
      
triggerserver("gui"this.name"end"makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]));
  }
  else if (
params[0] == "clientfunction2") {
    if (
params[1] != null)
      
makevar(params[1] @ "." params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
    else 
      
makevar(params[2])(params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11], params[12]);
  }
}
public function 
npcfunction(p0p1p2p3p4p5p6p7p8p9) {
  
findnpcbyid(p0).(@ p1)(p2p3p4p5p6p7p8p9);
}
public function 
serverfunction(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
temp.out 0;
  
  
triggerserver("gui"this.name"serverfunction"fobjfnamep0p1p2p3p4p5p6p7p8p9);
  
waitfor(this"ServerFunctionEnd"5);
  
out thiso.sfreturn;
  
thiso.sfreturn null;
  return 
out;
}
public function 
serverfunction2(fobjfnamep0p1p2p3p4p5p6p7p8p9) {
  
triggerserver("gui"this.name"serverfunction2"fobjfnamep0p1p2p3p4p5p6p7p8p9);

For some reason, clientside level objects don't have anything in their npcs variable, only on serverside.

You could also make your own system for keeping track of baddy objects by ID on clientside and serverside.
__________________

Last edited by Inverness; 01-18-2008 at 09:12 AM..
Reply With Quote