Graal Forums

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

Artificial_Sweetener 07-03-2002 11:21 AM

Simple question
 
Sorry uh.. I just need one simple command for a script i'm working on.. I'll delete this thread as soon as someone replies =)

Anyway, let me think of an example..

Just take like a light switch for an example, I need to figure out how to make it so if the player touches it once it will activate and if it touches it agian it will deactivate. I don't need this script exactly just the idea in general so I could finish up a script I'm working on.. Thanks alot :)

screen_name 07-03-2002 11:26 AM

well, something like this would work, for database npc

NPC Code:

if (playertouchsme) {
setstring this.onoff,#v(abs(strtofloat(#s(this.onoff))-1));
}





then have it read the flag, and if its 1 then on, 0 = off

=D

Artificial_Sweetener 07-03-2002 11:38 AM

Um could you explain it a bit?
So I could take it a part, understand how it works, and make it something else.. Please :(

screen_name 07-03-2002 12:11 PM

well, since there is only two possible flags, on or off, i just use variables 0 and 1

take the current status of the light, lets say off (off=0) and then just take the absolute value of the status -1, so
0-1 = -1
|-1| = 1

turns from off (0), to on (1)

same way around
1-1 = 0
|0| = 0

turns from on (1), to off (0)

Knight_Vincent 07-04-2002 02:51 AM

Just wondering, would that work the same if it was

if (weaponfired)

?

user13-xo 07-04-2002 02:55 AM

Quote:

Originally posted by Knight_Vincent
Just wondering, would that work the same if it was

if (weaponfired)

?

Yes

screen_name 07-04-2002 02:58 AM

it would work in any flag that is true

playerenters, playerchats, etc, etc

Knight_Vincent 07-04-2002 03:16 AM

Ahh, thank you :).

screen_name 07-04-2002 03:32 AM

no problem, thats what im here for



and remember if you have any other questions, dont be afraid to ask


All times are GMT +2. The time now is 05:23 PM.

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