Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-25-2009, 11:43 PM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
Question Help Meh

NPC Code:
//#CLIENTSIDE
function onKeyPressed(num1, key, num2)
{
if (key == "x")
{
ar = {player.x + (vecx(player.dir) * 2) + 1.1,
player.y + (vecy(player.dir) * 2) + 1.1};
triggeraction(ar[0], ar[1], "Sticked");
triggeraction(ar[0], ar[1], "DestroyBlock", 10);
setani("haven_staffstick",NULL);
freezeplayer(0.4);
sleep(0.4);
}
}


thats my current staffstick script how would i make it to send people to the osl? please help ;(
Reply With Quote
  #2  
Old 07-25-2009, 11:54 PM
papajchris papajchris is offline
Zeus Condero
papajchris's Avatar
Join Date: Jan 2006
Location: Michigan
Posts: 1,600
papajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to beholdpapajchris is a splendid one to behold
your gonna be asked to put it in phps
Reply With Quote
  #3  
Old 07-26-2009, 12:03 AM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
PHP Code:
//#CLIENTSIDE
function onKeyPressed(num1keynum2)
{
if (
key == "x")
{
ar = {player.+ (vecx(player.dir) * 2) + 1.1,
player.+ (vecy(player.dir) * 2) + 1.1};
triggeraction(ar[0], ar[1], "Sticked");
triggeraction(ar[0], ar[1], "DestroyBlock"10);
setani("haven_staffstick",NULL);
freezeplayer(0.4);
sleep(0.4);
}

sorry im new 2 forums :P
Reply With Quote
  #4  
Old 07-26-2009, 12:21 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Make sure you indent/style your scripts properly, there's even a style command on RC for that but when you get the hang of it, you'll style your code automatically as you type.

PHP Code:
//#CLIENTSIDE
function onKeyPressed(num1keynum2)
{
  if (
key == "x")
  {
    
ar = {player.+ (vecx(player.dir) * 2) + 1.1,
          
player.+ (vecy(player.dir) * 2) + 1.1};
    
triggeraction(ar[0], ar[1], "Sticked");
    
setani("haven_staffstick",NULL);
    
freezeplayer(0.4);
    
sleep(0.4);
  }

Now before you start getting into bad habits, reduce your usage of triggers to the absolute minimal. As you can see I removed your destroyblock trigger.

For hitting NPCs with it:

PHP Code:
function onActionSticked() {
  echo(
"was hit by staff stick!");

But now that works well for NPCs you need to use a weapon npc, and add it to the player, then use a script like this.

PHP Code:
//#CLIENTSIDE
function onActionSticked() {
  
player.chat "was hit by the staff stick";

But that won't warp the player to your osl, so you'll need to tell the client to do some server interaction. Here's an example of a weapon npc that would warp the player to OSL.

PHP Code:
function onActionServerSide() {
  if (
params[0] == "warptoOSL") {
    
// Warps Player to OSL
    
player.setlevel2("onlinestartlocal.nw"3030);
  }
}
//#CLIENTSIDE
function onCreated() {
  
warptoOSL();
}
function 
warptoOSL() {
  
// Sends Trigger to Server
  
triggerserver("gui"name"warptoOSL");

There I have presented the pieces to you, now you put it together
__________________
Quote:
Reply With Quote
  #5  
Old 07-26-2009, 12:34 AM
Mattehy Mattehy is offline
Developer
Mattehy's Avatar
Join Date: Jul 2009
Posts: 58
Mattehy is on a distinguished road
Question

So it would be :
PHP Code:
function onActionServerSide() { 
  if (
params[0] == "Warp2OSL") { 
    
player.setlevel2("onlinestartlocal.nw"3030); 
  } 

//#CLIENTSIDE 
function onKeyPressed(num1keynum2

  if (
key == "x"
  { 
    
ar = {player.+ (vecx(player.dir) * 2) + 1.1
          
player.+ (vecy(player.dir) * 2) + 1.1}; 
    
triggeraction(ar[0], ar[1], "Warp2OSL"); 
    
setani("haven_staffstick",NULL); 
    
freezeplayer(0.4); 
    
sleep(0.4); 
  } 

And the staffblock would be:
PHP Code:
blah blah blah
function onActionWarp2OSL()
destroy(); 
???
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 08:57 AM.


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