Jump to content

help with event system


Polak0

Recommended Posts

I have problem with event system. 

 

[11:03:18] ERROR: [scripts]\Event2\sourceS.lua:49: attempt to perform arithmetic on local 'player' (a nil value)

 

local Event = false
local player = 0

function Event_start(plr)
	if Event == false then
		Event = true
		outputChatBox("Save on event is ON, write /join to join on event.", plr, 255, 255, 255, true)
	elseif
	 Event == true then
		Event = false
		outputChatBox("Saves are OFF.", plr, 255, 255, 255, true)
end
end
addCommandHandler("event_saves", Event_start)


addCommandHandler("event_create", function(plr, cmd, t2, t1, value, ...)
		if not t2 or not t1 or not ... or not tonumber(value) then
			outputChatBox("Correct CMD is /event_create <event name> <the number of players>", plr, 255, 255, 255)
        end
	
	local name_event = table.concat({t2})
	local value = table.concat({t1})

		if  tonumber(value) < 8 then 
			outputChatBox("You write too small number of players !", plr, 255, 255, 255)
		return end
		
		if  tonumber(value) > 64 then 
			outputChatBox("You write too big number of players !", plr, 255, 255, 255)
		return end
		
	if  tonumber(value) > 0 then 
		local name = getPlayerName(plr)
		outputChatBox("Administrator: #008000"..name.." #FFFFFFinvite on event #008000"..name_event.."#FFFFFF , free places: #0080000/"..value.."", getRootElement(), 255, 255, 255, true)
		return end
end)

local function Join_event(plr, cmd, t1, value, player)
if not Event == true then return end

local value = table.concat({t1})

	if getElementData(plr, "player:event") then
		outputChatBox("You are in event!", plr, 255, 255, 255, true)
	return end
	
		setElementData(plr, "player:event", true)
		player = player+1
	if player > value then 
		outputChatBox("The event is have maximum number of players.", getRootElement(), 255, 255, 255, true)
	return end
	setElementPosition(plr, -2422.37842, -607.25677, 132.56250)
	outputChatBox("W E L C O M E   on the event !", plr, 255, 255, 255, true)
	
end
addCommandHandler("join", Join_event)


function lols(plr)
setElementData(plr, "player:event", false)
end
addCommandHandler("s", lols)

 

Edited by Polak0
Link to comment
local Event = false
local player = 0

function Event_start(plr)
	if Event == false then
		Event = true
		outputChatBox("Save on event is ON, write /join to join on event.", plr, 255, 255, 255, true)
	elseif
	    Event == true then
		Event = false
		outputChatBox("Saves are OFF.", plr, 255, 255, 255, true)
	end
end
addCommandHandler("event_saves", Event_start)


addCommandHandler("event_create", function(plr, cmd, t2, t1, value, ...)
		if not t2 or not t1 or not ... or not tonumber(value) then
			outputChatBox("Correct CMD is /event_create <event name> <the number of players>", plr, 255, 255, 255)
        end
	
	local name_event = table.concat({t2})
	local value = table.concat({t1})

		if  tonumber(value) < 8 then 
			outputChatBox("You write too small number of players !", plr, 255, 255, 255)
		return end
		
		if  tonumber(value) > 64 then 
			outputChatBox("You write too big number of players !", plr, 255, 255, 255)
		return end
		
	if  tonumber(value) > 0 then 
		local name = getPlayerName(plr)
		outputChatBox("Administrator: #008000"..name.." #FFFFFFinvite on event #008000"..name_event.."#FFFFFF , free places: #0080000/"..value.."", getRootElement(), 255, 255, 255, true)
		return end
end)

local function Join_event(plr, cmd, t1, value)
if not Event == true then return end

local value = table.concat({t1})

	if getElementData(plr, "player:event") then
		outputChatBox("You are in event!", plr, 255, 255, 255, true)
	return end
	
		setElementData(plr, "player:event", true)
		player = (tonumber(player) or 0)+1
	if player > value then 
		outputChatBox("The event is have maximum number of players.", getRootElement(), 255, 255, 255, true)
	return end
	setElementPosition(plr, -2422.37842, -607.25677, 132.56250)
	outputChatBox("W E L C O M E   on the event !", plr, 255, 255, 255, true)
	
end
addCommandHandler("join", Join_event)


function lols(plr)
setElementData(plr, "player:event", false)
end
addCommandHandler("s", lols)

 

Link to comment

The same problem.

