Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Script Help (https://forums.graalonline.com/forums/showthread.php?t=45351)

Deus_Sephiroth 06-08-2003 03:42 PM

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

Deus_Sephiroth 06-08-2003 04:16 PM

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

Ningnong 06-08-2003 04:27 PM

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.

Deus_Sephiroth 06-08-2003 04:29 PM

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.

Deus_Sephiroth 06-08-2003 05:46 PM

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.

mhermher 06-08-2003 06:44 PM

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.
}
}



Ningnong 06-08-2003 07:27 PM

.. 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.....

Tseng 06-08-2003 08:14 PM

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.

mhermher 06-09-2003 12:53 AM

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.

osrs 06-09-2003 01:04 AM

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;
}


Tseng 06-09-2003 01:09 AM

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.

Deus_Sephiroth 06-09-2003 07:42 AM

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.

Falados 06-09-2003 09:13 AM

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.

Tseng 06-09-2003 04:29 PM

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. :\

Neoreno 06-09-2003 05:58 PM

Quote:

newfeatures2003-v3.txt
Things that are not supported anymore:
- setbackpal
- playersays()

adam 06-09-2003 11:25 PM

*shouts for joy*

osrs 06-10-2003 02:18 AM

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..^_^

GoZelda 06-18-2003 03:27 PM

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.


All times are GMT +2. The time now is 11:21 AM.

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