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 05-18-2008, 10:12 PM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Questions about an Inventory

1. For dropping items, how would I drop an item in the Weapon List?
Something like this?
PHP Code:
putnpc2(playerx,playery,findNPC("Weapons/Sword of Heavens"));
Didn't work for me,. 
2. This is what my GUI displays:
PHP Code:
showimg(221,player.weapons[selectedweapon].image,14,85);
changeimgvis(221,7); 
But, when I am using my custom inventory, the image won't change.
It only works when I'm using a default inventory.
This is what I use to select items in my inventory:
PHP Code:
for(temp.i=0;temp.i<player.weapons.size();temp.i++;)
{
  if(
player.weapons[temp.i].name == obj.itemName)
  {
    
player.selectedweapon temp.i;
    return;
  }

Should I just use a custom "clientr.itemselected" variable?
Reply With Quote
  #2  
Old 05-18-2008, 10:16 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
You could use custom if you wanted.

For the question about dropping items, do something like this:

PHP Code:
function onActionServersidecmddxdywep )
{
  switch ( 
cmd )
  {
    case 
"dropWep":
    {
      
temp.putnpc2dxdy"" );
      
temp.i.join"object_droppeditem" );
      
temp.i.wep wep;
    }
  }

and then have a class object_droppeditem
PHP Code:
function onPlayerTouchsMe()
{
  
player.addWeaponthis.wep );
  
destroy();

__________________
Reply With Quote
  #3  
Old 05-18-2008, 10:24 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
PHP Code:
      temp.putnpc2dxdy"" );
      
temp.i.join"object_droppeditem" ); 
why must you do that?

PHP Code:
      with(putnpc2(playero.xplayero.y"object_droppeditem")).wep wep
Reply With Quote
  #4  
Old 05-18-2008, 10:26 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 [email protected] View Post
PHP Code:
      temp.putnpc2dxdy"" );
      
temp.i.join"object_droppeditem" ); 
why must you do that?

PHP Code:
      with(putnpc2(playero.xplayero.y"object_droppeditem")).wep wep
Looks cleaner
__________________
Reply With Quote
  #5  
Old 05-18-2008, 10:33 PM
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
Quote:
Originally Posted by [email protected] View Post

PHP Code:
      with(putnpc2(playero.xplayero.y"object_droppeditem")).wep wep
That wouldn't work, it would have to be "join object_droppeditem"


PHP Code:
      temp.putnpc2dxdy"" );
      
temp.i.join"object_droppeditem" ); 
I disagree that this looks cleaner, but I also don't see why "sidney" questioned your script, since yours would work better than "hers"..
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #6  
Old 05-18-2008, 10:41 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
oh 4fog the 'join'.

how would that version work better? if anything
PHP Code:
putnpc2(x"join item");
i.wep wep
would be better.
Reply With Quote
  #7  
Old 05-18-2008, 11:02 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You can't simply drop an item from an inventory onto the ground.
What you can do, is drop an NPC like you're doing, and enclose a variable with it with the name of the weapon and delete the players item. When the player touches the item, add that weapon via addweapon.
Reply With Quote
  #8  
Old 05-18-2008, 11:10 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
Why use GS1?

putnpc2( dx, dy, "join( \"item\" )" );
__________________
Reply With Quote
  #9  
Old 05-18-2008, 11:31 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by cbk1994 View Post
Why use GS1?

putnpc2( dx, dy, "join( \"item\" )" );
whats with the \ \?
always wonderd why people add them
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #10  
Old 05-18-2008, 11:36 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 Deas_Voice View Post
whats with the \ \?
always wonderd why people add them
Because otherwise the parser will think you are ending the string. Think like this:

PHP Code:
"join( "x" );" 
See how the quotes would have ended that string, and it would want to know what the x was doing outside of quotes? The backslash tells it that the quotes need to be IN the string, instead of ending/starting a string.
__________________
Reply With Quote
  #11  
Old 05-19-2008, 01:08 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
PHP Code:
function onActionServersidecmddxdywep )
{
  switch ( 
cmd )
  {
    case 
"dropWep":
    {
      for(
temp.i=0;temp.i<player.weapons.size();temp.i++;)
      {
        if(
player.weapons[temp.i].name == wep)
        {
          
this.wepID temp.i;
          break;
        }
      }
      
removeweapon(wep);
      
temp.putnpc2dxdy"" );
      
temp.i.join("object_droppeditem");
      
temp.i.wep wep;
      
temp.i.img player.weapons[this.wepID].image;
    }
  }

