crimes random value

General Chat, Comments

crimes random value

Postby Rodeobull » Sun Jan 21, 2018 4:00 pm

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 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: crimes random value

Postby Rodeobull » Mon Jan 22, 2018 4:15 pm

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
Rodeobull
 
Posts: 10
Joined: Thu Jan 09, 2014 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: crimes random value

Postby hallsofvallhalla » Mon Jan 22, 2018 4:34 pm

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.
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11946
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: crimes random value

Postby Rodeobull » Mon Jan 22, 2018 4:37 pm

the code in my last post is not working
Rodeobull
 
Posts: 10
Joined: Thu Jan 09, 2014 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: crimes random value

Postby hallsofvallhalla » Mon Jan 22, 2018 4:53 pm

what error are you getting?
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11946
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: crimes random value

Postby Rodeobull » Mon Jan 22, 2018 4:54 pm

Error in evaluated code:

$v=rand(3,7)*1;/*rnd*/$userStats["!currency"]->value+=$v;
ResultMessage("Pickpocket successful you got money.");
Rodeobull
 
Posts: 10
Joined: Thu Jan 09, 2014 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: crimes random value

Postby hallsofvallhalla » Mon Jan 22, 2018 5:02 pm

$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;
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11946
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: crimes random value

Postby Rodeobull » Mon Jan 22, 2018 5:12 pm

found it

!currency needs to be with a big C !Currency
Rodeobull
 
Posts: 10
Joined: Thu Jan 09, 2014 2:49 pm
Has thanked: 0 time
Been thanked: 0 time

Re: crimes random value

Postby hallsofvallhalla » Mon Jan 22, 2018 5:17 pm

Ha! its the little things. :P
User avatar
hallsofvallhalla
Site Admin
 
Posts: 11946
Images: 13
Joined: Wed Apr 22, 2009 6:29 pm
Location: mobile, al
Has thanked: 11 times
Been thanked: 158 times
Blog: View Blog (3)

Re: crimes random value

Postby Rodeobull » Mon Jan 22, 2018 5:21 pm

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 .");
Rodeobull
 
Posts: 10
Joined: Thu Jan 09, 2014 2:49 pm
Has thanked: 0 time
Been thanked: 0 time


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x