Graal Forums

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

Merlin 09-22-2001 07:36 AM

Small question
 
when generating random numbers
i'm using this code
PHP Code:

setstring server.random,#v(random(1,5)); 

but i keep getting things like
server.random=2.056879

any idea on how i can make it so it only generated whole numbers?

Merlin 09-22-2001 07:44 AM

Re: Re: Small question
 
Quote:

Originally posted by Kaimetsu


The int() function is your best friend in the world.

:(
now i have to go read the commands :[

Merlin 09-22-2001 07:48 AM

Quote:

int( var ) the integer value of a variable (truncates the floating point part)
ok i got this far :\
but i don't know how to properly do it like
setstring server.random,int(random(1,5));
i tryed like that
and
setstring server.random,#v int(random(1,5));
and
setstring server.random,i#v,int(random(1,5));

:[

Merlin 09-22-2001 07:56 AM

yay
setstring server.roll1,#v(int(random(1,6)));

Merlin 09-22-2001 08:07 AM

:)
now i am at my next problem
the point was to send the data to another npc
which i did
now im doing a check in the other
so i want to do like
if (timeout) {
a = #s(server.1);
b = #s(server.2);
c = #s(server.3);
timeout = 1;
}

if (timeout) {
if (a==b) {
myaction;
}

like that
but when i try to do
a = #s(server.1);

i get the error

Error: Expected format var, var[i], obj[i].attr, function(a), function(a,b)

:(

Merlin 09-22-2001 08:21 AM

yeah i want to compare the strings to eachother
like if (string 1 = string 2) {
action;
}

if (string 2 = string 3) {
action;
}

if (string 3 = string 1) {
action;
}

:\

Merlin 09-22-2001 08:25 AM

i tryed doing that and i could not get it :{

Shard_IceFire 09-22-2001 08:30 AM

lol...n00b.
:spam: :spam: :spam:

Merlin 09-22-2001 08:32 AM

Quote:

Originally posted by Shard_IceFire
lol...n00b.
:spam: :spam: :spam:

cool i am a newbie because i am assitant accounts admin woo
crawl back in your hole.

Merlin 09-22-2001 08:33 AM

Quote:

Originally posted by Kaimetsu


To see if string 1 is the same as string 2, use:

if(strequals(#s(string1),#s(string2))){
stuffyo;
}

love4kai

Merlin 09-22-2001 08:46 AM

Quote:

Originally posted by Kaimetsu


Just doin' what I do.

:)


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

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