Jump to content

table server-side


iiv03

Recommended Posts

well i was make table with function setWeather i'm tired to add table out function and connect to outputChatBox so my try:

local weatherName = {"Test1","Test2","Test3"}--tables
function changeWeather(player, command, state, weatherID, weatherName)
	local account = getPlayerAccount (player)
	local account_name = getAccountName(account)	
	if isObjectInACLGroup ( "user." .. account_name, aclGetGroup ( "Admin" )) then
	if not state then outputChatBox("write a weather!", player, 255,255,255,true) return end
	if state == "weather" then
	setWeather(tonumber(weatherID)) --Set the weather and let the player know he did it
	outputChatBox("Weather successfully changed to "..weatherName, player, 0, 255, 0) -- here get a weathername when set id of weathers!
	else
	outputChatBox("Access Denied", player, 255,255,255,true)
	end
end
end
addCommandHandler("change", changeWeather)

i'm getting error

attempt to concatenate local 'weatherName' (a nil value)

Link to comment

Problem hides here:

function changeWeather(player, command, state, weatherID, weatherName)

your function redefines value of weatherName variable in current scope.

You probably want this (inside your function):

local selected = weatherName[tonumber(weatherID)] -- get text from table

also remove last function argument to make everything work

function changeWeather(player, command, state, weatherID)

 

  • Thanks 1
Link to comment
21 hours ago, JeViCo said:

Problem hides here:


function changeWeather(player, command, state, weatherID, weatherName)

your function redefines value of weatherName variable in current scope.

You probably want this (inside your function):


local selected = weatherName[tonumber(weatherID)] -- get text from table

also remove last function argument to make everything work


function changeWeather(player, command, state, weatherID)

 

Thanks :)

 

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