RemoveAccount: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 15: Line 15:


==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
This example does...
This example does...
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onCmdRemove(playerSource,commandName,playerName)
function onCmdRemove ( playerSource, commandName, playerName )
-- Lets make sure they didn't put nothing for the playername
-- Lets make sure they didn't put nothing for the playername
if playerName ~= nil then
if playerName ~= nil then
-- Lets get the player from the nick provided
-- Lets get the player from the nick provided
local targetPlayer = getPlayerFromNick(playerName)
local targetPlayer = getPlayerFromNick ( playerName )
-- Checking if the player actually exists
-- Checking if the player actually exists
if targetPlayer ~= nil then
if targetPlayer ~= nil then
-- grab the accounts
-- grab the accounts
local sourceAccount = getClientAccount(playerSource)
local sourceAccount = getClientAccount ( playerSource )
local targetAccount = getClientAccount(targetPlayer)
local targetAccount = getClientAccount ( targetPlayer )
-- Now check to see if the player has greater priviledges (or levels)
-- Now check to see if the player has greater priviledges (or levels)
if getAccountLevel(sourceAccount) > getAccountLevel(targetAccount) then
if getAccountLevel ( sourceAccount ) > getAccountLevel ( targetAccount ) then
removeAccount(targetAccount)
removeAccount ( targetAccount )
outputChatBox(getPlayerName(playerSource).." removed "..playerName.."'s account")
outputChatBox ( getPlayerName ( playerSource ) .. " removed " .. playerName .. "'s account" )
else outputChatBox("You don't have authority to remove "..playerName.."'s account",playerSource) end
else  
else outputChatBox("There is no player by the name of "..playerName,playerSource) end
outputChatBox ( "You don't have authority to remove " .. playerName .. "'s account", playerSource )
else outputChatBox("USAGE: /remove [playername]",playerSource) end
end
else
outputChatBox ( "There is no player by the name of " .. playerName, playerSource )
end
else
outputChatBox ( "USAGE: /remove [playername]", playerSource )
end
end
end



Revision as of 12:27, 27 August 2009

This function is used to delete existing player accounts.

Syntax

bool removeAccount ( account theAccount )

Required Arguments

  • theAccount: The account you wish to remove

Returns

Returns true if account was successfully removed, false if the account does not exist.

Example

This example does...

function onCmdRemove ( playerSource, commandName, playerName )
	-- Lets make sure they didn't put nothing for the playername
	if playerName ~= nil then
		-- Lets get the player from the nick provided
		local targetPlayer = getPlayerFromNick ( playerName )
		-- Checking if the player actually exists
		if targetPlayer ~= nil then
			-- grab the accounts
			local sourceAccount = getClientAccount ( playerSource )
			local targetAccount = getClientAccount ( targetPlayer )
			-- Now check to see if the player has greater priviledges (or levels)
			if getAccountLevel ( sourceAccount ) > getAccountLevel ( targetAccount ) then
				removeAccount ( targetAccount )
				outputChatBox ( getPlayerName ( playerSource ) .. " removed " .. playerName .. "'s account" )
			else 
				outputChatBox ( "You don't have authority to remove " .. playerName .. "'s account", playerSource )
			end
		else
			outputChatBox ( "There is no player by the name of " .. playerName, playerSource )
		end
	else
		outputChatBox ( "USAGE: /remove [playername]", playerSource )
	end
end

addCommandHandler("remove",onCmdRemove)

See Also