Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help:Jetpack (https://forums.graalonline.com/forums/showthread.php?t=134261553)

Twaina 01-05-2011 03:34 AM

Help:Jetpack
 
Jetpack
Hey i made a script
and when i am on the ground my gani is ever idle help...
Quote:

//#CLIENTSIDE
function onCreated() {
this.jetpack = 0;
}

function onKeyPressed(code,key)
{
if( key == "b" )
{
if (this.jetpack = 0) {
if(player.z >= 10)
{
this.jetpack = 1;
player.chat="Stop!";
}
else
{
settimer(0.1);
player.z+= 0.2;
}
}
}
else if( key == "o" )
{
this.jetpack = 0;
player.z = 0;

}
}
function onTimeOut()
{
if(player.z > 0)
{
this.jetpack = 1;
replaceAni("walk", "grab");
this.speed = 0.05;
player.z-= 0.05;
for ( temp.i = 0; i < 4; i ++ )
{
if ( keydown(i) )
{ // if the key for that direction is pressed
player.x += vecx(i) * this.speed;
player.y += vecy(i) * this.speed;
}
settimer(0.05);
}
}
else
{
this.jetpack = 0;
replaceAni("grab", "walk");
settimer(0);
}
}

Twaina 01-05-2011 03:36 AM

grab and idle it wont work....

fowlplay4 01-05-2011 03:47 AM

Use PHP tags instead of QUOTE tags.

It's a logical mess.

Here.. have a scripting puzzle.

Here's the bare-bones for a weapon you turn on and off, and one of the ones you can check for keys being held down.

PHP Code:

//#CLIENTSIDE

function onWeaponFired() {
  
// Check if weapon is on
  
if (this.on) {
    
// Notify player of change
    
player.chat "Weapon is now OFF!";
    
// Set on flag to false/off
    
this.on false;
  } else {
    
// Notify player of change
    
player.chat "Weapon is now ON!";
    
// Set on flag to true/on
    
this.on true;
    
// Start Looping
    
setTimer(0.05);
  }
}

// When the time runs out in setTimer, it causes a timeout.
// Which triggers the onTimeout function/event.
function onTimeout() {
  
// Check for Keys being Held Down
  
if (keydown(6)) {
    
player.chat "IM PRESSING GRAB NOW LOL";
  }
  else if (
keydown(5)) {
    
player.chat "IM PRESSING ATTACK NOW LMAO";
  }
  
// Continue Looping / Timing out while On
  
if (this.onsetTimer(0.05);


You can control the z-axis by calling these functions:

PHP Code:

//#CLIENTSIDE

function raise_z() {
  
// Raise Z
  
player.+= 0.05;
  
// Check if over Maximum Height
  
if (player.10player.10;
}

function 
lower_z() {
  
// Lower Z
  
player.-= 0.05;
  
// Check if under Minimum Height
  
if (player.0player.0;
}

function 
reset_z() {
  
// Resets Player Z value
  
player.0;


Make a Jetpack out of it.

Twaina 01-05-2011 03:52 AM

but how i fix that....

Twaina 01-05-2011 03:58 AM

Jetpack
So i made this script but its fail when i am on the ground
its ever grab and idle
Quote:

PHP Code:

//#CLIENTSIDE
function onCreated() {
this.jetpack 0;
}

function 
onKeyPressed(code,key)
{
if( 
key == "b" )

if (
this.jetpack 0) {
if(
player.>= 10)

this.jetpack 1;
player.chat="Stop!";
}
else 
{
settimer(0.1);
player.z+= 0.2;



else if( 
key == "o" )
{
this.jetpack 0;
player.0;

}
}
function 
onTimeOut()
{
if(
player.0)
{
this.jetpack 1;
replaceAni("walk""grab");
this.speed 0.05;
player.z-= 0.05;
for ( 
temp.04++ )

if ( 
keydown(i) )
// if the key for that direction is pressed
player.+= vecx(i) * this.speed;
player.+= vecy(i) * this.speed;
}
settimer(0.05);

}
else
{
this.jetpack 0;
replaceAni("grab""walk");
settimer(0);
}




Twaina 01-05-2011 04:03 AM

Thanks

Tigairius 01-05-2011 05:27 AM

Hi, please make sure you read the NPC Scripting subforum rules before posting: http://forums.graalonline.com/forums...hp?t=134261188

You may want to review: Rule 1, Guideline 2, Guideline 6.


All times are GMT +2. The time now is 04:47 AM.

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