Page 1 of 1

crimes random value

Posted: Sun Jan 21, 2018 9:00 pm
by Rodeobull
is there anyone who can give me the code to a random value gain in crimes/jobs
something like =rand(2,5)*1;

Re: crimes random value

Posted: Mon Jan 22, 2018 9:15 pm
by Rodeobull
for now i have something like this and i think/hope i'm close to a good result

$v=rand(3,7)*1;/*rnd*/$userStats["!currency"]->value+=$v;
ResultMessage("Pickpocket successful you got money.");




also would like to know how to give a random item

example i have car item and i want to make a car theft crime that gives a random car

Re: crimes random value

Posted: Mon Jan 22, 2018 9:34 pm
by hallsofvallhalla
Sorry I must have missed this earlier. Looks like you have it figured out though.

For a random item there is an Id column in the objects table. You could just do another random number and then select by id = that number. This however would grab ANY item so you may want to make a new table that you place objects Id in there that you want to be randomly picked from and have a new Id for those.

Re: crimes random value

Posted: Mon Jan 22, 2018 9:37 pm
by Rodeobull
the code in my last post is not working

Re: crimes random value

Posted: Mon Jan 22, 2018 9:53 pm
by hallsofvallhalla
what error are you getting?

Re: crimes random value

Posted: Mon Jan 22, 2018 9:54 pm
by Rodeobull
Error in evaluated code:

$v=rand(3,7)*1;/*rnd*/$userStats["!currency"]->value+=$v;
ResultMessage("Pickpocket successful you got money.");

Re: crimes random value

Posted: Mon Jan 22, 2018 10:02 pm
by hallsofvallhalla
$v=rand(3,7)*1;
$userStats["!currency"]->value+=$v;
ResultMessage("Pickpocket successful you got money.");

not that it matters but you dont need the *1
to debug put this in to see what is working and whats not
echo "random = " . $v;
echo "currency=" . $userStats["!currency"]->value;

Re: crimes random value

Posted: Mon Jan 22, 2018 10:12 pm
by Rodeobull
found it

!currency needs to be with a big C !Currency

Re: crimes random value

Posted: Mon Jan 22, 2018 10:17 pm
by hallsofvallhalla
Ha! its the little things. :P

Re: crimes random value

Posted: Mon Jan 22, 2018 10:21 pm
by Rodeobull
So for the others who want to use this line

this is the good line

$v=rand(3,7)*1;
$userStats["!Currency"]->value+=$v;
ResultMessage("Pickpocket succesful you got $v !Currency .");