Jump to content

commandName i need the function


CITMartin

Recommended Posts

Greetings, i am making a new script to chatBox, but i have some problem making a script to binds with my new chatBox.

 

The user when want make the bind (example: /bind 4 drawLineInScreen colorR colorG colorB) i take the string drawLineInScreen, but when i want make te bind using bindKey, there are 2 options.

option 1

bool bindKey ( player thePlayer, string key, string keyState, function handlerFunction,  [ var arguments, ... ] )

option 2

bool bindKey ( player thePlayer, string key, string keyState, string commandName, [ string arguments ] )

 

In option 1 i can add 1 or more arguments, in option 2 i can add 1 only argument.

 

The data than i have is the commandName,

 

I need the function to my commandName and i can use very arguments with the option 1.

 

PLS HELP ME.

 

Link to comment
addEventHandler("onPlayerLogin",getRootElement(),
function ()
bindKey(source,"i","down","chatbox","command")
end)
 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function ()
for index, player in pairs(getElementsByType("player")) do
		bindKey(player,"i","down","chatbox","command")
  end
end)

i do not understand what you want perfect

Link to comment

use table.concat to use ...*n of arguments that you need in the command ..

EX : 

function setNameOfTeam(thePlayer, cmdName, teamNumber, ... )
  local playerAccount = getPlayerAccount(thePlayer)
local playerAccName = getAccountName(playerAccount)

	if isObjectInACLGroup ("user."..playerAccName, aclGetGroup("Admin") ) then
		if teamNumber == "1" then
		homeName = table.concat( {...}, " " )
			setTeamName ( team[1], homeName )
		triggerClientEvent(thePlayer, "updateNameS1", getRootElement(), homeName )

			outputChatBox ("You have successfully changed the team name to ".. homeName, thePlayer)
		elseif  teamNumber == "2" then
		enemyName = table.concat( {...}, " " )
			setTeamName ( team[2], enemyName )
		triggerClientEvent(thePlayer, "updateNameS2", getRootElement(), enemyName )

			outputChatBox ("You have successfully changed the team name to ".. enemyName, thePlayer)
		end
	else
	outputChatBox("You don't have rights !", thePlayer)

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