Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Random Actions.... (https://forums.graalonline.com/forums/showthread.php?t=12373)

KrAnKyP2P 09-20-2001 07:35 PM

Plz Help Again...
 
Im making sand mining for my server (cuz sand is rare) and i don't know how to make it random.. so u don't get the same ammount of sand every time... can anyone help??
SCROLL DOWN .. i need more help

~edited later after i got help~

Shard_IceFire 09-20-2001 08:51 PM

That's incredibly easy. You can do it in a number of ways but I'll show you mine:
NPC Code:

if (actionWHATEVER) {
this.number=random(1,10);
setstring sandplus,#v(this.number);
}


KrAnKyP2P 09-20-2001 09:25 PM

Thanks for the help
Scroll down

KrAnKyP2P 09-20-2001 09:48 PM

~~if someone buys 100 sand from me it does this~~

this.sandplus=strtofloat(#s(sandammt))+100;
setstring sandammt,#v(this.sandplus);

~~This is the sand jar...~~

if (weaponfired)
{
say2 Your Sand: #s(sandammt);
}

~~This is the (unnamed) mining tool~~

if (weaponfired){
set action.miningsand;
setcharprop #c, You have #v(this.number) Sand;
}

~~This is in the Mining Place...~~

if (action.miningsand)
{
this.number=random(1,10);
setstring sandplus,#v(this.number);
}



It doesn't work.. the sand just goes from 2.9382 or sumthin like that to 1.38473 then back to 29382 and to 1.38473..
can anyone help ?

KJS 09-21-2001 02:48 AM

say

this.number=int(random(1,11));

I just included int to it so it gets the integer of it. I added 1 to the last number because it can never be what the last number says... So this way it gives it a chance to be anywere from 1-10 insted of 1-9 (how it usto be)

Merlin 09-21-2001 03:41 AM

flags are not cool:cool: :cool: :cool: :cool: :cool:


All times are GMT +2. The time now is 12:31 AM.

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