Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Safe script (https://forums.graalonline.com/forums/showthread.php?t=60361)

alissalee 08-04-2005 06:51 PM

Safe script
 
if (created||timeout) {
message Tips: #s(server.BHE);
timeout=0.5;
}
if (playerchats&&strequals(#a,Birdwell)||strequals(#a ,Brandons account)||strequals(#a,Dark Dragon Guardian)){}
if (startswith(/take,#c)) {
tokenize #c;
if (strtofloat(#s(server.BHE))>=strtofloat(#t(1))){
if (strtofloat(#t(1))>0){
playerrupees+=strtofloat(#t(1));
setstring server.BHE,#v(strtofloat(#s(server.BHE))-strtofloat(#t(1)));
setplayerprop #c,Took #t(1)!;
message Tips: -#t(1);
sleep 3;
message Tips: #s(server.BHE);
}else setplayerprop #c,Can't take that!;
}}

if (playerchats) {
if (startswith(/tip,#c)){
tokenize #c;
if (playerrupees>=strtofloat(#t(1))){
if (strtofloat(#t(1))>0){
playerrupees-=strtofloat(#t(1));
setstring server.BHE,#v(strtofloat(#s(server.BHE))+strtofloa t(#t(1)));
setplayerprop #c, Tipped #t(1)!;
message Tips: +#t(1);
sleep 3;
message Tips: #s(server.BHE);
}
}
}
the script works but it gives out money to ppl not in the list to be able to take it. help please

protagonist 08-04-2005 07:41 PM

Quote:

Originally Posted by alissalee
if (created||timeout) {
message Tips: #s(server.BHE);
timeout=0.5;
}
if (playerchats&&strequals(#a,Birdwell)||strequals(#a ,Brandons account)||strequals(#a,Dark Dragon Guardian)){}
if (startswith(/take,#c)) {
tokenize #c;
if (strtofloat(#s(server.BHE))>=strtofloat(#t(1))){
if (strtofloat(#t(1))>0){
playerrupees+=strtofloat(#t(1));
setstring server.BHE,#v(strtofloat(#s(server.BHE))-strtofloat(#t(1)));
setplayerprop #c,Took #t(1)!;
message Tips: -#t(1);
sleep 3;
message Tips: #s(server.BHE);
}else setplayerprop #c,Can't take that!;
}}

if (playerchats) {
if (startswith(/tip,#c)){
tokenize #c;
if (playerrupees>=strtofloat(#t(1))){
if (strtofloat(#t(1))>0){
playerrupees-=strtofloat(#t(1));
setstring server.BHE,#v(strtofloat(#s(server.BHE))+strtofloa t(#t(1)));
setplayerprop #c, Tipped #t(1)!;
message Tips: +#t(1);
sleep 3;
message Tips: #s(server.BHE);
}
}
}
the script works but it gives out money to ppl not in the list to be able to take it. help please

The account check isn't even checking anything. You close it instead of continuing with the event block.

alissalee 08-04-2005 08:22 PM

Quote:

Originally Posted by protagonist
The account check isn't even checking anything. You close it instead of continuing with the event block.

ok that means wat i am a new scripter i dont know that much

Tolnaftate2004 08-04-2005 08:48 PM

1. KSI-GS (Rule 2a and Rule 8).
2. You may want to check that they're adding / taking an integer value.
3. The timeout isn't necessary...

PastAustin 08-04-2005 09:28 PM

Quote:

Originally Posted by Tolnaftate2004
1. KSI-GS (Rule 2a and Rule 8).
2. You may want to check that they're adding / taking an integer value.
3. The timeout isn't necessary...

If this weren't a simple fix I probably would completly recode it. So lets act as if it weren't.

Alissalee:
The thing I was pointing out with this that I guess I should have actually hilited it that you need to watch your groupings. You had this:
PHP Code:

if (playerchats&&strequals(#a,Birdwell)||strequals(#a,Brandons account)||strequals(#a,Dark Dragon Guardian)){} 

and then this:
PHP Code:

if (startswith(/take,#c)) { 

I am guessing you accidently closed the condition but what it was testing was not
PHP Code:

if (playerchats && startswith(/take#c) && (strequals(#a,Birdwell)||strequals(#a,Brandons account)||strequals(#a,Dark Dragon Guardian))) 

but
PHP Code:

// Does nothing:
if (playerchats && strequals(#a,Birdwell) || strequals(#a,Brandons account) || strequals(#a,Dark Dragon Guardian) {}
// And
if (startswith(/take#c)) {
// actions


Meaning that it would never reach the code block with the startswith because startswith is not a trigger. Also since you had:
PHP Code:

if (playerchats && strequals(#a,Birdwell)||strequals(#a,Brandons account)||strequals(#a,Dark Dragon Guardian)) {} 

You were literally saying
If the player chats and the account is Birdwell or if (no action) and the account is Brandons Account or (no action) and the account is Dark Dragon Guardian.
Meaning that the playerchats (the trigger) had no effect on Brandons Account or Dark Dragon Guardian since neither of them had the playerchats attached to them.

That is the long way of explaining it. Hope it helped.

Lance 08-04-2005 10:03 PM

In addition to everything already said, I'd suggest only re-displaying the tip amount when the NPC is created or when the tip amount has changed. It's unnecessary to have such a timeout-display unless you have some other script changing it (which does not seem to be the case).

alissalee 08-04-2005 10:15 PM

thank you it works right.


All times are GMT +2. The time now is 09:53 PM.

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