Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-05-2009, 08:01 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
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
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
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #2  
Old 04-05-2009, 03:55 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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();
  }

__________________
Reply With Quote
  #3  
Old 04-09-2009, 06:33 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
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?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #4  
Old 04-09-2009, 11:17 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Schetti View Post
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.
__________________
Reply With Quote
  #5  
Old 04-10-2009, 04:26 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Schetti View Post
PHP Code:
BlueFlag.trigger("dropFlag"player.accountpl.client.blueowner); 
Would be calling the function "ondropFlag()" I believe
Reply With Quote
  #6  
Old 04-10-2009, 08:44 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
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
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein

Last edited by Schetti; 04-10-2009 at 11:36 AM..
Reply With Quote
  #7  
Old 04-11-2009, 05:02 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
triggerserver("npc", "NameOfNPC", "dropFlag") should do what you want.
__________________
Reply With Quote
  #8  
Old 04-11-2009, 07:51 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
Still doesnt trigger, Imma go post my script again, I modifyed a bit before.
I might should try easier stuff
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);
 }

__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein

Last edited by Schetti; 04-11-2009 at 08:41 AM..
Reply With Quote
  #9  
Old 04-11-2009, 08:40 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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);
 }

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #10  
Old 04-11-2009, 08:47 AM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
WOOT THANKS

PS: ok, youre the teacher
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #11  
Old 04-11-2009, 08:51 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Schetti View Post
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);

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #12  
Old 04-11-2009, 03:37 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
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");

__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #13  
Old 04-11-2009, 03:51 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Quote:
Originally Posted by Schetti View Post
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...?
Reply With Quote
  #14  
Old 04-11-2009, 03:53 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
Quote:
Originally Posted by [email protected] View Post
Instead of doing it when they logout, do it for when they log in...?
good idea, but isnt that serverside too?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #15  
Old 04-11-2009, 05:14 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Schetti View Post
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.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:15 AM.


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