Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-07-2012, 11:39 AM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Getting back into GS2

Well it has been like 2 years since I have touched Gscript and I am wanting to get back into it, so I started to make a lucky grab event script after reading a few guides on the internet, but I have found nothing about an event of when a player grabs a block... Here is what I have so far and please don't just give me the code, only hints Also I have no way of testing this because there is never any admins on Testbed

For the npc in the level I thought it would be best to create a class and let the npcs join that class.

Graal Script Code:
function onCreated()
{
    
this.join("luckyGrabBlock");

Next I worked on the class, I am no sure about the file naming either

Graal Script Code:
function onCreated()
{
    
setimg("block.png");
}

//Not sure about the function so I tried this

function onPlayertouchsme()
{
    if(
player.gani == "grab.gani"//Not the right way to check gani?
    
{
        var 
theNumber random(0,1); //Not sure this works
        
if(theNumber == 0)
        {
            
player.setlevel2("level.nw",  3030); //What should I use before setlevel2
        
}
    }
}

//This is serverside to prevent hackers... It might cause a problem though... Not sure
//Also remember I have no way of testing this x.x 
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #2  
Old 10-07-2012, 03:01 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
I could be really wrong, it's been a while, but does removing '.gani' help?

I could also again be way off, things may have changed, but you could try prefixing the variable 'theNumber' with 'temp.' rather than 'var'? I remember that being the way to initialise variables within the scope of a function.

A good, basic debugging tool is using 'echo' to check whether certain parts of your code are being executed. It's also useful for dumping state. I'm sure I remember there being a proper debugger written in GS some where too that may be useful.

One thing you could try is:

Graal Script Code:
echo player.gani
To see what the value currently is. It may also be 'player.ani'.
Reply With Quote
  #3  
Old 10-07-2012, 04:48 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
It's actually player.ani, not player.gani. Also, said variable points to an object. player.ani.name is the actual name of the current gani.

That stuff aside, your grab check will probably not work like this, since onPlayerTouchsMe() is fired before you have the chance to actually grab the object.
__________________
Reply With Quote
  #4  
Old 10-08-2012, 10:39 AM
Vatec Vatec is offline
Lurking
Join Date: Oct 2012
Posts: 27
Vatec is on a distinguished road
Quote:
Originally Posted by Crow View Post
It's actually player.ani, not player.gani. Also, said variable points to an object. player.ani.name is the actual name of the current gani.

That stuff aside, your grab check will probably not work like this, since onPlayerTouchsMe() is fired before you have the chance to actually grab the object.
Is there an inbuilt grab check?
__________________


Quote:
Originally Posted by GULTHEX View Post
so i think the problem is that onactionclientside isint a real function
Reply With Quote
  #5  
Old 10-08-2012, 03:54 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 Vatec View Post
Is there an inbuilt grab check?
No, you will need to trigger it (either with a simple grab trigger outside of a movement system, or in your movement system).
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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:05 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.