Author Topic: Random Selection  (Read 3729 times)

0 Members and 1 Guest are viewing this topic.

Offline Chezor

  • Wiseguy
  • **
  • Posts: 90
  • RPG Planet Scripter
    • View Profile
    • RPG Planet
Random Selection
« on: September 02, 2008, 09:02:21 pm »
I want to create a job script, for RPG server. Suppose if i want to make import/export job script. [example]

Like people sit in any car, they type !transport. When they type it they will be given randomly selected place like little havana, docks, lighthouse etc.
How to make a script which randomly selects any option which i script.

just as !search coin
options:
you found a gold coin
you found silver coin
you found nothing

Anything will be directly chosen from that. Please explain in detail, im not expert you can understand because you know how hard it was when you were beginner. :]

Scripts: Fuel system in vehicles, Speedometer, Spawnback, Improved Copwork, Improved Jailing, Improved phone with sms, and many more. Coming soon..

Offline TanaX01

  • Made Man
  • ***
  • Posts: 214
  • BlackList! <3
    • View Profile
Re: Random Selection
« Reply #1 on: September 02, 2008, 10:01:45 pm »
mm dude look in script tommis !gotoloc name localitation yea ???

Offline thijn

  • LU testers
  • VC:MP Veteran
  • *
  • Posts: 667
  • Im proud to be pro.
    • View Profile
    • Vice Underdogs
Re: Random Selection
« Reply #2 on: September 02, 2008, 10:41:36 pm »
example:
Code: [Select]
var %a = $rand(1,3)
if (%a == 1) {
vcmp.msg %id You found were be teleporting to Little Havana.
vcmp.setloc %id (axis)
}
elseif (%a == 2) {
vcmp.msg %id You found were be teleporting to The Lighthouse.
vcmp.setloc %id (axis)
}
Hope u get it ;)

Offline Chezor

  • Wiseguy
  • **
  • Posts: 90
  • RPG Planet Scripter
    • View Profile
    • RPG Planet
Re: Random Selection
« Reply #3 on: September 03, 2008, 06:59:34 am »
example:
Code: [Select]
var %a = $rand(1,3)
if (%a == 1) {
vcmp.msg %id You found were be teleporting to Little Havana.
vcmp.setloc %id (axis)
}
elseif (%a == 2) {
vcmp.msg %id You found were be teleporting to The Lighthouse.
vcmp.setloc %id (axis)
}
Hope u get it ;)

okay i got this one, thankx thjn. so that $rand makes it randomly selecting either %a as 1 or %a as 2  :)

Scripts: Fuel system in vehicles, Speedometer, Spawnback, Improved Copwork, Improved Jailing, Improved phone with sms, and many more. Coming soon..

Windlord

  • Guest
Re: Random Selection
« Reply #4 on: September 03, 2008, 12:16:39 pm »
$rand(a,b) returns a random integer between a and b.
By using var %a = $rand(1,2)
You are able to temporarily store a random number between 1 and 2.

This lets you make the script to random stuff by checking the value of the variable: %a.

Offline Chezor

  • Wiseguy
  • **
  • Posts: 90
  • RPG Planet Scripter
    • View Profile
    • RPG Planet
Re: Random Selection
« Reply #5 on: September 03, 2008, 01:31:07 pm »
$rand(a,b) returns a random integer between a and b.
By using var %a = $rand(1,2)
You are able to temporarily store a random number between 1 and 2.

This lets you make the script to random stuff by checking the value of the variable: %a.
Thanks for the info.  :)

Scripts: Fuel system in vehicles, Speedometer, Spawnback, Improved Copwork, Improved Jailing, Improved phone with sms, and many more. Coming soon..