[Help]Police Call
#1
PLUGIN = nil
function Initialize(Plugin)
	Plugin:SetName("AltisLife")
	Plugin:SetVersion(1)
  
  --Loads Plugin Commands
  
	cPluginManager.BindCommand("/alert", "", AlertPol, "- Alert the police")

	-- Hooks
	
	PLUGIN = Plugin -- NOTE: only needed if you want OnDisable() to use GetName() or something like that
	
	-- Command Bindings

	LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
	return true
end
--Sets alarm triggered by AlertPol when the arguments are valid.
function setAlarm(playerName, Message)
  Root:BroadcastChat("CNN News: " ..Message.. "  From: " ..playerName)
end
--Function for Alert Police
function AlertPol(Split, Player)
  if (#Split ~= 2) then
    Player:SendMessageFailure("You\'re Arguments Are Invalid, here\'s the format: /alert \'Message\'")
    return True
  end
  if(#Split ~= 1) then
    playerName = Player:GetName()
    Message = Split[2]
    Player:SendMessageSuccess("Your report has been sent to the police, please hold on")
    --Triggers setAlarm function, go to line 19 for more info
    setAlarm(playerName, Message)
    return True
  end
  
end
function OnDisable()
	LOG(PLUGIN:GetName() .. " is shutting down...")
end

So this is my code for an upcoming Altis Life plugin, which is of course gonna have a different name. I'm waiting for MCServer to be less derpy with ai and stuff, and add minecarts.

Console reports no problems on startup, but when executing /alarm Test...
-{INFO} Your report has been sent to the police, please hold on

-{INFO}Something went wrong while executing command "/alert test'

Then on the console...

[Image: xtcul7J.png]

So, i'm new to LUA programming, so can you guys explain to me in depth what the error is, and how I can prevent it next time? Thanks Smile
EDIT: Yes I did copy the template from the documentation, and snipped off some of the explode example.
Reply
Thanks given by:


Messages In This Thread
[Help]Police Call - by GeekSalt - 09-16-2014, 04:40 PM
RE: [Help]Police Call - by xoft - 09-16-2014, 05:34 PM
RE: [Help]Police Call - by xoft - 09-16-2014, 05:39 PM
RE: [Help]Police Call - by GeekSalt - 09-17-2014, 12:29 AM
RE: [Help]Police Call - by NiLSPACE - 09-17-2014, 12:30 AM
RE: [Help]Police Call - by GeekSalt - 09-17-2014, 12:48 AM



Users browsing this thread: 1 Guest(s)