Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Another triggeraction (https://forums.graalonline.com/forums/showthread.php?t=84999)

Schetti 04-05-2009 08:01 AM

Another triggeraction
 
Yea, a question about trigger again ... :(

That is the weapon, its used to add/remove the flag(Ctf-flag) to the player
PHP Code:

//Weapon
function onActionserverside() {
  switch (
params[0]) {
    case 
"remove":
player.removeWeapon("-System/Ctfblue");
sleep 1;
    }
  }

//#CLIENTSIDE
function onPlayerChats() {
if (
player.chat == "Drop Flag") {
replaceani walk,walk;
replaceani idle,idle;
setani("idle",null);
triggerserver("gui"this.name"remove");
 }


The weapon works pretty well, but I also got a class, wich is totally NOT working.

This is the class, and here the trigger doesnt work, someone can tell me why and/or give me an example to make it working?
I am totally :confused:
PHP Code:

//Class
function onCreated() {
  
this.setshape(1,32,32);
  
this.blueowner 2;
  
this.dir 1;
  
this.setcharani("sch_ctfblueidle",null);
  
this.blockagain();
}

function 
onActionReturn() {
  if (
client.blueowner == "1") {
  
this.blueowner 2;
  
this.dir 1;
  
client.blueowner 2;
      
this.show();
 }
}

//#CLIENTSIDE
function onPlayerChats() {
if (
player.chat == "Drop Flag")
triggeraction(this.xthis.y"Return"null);

 }


Note: I wont look on forums until Thursday, so dont wonder if I dont answer, but I would be happy to see some suggestions if I come back

cbk1994 04-05-2009 03:55 PM

You're mixing GS1 and GS2, which is a very bad thing.

Here's your weapon. Basically just doing the same thing, but with some GS2 corrections/styling.

PHP Code:

function onActionServerSide(cmd) {
  switch (
cmd) {
    case 
"removeWeapon": {
      
player.removeWeapon("-System/Ctfblue"); // Is this seriously the name of the weapon?
      
break;
    }
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "drop flag") {
    
replaceani("walk""walk");
    
replaceani("idle""idle");
    
setani("idle"null);
    
triggerserver("gui"name"removeWeapon");
  }


And assuming the flag needs to move, best thing to do would be to create a DB NPC for the flag, then add something like this in the "removeWeapon" case in your weapon

PHP Code:

BlueFlag.trigger("dropFlag"player); 

then in the DB NPC do something like this

PHP Code:

function onCreated() {
  
this.setshape(1,32,32);
  
this.blueowner 2;
  
this.dir 1;
  
this.setcharani("sch_ctfblueidle",null);
}
function 
onActionDropFlag(pl) {
  if (
pl.client.blueowner == 1) {
    
this.blueowner 2;
    
this.dir 1;
    
pl.client.blueowner 2;
    
this.show();
  }



Schetti 04-09-2009 06:33 PM

first at all, thanks for helping


Weapon is called -System/Ctfblue // yea too lazy to change
The DBNpc is called BlueFlag

PHP Code:

BlueFlag.trigger("dropFlag"player.accountpl.client.blueowner); 

this doesnt work I think

and should I post full DB script amd weap?

cbk1994 04-09-2009 11:17 PM

Quote:

Originally Posted by Schetti (Post 1482557)
and should I post full DB script amd weap?

Yes, please.

Also add an 'echo' in the serverside part to see if it is even receiving the trigger.

salesman 04-10-2009 04:26 AM

Quote:

Originally Posted by Schetti (Post 1482557)
PHP Code:

BlueFlag.trigger("dropFlag"player.accountpl.client.blueowner); 


Would be calling the function "ondropFlag()" I believe

Schetti 04-10-2009 08:44 AM

The Drop Flag doesnt work, means theres no echo. Like before I said, the Drop Flag trigger of the Weap comes first and disabled the DNPC one. Also if I said Drop Flag without having the Weapon it echos.
rest works fine

Weaponname: -BlueFlag
DBNPCname: BlueFlag

Weapon:
PHP Code:

function onActionServerSide(cmd) { 
  switch (
cmd) { 
    case 
"removeWeapon": {
    
temp.pl findplayerbycommunityname(params[1]);
      
pl.removeWeapon("-BlueFlag");
      break; 
    } 
  } 


//#CLIENTSIDE
function onCreated() {
    
replaceani("walk""sch_ctfbwalk"); 
    
replaceani("idle""sch_ctfbidle"); 
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
  
client.bflag "got";
  
settimer(.05);
}

function 
onPlayerChats() { 
  if (
player.chat == "drop flag") { 
    
replaceani("walk""walk"); 
    
replaceani("idle""idle"); 
    
setani("idle"null); 
    
triggerserver("gui"name"removeWeapon"player.account); 
  } 
}  

function 
onTimeout() {
if (
client.bflag == "got") {
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
    
settimer(.05);

 }



DBNPC:
PHP Code:

function onActionDropFlag() { 
echo (
"Do you?"); //No it doesnt
     
temp.pl findplayerbycommunityname(params[1]);
  if (
client.blueowner == "1") { 
  echo (
"do you now?"); //also not
    
this.blueowner 2
    
this.dir 1
    
pl.client.blueowner 2
    
this.level ctf.gmap;
    
this.94.5;
    
this.26;  
    
this.blockagain();
    
this.show();
  } 
}
function 
onActionMoveFlag() { 
   if (
player.guild == "Red Team") {
    
player.addWeapon("-BlueFlag");
    
this.blueowner 1;
    
player.client.blueowner 1;
    
this.hide();
 }
}
function 
onCreated() { 
  
this.setshape(1,32,32); 
  
this.blueowner 2
  
this.dir 1
  
this.setcharani("sch_ctfblueidle",null); 
    
this.blockagain();
    
this.show();


//#CLIENTSIDE
function onPlayerTouchsme() {
triggeraction(this.xthis.y"moveFlag"player.account);
}

function 
onPlayerChats() {
if (
player.chat == "Drop Flag") { 
 
triggeraction(this.xthis.y"dropFlag"player.account);  
 }





I would need to find a way to trigger the DBNPC dropFlag with a command in the weapon, so I wouldnt have to check the client.bluowner stuff. Just because only the guy with the weap would be able to trigger that.
Now simply:
I need a way to use a triggeraction(//bla); in a weapon wich would trigger an action in an DBNPC

cbk1994 04-11-2009 05:02 AM

triggerserver("npc", "NameOfNPC", "dropFlag") should do what you want.

Schetti 04-11-2009 07:51 AM

Still doesnt trigger, Imma go post my script again, I modifyed a bit before.
I might should try easier stuff :confused::confused::confused:
NPC(Name: BlueFlag)
PHP Code:

function onActionDropFlag() { 
  echo (
"Flag got dropped");  //never comes :(
    
this.blueowner 2
    
this.dir 1
    
this.level ctf.gmap;
    
this.94.5;
    
this.26;  
    
this.blockagain();
    
this.show();
}
function 
onActionMoveFlag() { 
   if (
player.guild == "Red Team") {
    
player.addWeapon("-BlueFlag");
    
this.blueowner 1;
    
this.hide();
 }
}
function 
onCreated() { 
  
this.setshape(1,32,32); 
  
this.blueowner 2
  
this.dir 1
  
this.setcharani("sch_ctfblueidle",null); 
    
this.blockagain();
    
this.show();


//#CLIENTSIDE
function onPlayerTouchsme() {
triggeraction(this.xthis.y"moveFlag"player.account);



Weapon(Name: -BlueFlag)
PHP Code:

function onActionServerSide(cmd) { 
  switch (
cmd) { 
    case 
"removeWeapon": {
    
temp.pl findplayerbycommunityname(params[1]);
      
pl.removeWeapon("-BlueFlag");
      break; 
    } 
  } 


//#CLIENTSIDE
function onCreated() {
    
replaceani("walk""sch_ctfbwalk"); 
    
replaceani("idle""sch_ctfbidle"); 
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
  
client.bflag "got";
  
settimer(.05);
}

function 
onPlayerChats() { 
  if (
player.chat == "drop flag") {
   
triggerserver("npc""BlueFlag""DropFlag");   
    
replaceani("walk""walk"); 
    
replaceani("idle""idle"); 
    
setani("idle"null); 
    
triggerserver("gui"name"removeWeapon"player.account); 
  } 
}  

function 
onTimeout() {
if (
client.bflag == "got") {
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
    
settimer(.05);
 }



Tigairius 04-11-2009 08:40 AM

PHP Code:

function onActionDropFlag() { 
  echo(
"Flag got dropped");  //never comes :( -- don't put space in between echo and (
    
this.blueowner 2
    
this.dir 1
    
client.blueowner 2
    
this.level "ctf.gmap"// use quotations around strings
    
this.94.5;
    
this.26;  
    
this.blockagain();
    
this.show();
}
function 
onActionMoveFlag() { 
   if (
player.guild == "Red Team") {
    
player.addWeapon("-BlueFlag"); // I thought it was -System/BlueFlag ?
    
this.blueowner 1;
    
player.client.blueowner 1;
    
this.hide();
 }
}
function 
onCreated() { 
  
this.setshape(1,32,32); 
  
this.blueowner 2
  
this.dir 1
  
this.setcharani("sch_ctfblueidle",null); 
    
this.blockagain();
    
this.show();


//#CLIENTSIDE
function onPlayerTouchsme() {
triggeraction(this.0.5this.0.5"MoveFlag"player.account);


PHP Code:

function onActionServerSide(cmd) { 
  switch (
cmd) { 
    case 
"removeWeapon": {
    
temp.pl findplayerbycommunityname(params[1]);
      
pl.removeWeapon("-BlueFlag");
      break; 
      case 
"DropFlag":
        (
"BlueFlag").trigger("ActionDropFlag");
      break;
    } 
  } 


//#CLIENTSIDE
function onCreated() {
    
replaceani("walk""sch_ctfbwalk"); 
    
replaceani("idle""sch_ctfbidle"); 
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
  
client.bflag "got";
  
settimer(.05);
}

function 
onPlayerChats() { 
  if (
player.chat == "drop flag") {
    
triggerserver("gui"name"DropFlag");   
    
replaceani("walk""walk"); 
    
replaceani("idle""idle"); 
    
setani("idle"null); 
    
triggerserver("gui"name"removeWeapon"player.account); 
  } 
}  

function 
onTimeout() {
if (
client.bflag == "got") {
  
showtext 0,player.x+1.5,player.y-1.5,arial,bc,Blue Flag!;
  
changeimgzoom 0,0.9;
    
settimer(.05);
 }



Schetti 04-11-2009 08:47 AM

WOOT THANKS

PS: ok, youre the teacher

Tigairius 04-11-2009 08:51 AM

Quote:

Originally Posted by Schetti (Post 1482918)
WOOT THANKS

PS: ok, youre the teacher

:) By the way, you can move that playertouchsme function part to serverside in your NPC, and get rid of the clientside part all together by doing:

PHP Code:

function onPlayerTouchsme() {
  
this.trigger("ActionMoveFlag"player.account);


instead of:

PHP Code:

//#CLIENTSIDE
function onPlayerTouchsme() {
triggeraction(this.0.5this.0.5"MoveFlag"player.account);



Schetti 04-11-2009 03:37 PM

is there a way to get a trigger to client?
for example, this wouldn't replace the animations, because its clientside:
PHP Code:

function onPlayerLogout() {
    
replaceani("walk""walk"); 
    
replaceani("idle""idle"); 
    
setani("idle"null); 
 (
"BlueFlag").trigger("ActionReturnFlag"player.account);
removeWeapon("-BlueFlag");



[email protected] 04-11-2009 03:51 PM

Quote:

Originally Posted by Schetti (Post 1482968)
is there a way to get a trigger to client?
for example, this wouldn't replace the animations, because its clientside:
PHP Code:

function onPlayerLogout() {
    
replaceani("walk""walk"); 
    
replaceani("idle""idle"); 
    
setani("idle"null); 
 (
"BlueFlag").trigger("ActionReturnFlag"player.account);
removeWeapon("-BlueFlag");




Instead of doing it when they logout, do it for when they log in...?

Schetti 04-11-2009 03:53 PM

Quote:

Originally Posted by [email protected] (Post 1482969)
Instead of doing it when they logout, do it for when they log in...?

good idea, but isnt that serverside too?

cbk1994 04-11-2009 05:14 PM

Quote:

Originally Posted by Schetti (Post 1482970)
good idea, but isnt that serverside too?

Animations are replaced by default when the player logs in.

The trigger (for the blue flag) will work fine when they logout.

And just remove the weapon when they log in.

PHP Code:

function onPlayerLogout(pl) {
  if (
pl.account == BlueFlag.owner) {
    
BlueFlag.trigger("DropFlag");
  }


something like that will accomplish the flag dropping.


All times are GMT +2. The time now is 01:21 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.