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 06-08-2003, 03:42 PM
Deus_Sephiroth Deus_Sephiroth is offline
Registered User
Join Date: Jun 2003
Posts: 12
Deus_Sephiroth is on a distinguished road
Send a message via AIM to Deus_Sephiroth
Script Help

This is my first post so if the code didnt show up right thats why lol.

The script editor is givin me the Expected Format Error with this code and I cant see why.

NPC Code:
for{i=0; i<EffectTime; i++){
setsword #1,2;
}



I also tried it the way it shows in npcscripting.doc

NPC Code:
for{i=0; i<EffectTime; i++) setsword #1,2;



That is the way the editor says it should be done but it still wont except it.

Thanks for your help
Reply With Quote
  #2  
Old 06-08-2003, 04:16 PM
Deus_Sephiroth Deus_Sephiroth is offline
Registered User
Join Date: Jun 2003
Posts: 12
Deus_Sephiroth is on a distinguished road
Send a message via AIM to Deus_Sephiroth
Also for some reason my beer will not display until I exit and re enter the room. It should work here is the bartender part of the code.

NPC Code:

//Yellow Beer
//If the player says Buy Regular Beer and his rupees are greater
//than or equal to 5 then subtract 5 of his rupees and set
//the ybeershow flag
if (playersays(Buy Regular Beer) && playerrupees >=5){
playerrupees -5;
set ybeershow;
}

//If the player says Buy Regular Beer and his rupees are less
//than 5 then display the message Sorry You Dont Have
//Enough Rupees, then wait 3 seconds and clear the message.

if (playersays(Buy Regular Beer) && playerrupees <5){
message Sorry You Dont Have Enough Rupees;
sleep 3.0;
message ;
}



Now here is the actual Beer npc code
NPC Code:

//If ybeershow is true then show the beer npc
if (ybeershow){
show;
}
//If ybeershow is not true then hidethe beer npc
if (!ybeershow){
hide;
}
//If the player touches the beer replenish 5 hearts and then unset
// the ybeershow flag
if (playertouchsme) {
hurt -10;
unset ybeershow;
}


If there is somthing wrong please tell me so i can figure out what i did and not do it again lol
Reply With Quote
  #3  
Old 06-08-2003, 04:27 PM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
Incorrect:
NPC Code:

for{i=0; i<EffectTime; i++)


Correct:
NPC Code:

for (i=0; i<EffectTime; i++)


Spot the difference?

