Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Really simple question :) (https://forums.graalonline.com/forums/showthread.php?t=48528)

Zethar 10-10-2003 02:05 AM

Really simple question :)
 
Ok, i'm trying to learn how to script and i'm doing something that when it happens it won't happen again.
for example.
NPC Code:

if (playerchats&&strequals(#c,Hello)){
players[index].rupees+=10;
}



It thought it might be something like this but it doesnt work
NPC Code:

if (playerchats&&strequals(#c,Hello)){
players[index].rupees+=10;
set Hello-Rupee}
if (playerchats&&strequals(#c,Hello)){
if (Hello-Rupee){message No more >:[
}
}


And whats the command for if all enemies are dead....?

Qwert616 10-10-2003 02:27 AM

Re: Really simple question :)
 
Even though the second part of the money script finds that the event is false, it is still re-running the first event each time the player speaks.

I think you are looking for something like this:
NPC Code:
if (playerchats&&strequals(#c,Hello))
if (HelloRupee)
{message No more >:[;}
else
{players[index].rupees+=10;
set HelloRupee;
}




*note: There is most likely a more efficient way to do this*

I hope this helps.

DustyPorViva 10-10-2003 02:31 AM

Now don't go forgetting your semi-colons, they have a lot to do with scripting.

EDIT: No need to set a flag.

Zethar 10-10-2003 02:51 AM

ok that doesnt really work.
If you type "hello" once you get nothing and if you type hello1 or anything else after your money just goess up =(

osrs 10-10-2003 03:21 AM

A variable will help the script to work once. E.g:

NPC Code:


if(created){
this.mode = 0;
}

if(playerchats && strequals(#c,bah) && this.mode == 0){
playerrupees+=10;
this.mode = 1;
}



Done,you did it once and next time you won't be able to get more 10 gralats. Why did i put 'playerrupees' with underline? Because seems (is) better to use than players[index].rupees since it's for you.

Quote:


And whats the command for if all enemies are dead....?

read commands.rtf ^-^

Qwert616 10-10-2003 04:21 AM

Ah, hm.

I should probably stop trying to help people in this section. ^_^;;

Thanks osrs, that helped me out too.

CheeToS2 10-10-2003 01:26 PM

Quote:

Originally posted by DustyPorViva
EDIT: No need to set a flag.
setting a flag would be the best way, otherwise somebody could get gralats over and over again by using update level.

Python523 10-10-2003 03:50 PM

geez, every one of you suck at formatting x_X

osrs 10-10-2003 04:48 PM

Quote:

Originally posted by Python523
geez, every one of you suck at formatting x_X
Sorry if we aren't a master like you. ^^

Quote:

Originally posted by CheeToS2

setting a flag would be the best way, otherwise somebody could get gralats over and over again by using update level.

A player won't update the level,so i think a variable would be fine >.<
But setting a flag work too.

Neoreno 10-10-2003 06:55 PM

Quote:

Originally posted by osrs

Sorry if we aren't a master like you. ^^

It doesn't take an ounce of brainpower to format well.


Also, you didn't specify an index for player[index].rupees.
I also think that is read only.

Dach 10-10-2003 08:07 PM

funny how everyone is using the code brackets, yet half of them don't even bother to actually use spaces (the whole point of using code brackets)

Ningnong 10-10-2003 08:45 PM

This is all you need.

NPC Code:

if (playerchats){
if (strequals(#c,Hello) && !Hello) {
playerrupees += 10;
set Hello;
}
}



Simple as.

CheeToS2 10-10-2003 09:48 PM

Quote:

Originally posted by osrs
A player won't update the level,so i think a variable would be fine >.<
But setting a flag work too.

If anybody ever fixed a tile error, or updated the level, or (possibly) if the server went down, the variable would be reset. Its foolish to not use some kind of permanent protection when dealing with rupees.

Quote:

Originally posted by Neoreno


It doesn't take an ounce of brainpower to format well.


Also, you didn't specify an index for player[index].rupees.
I also think that is read only.

You don't need [index] when dealing with the player in question, and its only read-only when its clientside.

Neoreno 10-10-2003 09:51 PM

In any case, I would think it's better to use playerrupees.

Kaimetsu 10-11-2003 04:01 AM

Quote:

Originally posted by Dach
funny how everyone is using the code brackets, yet half of them don't even bother to actually use spaces (the whole point of using code brackets)
Wha? Code brackets as in '{'s? They're not inextricably related to spaces.

Dach 10-11-2003 04:45 AM

Quote:

Originally posted by Kaimetsu


Wha? Code brackets as in '{'s? They're not inextricably related to spaces.

I meant these
NPC Code:



couldn't remember what they're called exactly
ohyeah tags... d'oh

Kaimetsu 10-11-2003 04:48 AM

Ah, you're talking about indenting within code tags. Fair enough, I misinterpreted :)

terisu 10-11-2003 02:35 PM

It always seems like storing a string that only checks if a player has touched an NPC, would waste space and make a disarray of the player's stored strings etc.

GoZelda 10-11-2003 05:10 PM

Quote:

Originally posted by Dach


I meant these
NPC Code:



couldn't remember what they're called exactly
ohyeah tags... d'oh

Erm, there's nothing in the code...?

Dach 10-11-2003 07:24 PM

Quote:

Originally posted by GoZelda

Erm, there's nothing in the code...?

as in, people do this
NPC Code:

if (playertouchsme) {
playerhearts = 0;
}


instead of
NPC Code:

if (playertouchsme) {
playerhearts = 0;
}


GoZelda 10-11-2003 07:29 PM

Erm, just click the "style" button?

DarkShadows_Legend 10-11-2003 07:30 PM

Quote:

Originally posted by Dach
stuff
It's pretty much laziness on my part. Not sure about the others. I don't really fix the format until the end and online there is no Style button to help out a bit with making things look neat. :(

Quote:

(possibly) if the server went down,
O.o
If the server went down wouldn't all npc's not work?

osrs 10-11-2003 08:15 PM

Quote:

Originally posted by Dach


as in, people do this
NPC Code:

if (playertouchsme) {
playerhearts = 0;
}


instead of
NPC Code:

if (playertouchsme) {
playerhearts = 0;
}


Only styling is different, what's wrong?


Quote:

Originally posted by DarkShadows_Legend
If the server went down wouldn't all npc's not work?
He meant if the server went down and back ( i believe),flags will be cleared and you will able to get more 10 gralats in this case.

Kaimetsu 10-12-2003 04:43 AM

Sigh. If you ever try to make anything remotely complicated, you'll understand the value of proper indenting.

-Ramirez- 10-12-2003 08:49 AM

Quote:

Originally posted by DarkShadows_Legend
O.o
If the server went down wouldn't all npc's not work?

I'm probably wrong, but NPCs revert to clientside-only status when this happens, do they not?

Python523 10-12-2003 08:56 AM

Quote:

Originally posted by -Ramirez-

I'm probably wrong, but NPCs revert to clientside-only status when this happens, do they not?

wrong, that's only if the gserver is started without the npcserver, if the npcserver goes down npcs/weapons aren't sent at all

GoZelda 10-12-2003 01:19 PM

Quote:

Originally posted by osrs
He meant if the server went down and back ( i believe),flags will be cleared and you will able to get more 10 gralats in this case.
I think this.variables are cleared.
Explains why farming NPCs&stuff suddenly are gone sometimes.

-Ramirez- 10-12-2003 08:42 PM

Quote:

Originally posted by Python523


wrong, that's only if the gserver is started without the npcserver, if the npcserver goes down npcs/weapons aren't sent at all

Told you I was probably wrong. ;)

I thought I remembered a time on another server when that happened. All of my NPCWs disappeared, as expected, but I don't remember level NPCs dying with the server. It's probably my bad memory again. :P


All times are GMT +2. The time now is 07:13 AM.

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