Why is it giving me the wrong images?
Reply With Quote
  #12  
Old 05-19-2008, 01:17 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Why are you doing all that looping? Send the current weapon in the triggerclient.
Reply With Quote
  #13  
Old 05-19-2008, 01:27 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
If I don't do the looping, can't find the Weapon id needed to change the image. I've tried findWeapon(), so I used the loop instead. Can you tell me why it won't display the correct images..
Reply With Quote
  #14  
Old 05-19-2008, 01:30 AM
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
In the class, perhaps try setimg( this.img)?

Also, you might need to join it AFTER setting this.img and this.wep so that it runs the functions when this.img actually exists.
__________________
Reply With Quote
  #15  
Old 05-19-2008, 01:33 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
You can still do it on the clientside.
PHP Code:
function onActionServersidecmddxdywepwepimg ) {
  switch ( 
cmd ) {
    case 
"dropWep": {
      
removeweapon(wep);
      
temp.putnpc2dxdy"" );
      
temp.i.join("object_droppeditem");
      
temp.i.wep wep;
      
temp.i.setimg(wepimg);
    }
  }
}
//#CLIENTSIDE
//stuff
temp.wep="Bomb";
temp.wepid=-1;
for (
temp.i=0;i<player.weapons.size();i++) {
  if (
wep == player.weapons[i].name) {
    
wepid=i;
    break;
  }
}
triggerserver("gui",this.name,"dropWep",dx,dy,wep,player.weapons[wepid].image); 

Last edited by DustyPorViva; 05-19-2008 at 01:47 AM..
Reply With Quote
  #16  
Old 05-19-2008, 01:39 AM
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
PHP Code:
triggerserver("dropWep",dx,dy,wep,player.weapons[wepid].image); 
Do you know something I don't?

I recall

PHP Code:
triggerserver"gui", [...] );
triggerserver"weapon", [...] ); 
__________________
Reply With Quote
  #17  
Old 05-19-2008, 01:41 AM
Stryke Stryke is offline
Scripter
Join Date: Apr 2008
Posts: 157
Stryke is an unknown quantity at this point
Solved. The problem was I was supposed to access the image of the player's weapon on the clientside, and i was trying to access it off the serverside. Thanks guys!

i'll give rep when i can cause ill gave in the last 24 hours
Reply With Quote
  #18  
Old 05-19-2008, 01:46 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by cbk1994 View Post
PHP Code:
triggerserver("dropWep",dx,dy,wep,player.weapons[wepid].image); 
Do you know something I don't?

I recall

PHP Code:
triggerserver"gui", [...] );
triggerserver"weapon", [...] ); 
Oops!

Quote:
Originally Posted by Stryke View Post
Solved. The problem was I was supposed to access the image of the player's weapon on the clientside, and i was trying to access it off the serverside. Thanks guys!
Heh, I'll just point out... if you're having problems like this, debug it. If you ever have a problem, start echoing crap that you suspect is the culprit. In this case, the image isn't setting? Most logical deduction would be that the variable you're assigning the image name to isn't correct. Thus, echo the variable you're using to set the image name. If it IS correct... then come here because something isn't right. If it's null, then you've messed up somewhere else when trying to set it. Go back and think hard and try to figure out what. Debugging is crucial and can most likely make you realize it was a simple problem that you could have caught a lot earlier on your own.

Last edited by Tolnaftate2004; 05-19-2008 at 03:03 AM..
Reply With Quote
  #19  
Old 05-19-2008, 02:54 AM
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 Stryke View Post
Solved. The problem was I was supposed to access the image of the player's weapon on the clientside, and i was trying to access it off the serverside. Thanks guys!

i'll give rep when i can cause ill gave in the last 24 hours
You won't be able to give it to me anyway, as you already did.

And, for the record, it was a gray gem

But yes, it is a good idea to give rep to the people who help you; you in return will receive good rep, for the most part.

Be sure to leave your name

And Dusty, you beast! Double posting, tssk tssk.
__________________
Reply With Quote
  #20  
Old 05-19-2008, 06:18 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Don't put the join inside the putnpc's script please. Just join it upon creation and that's it. It's unhealthy and bad tact to put commands and function calls outside of function definitions.
__________________
Do it with a DON!
Reply With Quote
  #21  
Old 05-19-2008, 08:28 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
do a check serverside, sending the weapon info clientside will make it insecure.
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 10:40 AM.


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