Also, use if (playerchats && strequals(#c,text)) rarther than if (playersays())

There is a much more efficient method of doing that beer thing. Try using else, and you don't really need to set flags.
__________________
Former Global Scripting Team Member


Reply With Quote
  #4  
Old 06-08-2003, 04:29 PM
Deus_Sephiroth Deus_Sephiroth is offline
Registered User
Join Date: Jun 2003
Posts: 12
Deus_Sephiroth is on a distinguished road
Send a message via AIM to Deus_Sephiroth
ok ill have to try that, but the space in the for code makes no difference, i just tried it. oops i see i have a { instead of (. Also I tried your suggestion for the playersays, it doesnt change the fact that the stupid beer still wont appear until i exit and come back, but ill use that instead anyway, since its more effecient.
Reply With Quote
  #5  
Old 06-08-2003, 05:46 PM
Deus_Sephiroth Deus_Sephiroth is offline
Registered User
Join Date: Jun 2003
Posts: 12
Deus_Sephiroth is on a distinguished road
Send a message via AIM to Deus_Sephiroth
well after countless tries i realised that its easier to make a text file with the script and call an npc, it saves many lines of code and reduces errors greatly.

Also if anyone would have an idea how to set a players sword power to 2 or more for 20 seconds and have it revert back to what it was lemme know.

Last edited by Deus_Sephiroth; 06-08-2003 at 05:56 PM..
Reply With Quote
  #6  
Old 06-08-2003, 06:44 PM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
NPC Code:

if (playerchats&&strequals(#c,buy regular beer)) {
if (playerrupees >=5){
playerrupees -=5;
set ybeershow;
} else if (playerrupees<5) {
say2 You need more money.
}



NPC Code:

if (ybeershow){
show;
} else {
hide;
}
if (playertouchsme) {
hurt -10;
unset ybeershow;
}



Thats one way, if i was you i'd rather use putnpc.

NPC Code:

if (playerchats&&strequals(#c,buy regular beer)) {
if (playerrupees >=5){
playerrupees -=5;
putnpc2 x,y, { //dont remember if this line is correct.
if (playertouchsme) {
playerhearts+=5;
hurt 0;
}
}
else if (playerrupees<5) {
say2 You need more money.
}
}


__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #7  
Old 06-08-2003, 07:27 PM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
.. I do this alot, thats why my post gets deleted but thats a full script =o.

Quote:
well after countless tries i realised that its easier to make a text file with the script and call an npc, it saves many lines of code and reduces errors greatly
You don't need to use flags! It can be done in a few lines. Instead of putting the flag in just simply put 'show'. Then use the if (playertouchsme) etc.....
__________________
Former Global Scripting Team Member


Reply With Quote
  #8  
Old 06-08-2003, 08:14 PM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
putnpc2-ing would be superior.

Also, I'd suggest nesting the money check inside the if playerchats and asks for beer, then you could use an 'else' instead of rechecking if the playerchats and doesn't have the money. Tyrial did this in his example, but did not explain what or why he did. The same goes for your 'playerrupees -5' to the correct way to do that: 'playerrupees -=5'.

And Tyrial...for goodness' sake, please use proper formatting, especially when trying to help someone new. And, explain what you're doing so they can learn. Just posting a way to do it (be it the correct way or not) without an explanation doesn't teach the person anything.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #9  
Old 06-09-2003, 12:53 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
Quote:
Originally posted by Tseng
putnpc2-ing would be superior.

Also, I'd suggest nesting the money check inside the if playerchats and asks for beer, then you could use an 'else' instead of rechecking if the playerchats and doesn't have the money. Tyrial did this in his example, but did not explain what or why he did. The same goes for your 'playerrupees -5' to the correct way to do that: 'playerrupees -=5'.

And Tyrial...for goodness' sake, please use proper formatting, especially when trying to help someone new. And, explain what you're doing so they can learn. Just posting a way to do it (be it the correct way or not) without an explanation doesn't teach the person anything.
Tseng, i wrote that in the sky.. i didn't open graal or anything, and he didn't say "teach me how to fix this" he asked for help, and i helped him.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #10  
Old 06-09-2003, 01:04 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by mhermher
NPC Code:

if (playerchats&&strequals(#c,buy regular beer)) {
if (playerrupees >=5){
playerrupees -=5;
set ybeershow;
} else if (playerrupees<5) { < This "else if()" is not needed,just else would work fine...
say2 You need more money. < You forget to put a ";" here
}


This would be better..=)

NPC Code:

if (playerchats&&strequals(#c,buy regular beer)){
if (playerrupees >=5){
playerrupees -=5; set ybeershow; < I dont think this set is needed..but x.x'
} else
say2 You need at least 5 gralats;
}

__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #11  
Old 06-09-2003, 01:09 AM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by mhermher


Tseng, i wrote that in the sky.. i didn't open graal or anything, and he didn't say "teach me how to fix this" he asked for help, and i helped him.
That doesn't help him though.

The old "Give a man a fish / teach a man to fish" saying comes to mind.

The best way to help someone is to is not just to do the work for them, but to explain what you changed and why you changed it, so they can understand what happened, and learn from it.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #12  
Old 06-09-2003, 07:42 AM
Deus_Sephiroth Deus_Sephiroth is offline
Registered User
Join Date: Jun 2003
Posts: 12
Deus_Sephiroth is on a distinguished road
Send a message via AIM to Deus_Sephiroth
Its cool guys, i appreciate all your help in all the forms, here is what I did to correct it.

NPC Code:

//Bartender Code
//Yellow Beer
if (playersays(Buy Regular Beer)&& playerrupees>=5){
playerrupees -=5;
putnpc yellowbeer.gif, yellowbeernpc.txt,13,21;
}

if (playersays(Buy Regular Beer)&& playerrupees<5){
message Sorry, you dont have enough rupees;
sleep 3;
message ;
}

//Yellowbeernpc.txt
// NPC made by Sephiroth *leader* {Brotherhood of Kazad0m}
if (playertouchsme) {
hurt -6;
hide;
}



which works fine, I just need to figure out how to change things like the players sword power for say 60 seconds after drinkin the beer. Hopefully ill think of somthing.
Reply With Quote
  #13  
Old 06-09-2003, 09:13 AM
Falados Falados is offline
Cucumber NPC
Falados's Avatar
Join Date: Jan 2003
Posts: 141
Falados is on a distinguished road
Send a message via ICQ to Falados Send a message via AIM to Falados
You forgot events, setting a flag does not trigger an event to run the script, you probably should either do the putnpc thing that was suggested earlier, or call the npc for an update via triggeraction or callnpc.
__________________

subliminal message: 1+1=3
Reply With Quote
  #14  
Old 06-09-2003, 04:29 PM
Tseng Tseng is offline
Sublime
Tseng's Avatar
Join Date: Jan 2003
Location: California
Posts: 0
Tseng is on a distinguished road
Quote:
Originally posted by Kaimetsu
playersays: BAD
playerchat&strequals: GOOD
I wish Stefan had not reenabled playersays. It would have forced people to use the proper method.
__________________
Funny Things:
Quote:
Originally posted by Stefan
I didn't ban you, I only played a little bit with my RC.
-----
Reply With Quote
  #15  
Old 06-09-2003, 05:58 PM
Neoreno Neoreno is offline
Cerebrate
Neoreno's Avatar
Join Date: Aug 2001
Location: England
Posts: 1,663
Neoreno is on a distinguished road
Send a message via AIM to Neoreno
Quote:
newfeatures2003-v3.txt
Things that are not supported anymore:
- setbackpal
- playersays()
__________________

Quote:
Exitus Acta Probat: The Outcome Justifies the Deed.
Reply With Quote
  #16  
Old 06-09-2003, 11:25 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
*shouts for joy*
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #17  
Old 06-10-2003, 02:18 AM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
Quote:
Originally posted by Tseng
I wish Stefan had not reenabled playersays. It would have forced people to use the proper method.
We are always telling people to dont use playersays(),and they use..^_^
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #18  
Old 06-18-2003, 03:27 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Quote:
Originally posted by Deus_Sephiroth
well after countless tries i realised that its easier to make a text file with the script and call an npc, it saves many lines of code and reduces errors greatly.

Also if anyone would have an idea how to set a players sword power to 2 or more for 20 seconds and have it revert back to what it was lemme know.
Erm, people, i hope you know we aren't allowed to give full scripts... For the sword thing, well, first of all you need to save the original sword power of the player.

Quote:
if (playerenters){
this.swordsave=players[index].swordpower;
players[index].swordpower=2;
timeout = 20;
}
afterwards, you need to set back the original sword power.

Quote:
if (timeout){
players[index].swordpower=#v(this.swordsave);
}
So, you need to save the swordpower, have a timeout and then set the swordpower back to what it was.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
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 04:22 AM.


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