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 01-05-2011, 03:34 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
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);
}
}
Reply With Quote
  #2  
Old 01-05-2011, 03:36 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
grab and idle it wont work....
Reply With Quote
  #3  
Old 01-05-2011, 03:47 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
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.
__________________
Quote:

Last edited by fowlplay4; 01-05-2011 at 03:59 AM..
Reply With Quote
  #4  
Old 01-05-2011, 03:52 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
but how i fix that....
Reply With Quote
  #5  
Old 01-05-2011, 03:58 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
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);
}

Reply With Quote
  #6  
Old 01-05-2011, 04:03 AM
Twaina Twaina is offline
Registered User
Join Date: Dec 2010
Posts: 59
Twaina has a little shameless behaviour in the past
Thanks
Reply With Quote
  #7  
Old 01-05-2011, 05:27 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
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
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 01:47 AM.


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