crimes random value

General Chat, Comments
Post Reply
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

crimes random value

Post 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;
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

Re: crimes random value

Post 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
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: crimes random value

Post 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.
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

Re: crimes random value

Post by Rodeobull »

the code in my last post is not working
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: crimes random value

Post by hallsofvallhalla »

what error are you getting?
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

Re: crimes random value

Post by Rodeobull »

Error in evaluated code:

$v=rand(3,7)*1;/*rnd*/$userStats["!currency"]->value+=$v;
ResultMessage("Pickpocket successful you got money.");
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: crimes random value

Post 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;
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

Re: crimes random value

Post by Rodeobull »

found it

!currency needs to be with a big C !Currency
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: crimes random value

Post by hallsofvallhalla »

Ha! its the little things. :P
Rodeobull
Posts: 10
Joined: Thu Jan 09, 2014 7:49 pm

Re: crimes random value

Post 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 .");
Post Reply

Return to “General”