Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Help Meh (https://forums.graalonline.com/forums/showthread.php?t=87070)

Mattehy 07-25-2009 11:43 PM

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 ;(

papajchris 07-25-2009 11:54 PM

your gonna be asked to put it in phps

Mattehy 07-26-2009 12:03 AM

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

fowlplay4 07-26-2009 12:21 AM

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 :)

Mattehy 07-26-2009 12:34 AM

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(); 

???


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

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