Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Pay check System (https://forums.graalonline.com/forums/showthread.php?t=60657)

alissalee 08-23-2005 08:55 PM

Pay check System
 
how would i script the part when the player chats /paycheck it only takes $250 playerrupees from the safe?

calani 08-23-2005 10:16 PM

-shakes head-
Not to be rude or anything, but judging by the vast number of questions you've been asking about simple things or things you have no idea how to do, you really need to get a NAT for your server.

xAndrewx 08-23-2005 10:23 PM

Use a database.

Bl0nkt 08-24-2005 01:15 AM

Keep the money that's in that safe in a serverr. string.

NPC Code:
if (playerchats && strequals(#c,/paycheck)) {



Ok, so

NPC Code:
if (playerchats ...



This is detected when enter is hit entering a message.

NPC Code:
&& strequals(#c,/paycheck)) {



&& is just another way of saying and in scripting. So far we have 'if the player enters a message and'. strequals is used to determine what a player has. In this case, it's looking for something the player is saying (notice #c). So, if the player enters a message and the player's chat text is '/paycheck', what is written in the bracers will take place.

NPC Code:
if (playerchats && strequals(#c,/paycheck)) {
playerrupees += 250;
setstring 'serverr.strings',strtofloat(#s('serverr.strings') ) - 250;
}



Of course, you will have to add another flag in there to test whether the safe has 250g or not; but that's your job.

Luigi203 08-24-2005 01:52 AM

Quote:

Originally Posted by Bl0nkt
Keep the money that's in that safe in a serverr. string.

What the hell, Hachi? Use a DB NPC, did you absorb nothing I tried to teach you? I guess you like opening your server. flags and wondering what the hell each flag means.

Quote:

Originally Posted by Bl0nkt
NPC Code:
if (playerchats && strequals(#c,/paycheck)) {
playerrupees += 250;
setstring 'serverr.strings',strtofloat(#s('serverr.strings') ) - 250;
}


NPC Code:

setstring 'serverr.strings',#v(strtofloat(#s('serverr.strings')) - 250);




Use the flag prefix thiso. and with(). Thiso. flags belong to the npc that is 'calling' another with the with() function, for example,
NPC Code:

thiso.var = 5;
with (getnpc(DBNPC)) this.var += thiso.var;



If you were to just do "with (getnpc(DBNPC)) this.var += this.var;"
it would add DBNPC's this.var to itself, however, since thiso.var belongs to the current npc and it equals 5, it adds 5 to DBNPC's this.var. I hope you understand this...

Bl0nkt 08-24-2005 11:56 PM

Quote:

Originally Posted by Luigi203
What the hell, Hachi? Use a DB NPC, did you absorb nothing I tried to teach you? I guess you like opening your server. flags and wondering what the hell each flag means.



NPC Code:

setstring 'serverr.strings',#v(strtofloat(#s('serverr.strings')) - 250);




Use the flag prefix thiso. and with(). Thiso. flags belong to the npc that is 'calling' another with the with() function, for example,
NPC Code:

thiso.var = 5;
with (getnpc(DBNPC)) this.var += thiso.var;



If you were to just do "with (getnpc(DBNPC)) this.var += this.var;"
it would add DBNPC's this.var to itself, however, since thiso.var belongs to the current npc and it equals 5, it adds 5 to DBNPC's this.var. I hope you understand this...

I never really learned about DBs. :[

calani 08-25-2005 01:46 AM

hey cool, my post got deleted :D
guess i'm not supposed to help out o.O

Malinko 08-25-2005 02:18 AM

Quote:

Originally Posted by calani
hey cool, my post got deleted :D
guess i'm not supposed to help out o.O

http://forums.graalonline.com/forums...cement.php?f=8

Read Rules #2 and #4.

Lance 08-25-2005 06:19 AM

Quote:

Originally Posted by Malinko

Only rule 2 was applicable in this case.

konidias 08-25-2005 08:02 PM

His post was moot considering the starting post breaks rule #1.

Lance 08-26-2005 01:51 AM

Quote:

Originally Posted by konidias
His post was moot considering the starting post breaks rule #1.

Not intrinsically.

Gamba_Legend 08-27-2005 12:45 AM

Just ignore this person from now on
It's not my idea this person was hired and/or not fired -.-

calani 08-27-2005 01:02 AM

Quote:

Originally Posted by Malinko
Read Rules #2 and #4

har har @ breaking rule #4.
shall I bring up our last argument wherein every one of your glorious 'points' were off or misinformed, or completely and utterly wrong?
Quote:

Originally Posted by Malinko
For all we know, the only information you posess is the knowledge of you abusing your powers and harassing players/playerworlds with the powers you have gained. So don't speak to me unless you know your information.

It's scary how perfectly accurate that is about the very person who spoke it.



Anyways, enough with the bashing.

I broke rule #2 for posting a 'full script' that could not possibly work?
lets review the script i posted


[start of script]
(serverside script showing thiso. vars inside a with)
//#CLIENTSIDE
(clientside script showing thiso.vars not crossing the clientside boundary)

//////////////

(a second serverside script showing how this. vars do not work through withs)
//#CLIENTSIDE
(clientside code showing that this. vars also do not cross the clientside boundary)
[end of script]


few problems with that one being a full script they can copy/paste into an editor:
* will not work at all. the script has no purpose and no way to link itself together
* there's actually two scripts in one! neither of which work

please, explain to me how that violates rule #2.


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

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