Jump to content

setWeather attempt


Vinspire

Recommended Posts

Hello guys, the code below is an attempt of trying to set your own weather on your screen with the command csw. What I thought of here is that if you do => E.g: "/csw 0" then you get the normal weather, /csw 1 = sun, /csw 2 = foggy, and so on to 250 or so, (idk the max weather list)

Could you help me a bit with this? doesn't work perfectly now. It's because it sets randomly weathers when you do /csw. I don't want it to set randomly, I want the thing above. Do you think you could help? if so Thanks alot.

:arrowdown:

addCommandHandler('csw', 
 function ( ) 
 setWeather(math.random (0, 9 ) ) 
  local Weather = getWeather () 
  outputChatBox("The weather is currently: "..Weather, source) 
  end 
  ) 

Edited by Guest
Link to comment
  • Moderators
addCommandHandler('csw', 
function (player,CMD,Weather) 
    Weather = tonumber(Weather) 
    if Weather then 
        setWeather(Weather) 
        --local Weather = getWeather () 
        outputChatBox("The weather is currently: "..Weather, player) 
    end 
end) 

Edited by Guest
Link to comment
addCommandHandler('csw', 
function (Weather) 
    Weather = tonumber(Weather) 
    if Weather then 
        setWeather(Weather) 
        --local Weather = getWeather () 
        outputChatBox("The weather is currently: "..Weather, source) 
    end 
end) 

That doesn't work ;s

Link to comment

For client-side:

addCommandHandler('csw', 
    function (Weather) 
        Weather = tonumber(Weather) 
        local sWeather = setWeather(Weather) 
        if (sWeather == false) then 
            outputChatBox("This is not a valid weather ID! You entered: "..Weather) 
        end 
    end 
end) 

For server-side:

addCommandHandler('csw', 
    function (Weather) 
        Weather = tonumber(Weather) 
        local sWeather = setWeather(Weather) 
        if (sWeather == false) then 
            outputChatBox("This is not a valid weather ID! You entered: "..Weather, source) 
        end 
    end 
end) 

Link to comment
For server-side:
addCommandHandler('csw', 
    function (Weather) 
        Weather = tonumber(Weather) 
        local sWeather = setWeather(Weather) 
        if (sWeather == false) then 
            outputChatBox("This is not a valid weather ID! You entered: "..Weather, source) 
        end 
    end 
end) 

addCommandHandler server-side has a playerSource parameter. your forgot that.

Link to comment

*Coughs*

For server-side:

function cWeather(thePlayer, theCommand, weatherID) 
    local weatherID = tonumber(weatherID) 
    local sWeather = setWeather(weatherID) 
    if (sWeather ~= false) then 
        outputChatBox("Successfully changed the weather!", thePlayer) 
    else 
        outputChatBox("This is not a valid weather ID. You entered: "..tostring(weatherID), thePlayer) 
    end 
end 
  
addCommandHandler("cws", cWeather) 

For client-side:

function cWeather(theCommand, weatherID) 
    local weatherID = tonumber(weatherID) 
    local sWeather = setWeather(weatherID) 
    if (sWeather ~= false) then 
        outputChatBox("Successfully changed the weather!") 
    else 
        outputChatBox("This is not a valid weather ID. You entered: "..tostring(weatherID)) 
    end 
end 
  
addCommandHandler("cws", cWeather) 

Typed in my own 'rules' this time. I guess it shouldn't give any errors by 'setWeather' if I'm correct :P

Link to comment

Thanks guys, xD. If you could help me setting the time too that would be best :D

doesn't work too, doesn't say much on this on the wiki so =/

What I want with this code is that players can set their own time on their screen for better graphic or other reasons.

addEventHandler( 'onClientRender', getRootElement( ), 
function (csettime) 
    local hour, minutes = getTime() 
    setTime( 1, 0 ) 
end 
) 
addCommandHandler('cst', csettime) 

Thanks!

Link to comment

Take my client-side code. Add one more variable into the function. Add one more local variable to make the variable you just added to the function a number (tonumber()). Change the 'setWeather' code to the 'setTime' code and it's needed 'settings'.

Link to comment

Something like this? .:arrowdown:.

(sorry I didn't really get what you mean (shit scripter <-)

function cTime(theCommand, timeID) 
    local timeID= tonumber(timeID) 
    local sTime = setTime(timeID) 
    if (sTime ~= false) then 
    end 
end 
addCommandHandler("cst", cTime) 
addCommandHandler("csettime", cTime) 

Link to comment
Something like this? .:arrowdown:.

(sorry I didn't really get what you mean (:~ scripter <-)

Code 

Should do the hours and minutes separated, because 'setTime' needs that.

function cTime(theCommand, timeID1, timeID2) 
    local timeID1 = tonumber(timeID1) --Hours 
    local timeID2 = tonumber(timeID2) --Minutes 
    local sTime = setTime(timeID1, timeID2) 
    if (sTime ~= false) then 
        --Success 
    else 
        --Failed 
    end 
end 
addCommandHandler("cst", cTime) 
addCommandHandler("csettime", cTime) 

Note: This is client-side.

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...