Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Fire rate (https://forums.graalonline.com/forums/showthread.php?t=63097)

JkWhoSaysNi 12-31-2005 04:23 AM

Fire rate
 
I have a simple weapon script which fires a weapon but at the moment every time you press D it fires. How can i make it so theres a larger inteval between firing?

Thanks.

Lance 12-31-2005 04:48 AM

You could set a flag to true if the weapon is fired and the flag is false. Then, set a timeout to reset the flag.

Kronan 12-31-2005 05:29 AM

Here is a small example:


NPC Code:
//#CLIENTSIDE
function onCreated() {
this.fired = true;
}
function onWeaponFired() {
if (this.fired) {
// your stuff can go here
this.fired = false;
setTimer(5);
}
else
{
player.chat = "You must wait 5 seconds before firing again!";
}
}
function onTimeout() {
if (this.fired == false) {
this.fired = true;
setTimer(5);
}
}


Lance 12-31-2005 05:32 AM

Quote:

Originally Posted by Kronan
Here is a small example:


NPC Code:
//#CLIENTSIDE
function onCreated() {
this.fired = true;
}
function onWeaponFired() {
if (this.fired) {
// your stuff can go here
this.fired = false;
setTimer(5);
}
else
{
player.chat = "You must wait 5 seconds before firing again!";
}
}
function onTimeout() {
if (this.fired == false) {
this.fired = true;
}
}


Why did you make this.fired counterintuitive?

JkWhoSaysNi 12-31-2005 03:57 PM

Thanks.

Is there any reason to use function onCreated() {} over if(created) {}?

Skyld 12-31-2005 04:43 PM

Quote:

Originally Posted by JkWhoSaysNi
Thanks.

Is there any reason to use function onCreated() {} over if(created) {}?

Kronan's example is gscript2. if (created) is not.

JkWhoSaysNi 12-31-2005 07:25 PM

Ah, thanks.


All times are GMT +2. The time now is 12:51 PM.

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