Jump to content

Urgent help !


Recommended Posts

This is a simple Quiz code.

/createquiz - To create a Quiz.

/answer - To answer the Quiz.

/deletequiz - To delete unanswered Quiz.

 

Server Side code:

theAnswer = nil

function createQuiz(thePlayer, cmd, quiz, answer)
	if theAnswer then
		outputChatBox("You can't create a Quiz. Use /deletequiz first to delete previous Quiz.", thePlayer)
    	return
	end
	if not quiz or not answer then
		outputChatBox("SYNTAX: /"..cmd.." [Question] [Answer]", thePlayer)
		return
	end
	theAnswer = answer
	outputChatBox("QUIZ: "..quiz.."?", root)
	outputChatBox("QUIZ: Use command /answer to answer the quiz.", root)
end
addCommandHandler("createquiz", createQuiz)

function deleteQuiz ()
	if theAnswer then
		theAnswer = nil
		outputChatBox("QUIZ: Quiz has been deleted.", root)
	end
end
addCommandHandler("deletequiz", deleteQuiz)

function answerQuiz (thePlayer, cmd, answer)
	if not theAnswer then
		outputChatBox("QUIZ: There is no Quiz.", thePlayer)
		return
	elseif not answer then
		outputChatBox("SYNTAX: /"..cmd.." [Answer]", thePlayer)
		return
	end
	if answer == theAnswer then
		theAnswer = nil
		outputChatBox("QUIZ: "..getPlayerName(thePlayer).." win the Quiz!", root)
		outputChatBox("QUIZ: The correct answer is \""..answer..".\"", root)
		givePlayerMoney(thePlayer, 200)
	end
end
addCommandHandler("answer", answerQuiz)

 

Edited by idarrr
Server side script
Link to comment
  • 4 months later...
  • Scripting Moderators
1 hour ago, Leonardo Leandro said:

Cody How can I use String.count ?

#str

string.len(str)

utf8.len(str)

 

which one will you choose?

Edited by thisdp
Link to comment
  • Scripting Moderators
48 minutes ago, CodyJ(L) said:

Why wouldn't it, also; utf8.len only returns the length of it, not if the string is within the text.

It is because I didn't understand him. xD

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