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 09-05-2011, 05:21 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Item Spawn

I am trying to make an item spawner. I am making it create an NPC at my mouses x and y, and when it is touched, it adds the weapon to the player and destroys itself. However, I can't get it to work. When I fire the weapon, it puts the NPC with the image bcalarmclock.png, and it changes the chat to the players chat. That is all done on created. In the class, this is what I have...
PHP Code:
//Works
function onCreated() {
  
setimg("block.png");
  
this.chat text;
}
//Doesn't work
function onPlayerTouchsMe() {
  
addweapon(this.chat);
  
player.chat "Green";
  
destroy();

Any suggestions?
I think it is something to do with the PlayerTouchsMe
__________________
Reply With Quote
  #2  
Old 09-05-2011, 05:49 PM
furry_mougle furry_mougle is offline
big heart
furry_mougle's Avatar
Join Date: Aug 2011
Posts: 42
furry_mougle is an unknown quantity at this point
How would the class know you're touching the NPC in the first place?
__________________
Quote:
Originally Posted by ffcmike View Post
But make sure to change beer.png to Orange Juice.
pay bills to play graal
Reply With Quote
  #3  
Old 09-05-2011, 05:52 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Nvm now I fixed it. Thanks anyway.
__________________
Reply With Quote
  #4  
Old 09-05-2011, 05:52 PM
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
Try giving it a shape:

PHP Code:
function onCreated() {
  
this.image "block.png";
  
setshape(1,32,32);

__________________
Quote:
Reply With Quote
  #5  
Old 09-05-2011, 06:07 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
When you touch it, it destroys on your screen, but not on other players. X_X

Class
PHP Code:
function onCreated() {
  
setimg("block.png");
  
this.chat text;
  
setshape(1,32,32);
}
//#CLIENTSIDE
function onPlayerTouchsMe() {
  
addweapon(this.chat);
  
destroy();

Weapon
PHP Code:
function onActionServerSide() {
  if (
params[0] == "spawn") {
    
temp.npc putnpc2(params[1],params[2], "join(\"emera_spawn\");");
    
text params[3];
  }
}
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat.starts("/spawn ")) {
    
triggerserver("gui",this.name,"spawn",mousex,mousey,player.chat.substring(7));
  }

__________________
Reply With Quote
  #6  
Old 09-05-2011, 06:12 PM
gaben gaben is offline
uhh no
gaben's Avatar
Join Date: Aug 2011
Posts: 47
gaben is an unknown quantity at this point
http://gscript.graal.net/onPlayerTouchsMe

Just execute destroy() serverside? wat
__________________
Quote:
Originally Posted by iBeatz View Post
Who came up with this Cheat Engine? The more I read about, the more ingenious the whole thing sounds.
Quote:
Originally Posted by Unixmad
This forums is going worst each day.
Quote:
Originally Posted by ff7chocoboknight View Post
You sure are taking your time leaving, furry.
Quote:
Originally Posted by [email protected] View Post
are u old enough 2 even play Graal little girl???
Reply With Quote
  #7  
Old 09-05-2011, 06:14 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by gaben View Post
http://gscript.graal.net/onPlayerTouchsMe

Just execute destroy() serverside? wat
Whenever I try to execute playertouchsme serverside it doesn't work though.
__________________
Reply With Quote
  #8  
Old 09-05-2011, 06:15 PM
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
player.addweapon() is a server-side function, and destroying it on the client-side will only destroying it on your client (screen).

Removing //#CLIENTSIDE should make it work the way you want.
__________________
Quote:
Reply With Quote
  #9  
Old 09-05-2011, 06:16 PM
gaben gaben is offline
uhh no
gaben's Avatar
Join Date: Aug 2011
Posts: 47
gaben is an unknown quantity at this point
Quote:
Originally Posted by Emera View Post
Whenever I try to execute playertouchsme serverside it doesn't work though.
playertouchsme is clientside? also what fp4 said sounds just about right anyway
__________________
Quote:
Originally Posted by iBeatz View Post
Who came up with this Cheat Engine? The more I read about, the more ingenious the whole thing sounds.
Quote:
Originally Posted by Unixmad
This forums is going worst each day.
Quote:
Originally Posted by ff7chocoboknight View Post
You sure are taking your time leaving, furry.
Quote:
Originally Posted by [email protected] View Post
are u old enough 2 even play Graal little girl???

Last edited by gaben; 09-05-2011 at 06:26 PM..
Reply With Quote
  #10  
Old 09-05-2011, 06:17 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
player.addweapon() is a server-side function, and destroying it on the client-side will only destroying it on your client (screen).

Removing //#CLIENTSIDE should make it work the way you want.
Then the block doesn't even destroy. It doesn't work if I remove the clientside above onPlayerTouchsMe
__________________
Reply With Quote
  #11  
Old 09-05-2011, 10:01 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
function onPlayerTouchsme() will work serverside in everything but a weapon, but for what you are describing you should be using a class anyway.
Reply With Quote
  #12  
Old 09-05-2011, 10: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 Emera View Post
Then the block doesn't even destroy. It doesn't work if I remove the clientside above onPlayerTouchsMe
Have you tried putting echoes in relevant locations to try to find the problem?
__________________
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:35 PM.


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