[21:41:20] ERROR: [scripts]\Event2\sourceS.lua:49: attempt to call upvalue 'player' (a number value)

 

\\Edit

New Problem.

[21:46:34] ERROR: [Scripts]\Event2\sourceS.lua:50: attempt to compare string with number
local Event = false
local player = 0

function Event_start(plr)
	if Event == false then
		Event = true
		outputChatBox("Save on event is ON, write /join to join on event.", plr, 255, 255, 255, true)
	elseif
	    Event == true then
		Event = false
		outputChatBox("Saves are OFF.", plr, 255, 255, 255, true)
	end
end
addCommandHandler("event_saves", Event_start)


addCommandHandler("event_create", function(plr, cmd, t2, t1, value, ...)
		if not t2 or not t1 or not ... or not tonumber(value) then
			outputChatBox("Correct CMD is /event_create <event name> <the number of players>", plr, 255, 255, 255)
        end
	
	local name_event = table.concat({t2})
	local value = table.concat({t1})

		if  tonumber(value) < 8 then 
			outputChatBox("You write too small number of players !", plr, 255, 255, 255)
		return end
		
		if  tonumber(value) > 64 then 
			outputChatBox("You write too big number of players !", plr, 255, 255, 255)
		return end
		
	if  tonumber(value) > 0 then 
		local name = getPlayerName(plr)
		outputChatBox("Administrator: #008000"..name.." #FFFFFFinvite on event #008000"..name_event.."#FFFFFF , free places: #0080000/"..value.."", getRootElement(), 255, 255, 255, true)
		return end
end)

local function Join_event(plr, cmd, t1, value, player)
if not Event == true then return end

local value = table.concat({t1})

	if getElementData(plr, "player:event") then
		outputChatBox("You are in event!", plr, 255, 255, 255, true)
	return end
	
		setElementData(plr, "player:event", true)
		player = (tonumber(player) or 0)+1
	if player > value then 
		outputChatBox("The event is have maximum number of players.", getRootElement(), 255, 255, 255, true)
	return end
	setElementPosition(plr, -2422.37842, -607.25677, 132.56250)
	outputChatBox("W E L C O M E   on the event !", plr, 255, 255, 255, true)
	
end
addCommandHandler("join", Join_event)


function lols(plr)
setElementData(plr, "player:event", false)
end
addCommandHandler("s", lols)

 

Edited by Polak0
Link to comment
local Event = false
local playersCount = 0

function Event_start(plr)
	if not Event then
		Event = true
		outputChatBox("Save on event is ON, write /join to join on event.", plr, 255, 255, 255, true)
	else
		Event = false
		outputChatBox("Saves are OFF.", plr, 255, 255, 255, true)
	end
end
addCommandHandler("event_saves", Event_start)

addCommandHandler("event_create",
	function(plr, _, t2, t1, value, ...)
		if not t2 or not t1 or not tonumber(value) then
			outputChatBox("Correct CMD is /event_create <event name> <the number of players>", plr, 255, 255, 255)
        end	
		local name_event = table.concat({t2})
		local value = table.concat({t1})
		if tonumber(value) < 8 then 
			outputChatBox("You write too small number of players !", plr, 255, 255, 255)
			return 
		end
		if tonumber(value) > 64 then 
			outputChatBox("You write too big number of players !", plr, 255, 255, 255)
			return 
		end
		if tonumber(value) > 0 then 
			local name = getPlayerName(plr)
			outputChatBox("Administrator: #008000"..name.." #FFFFFFinvite on event #008000"..name_event.."#FFFFFF , free places: #0080000/"..value.."", getRootElement(), 255, 255, 255, true)
			return 
		end
	end
)

function Join_event(plr, cmd, t1, value)
	if not Event then return end
	local value = table.concat({t1})
	if getElementData(plr, "player:event") then
		outputChatBox("You are in event!", plr, 255, 255, 255, true)
		return 
	end
	if playersCount >= value then 
		outputChatBox("The event is have maximum number of players.", getRootElement(), 255, 255, 255, true)
		return 
	end
	setElementData(plr, "player:event", true)
	playersCount = (playersCount or 0) + 1
	setElementPosition(plr, -2422.37842, -607.25677, 132.56250)
	outputChatBox("W E L C O M E   on the event !", plr, 255, 255, 255, true)
end
addCommandHandler("join", Join_event)


function lols(plr)
	setElementData(plr, "player:event", false)
end
addCommandHandler("s", lols)

 

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