Jump to content

How would I make a map be random?


Mossy

Recommended Posts

Like this:

local maps = {} 
addCommandHandler("random",function(source) 
    for _,v in ipairs(getResources())do --loop through all the resources 
        if string.lower(getResourceInfo(v,"type")) =="map" then --see if it's a map 
            table.insert(maps,v) --if it is, insert it into our table 
        end 
    end 
    map = unpack(math.random(#maps)) --get a random map from the table 
    startResource(map) --start the map 
end) 

??

Edited by Guest
Link to comment
well, if you are in the admin acl then use this function:
isObjectInACLGroup 

BTW, fixed the error

Code please? :>

uh,

local maps = {} 
addCommandHandler("random",function(source) 
    if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("admin")) then outputChatBox("You are not an admin!",source) return end 
    for _,v in ipairs(getResources())do --loop through all the resources 
        if string.lower(getResourceInfo(v,"type")) =="map" then --see if it's a map 
            table.insert(maps,v) --if it is, insert it into our table 
        end 
    end 
    map = unpack(math.random(#maps)) --get a random map from the table 
    startResource(map) --start the map 
end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...