ToS API

This forum is for any general discussions related to Hook64.

Moderators: Developers, Moderators

Pluttotiki
Newbie
Posts: 10
Joined: 10:02 am, Sun Aug 07, 2016

ToS API

Postby Pluttotiki » 3:26 pm, Mon Aug 08, 2016

hello guys!
for example i took this code:

Code: Select all

local acutil = require("acutil");
	local frame = ui.GetFrame("minimap");
	local btnsize = 30;
	local nextbutton = frame:CreateOrGetControl('button', "nextbutton", 15+34, 18, btnsize, btnsize);
	tolua.cast(nextbutton, "ui::CButton");
	nextbutton:SetText("{s22}>");
	nextbutton:SetEventScript(ui.LBUTTONUP, "CHSURF_CHANGE_CHANNEL(1)");
	nextbutton:SetClickSound('button_click_big');
	nextbutton:SetOverSound('button_over');

	local prevbutton = frame:CreateOrGetControl('button', "prevbutton", 15, 18, btnsize, btnsize);
	tolua.cast(prevbutton, "ui::CButton");
	prevbutton:SetText("{s22}<");
	prevbutton:SetEventScript(ui.LBUTTONUP, "CHSURF_CHANGE_CHANNEL(-1)");


local settings = {	maxNumberOfChannelsToShow = 30;};

function CHANNELSURFER_ON_INIT(addon, frame)
	addon:RegisterMsg('GAME_START', 'CHSURF_CREATE_BUTTONS');

	acutil.setupHook(SELECT_ZONE_MOVE_CHANNEL_HOOKED, "SELECT_ZONE_MOVE_CHANNEL");
	acutil.setupHook(POPUP_CHANNEL_LIST_HOOKED, "POPUP_CHANNEL_LIST");
end

function SELECT_ZONE_MOVE_CHANNEL_HOOKED(index, channelID)
	local mapName = session.GetMapName();
	local mapCls = GetClass("Map", mapName);
	local zoneInsts = session.serverState.GetMap(mapCls.ClassID);
	if zoneInsts.pcCount == -1 then
		ui.SysMsg(ClMsg("ChannelIsClosed"));
		return;
	end

	app.ChangeChannel(channelID);
end

function POPUP_CHANNEL_LIST_HOOKED(parent)
    if parent:GetUserValue("ISOPENDROPCHANNELLIST") == "YES" then
        parent:SetUserValue("ISOPENDROPCHANNELLIST", "NO");
        return;
    end

    parent:SetUserValue("ISOPENDROPCHANNELLIST", "YES");

    local frame = parent:GetTopParentFrame();
    local ctrl = frame:GetChild("btn");
    local curchannel = frame:GetChild("curchannel");
    local mapName = session.GetMapName();
    local mapCls = GetClass("Map", mapName);

    local channel = session.loginInfo.GetChannel();

	local zoneInsts = session.serverState.GetMap(mapCls.ClassID);

	local NUMBER_OF_CHANNELS = zoneInsts:GetZoneInstCount();
	local numberOfChannelsToShow = NUMBER_OF_CHANNELS;

	if numberOfChannelsToShow >= settings.maxNumberOfChannelsToShow then
		numberOfChannelsToShow = settings.maxNumberOfChannelsToShow;
	end

    local dropListFrame = ui.MakeDropListFrame(ctrl, -270, 0, 300, 600, numberOfChannelsToShow, ui.LEFT, "SELECT_ZONE_MOVE_CHANNEL");

    if zoneInsts == nil then
        app.RequestChannelTraffics(mapCls.ClassID);
    else
        if zoneInsts:NeedToCheckUpdate() == true then
            app.RequestChannelTraffics(mapCls.ClassID);
        end

        for i = 0, NUMBER_OF_CHANNELS - 1 do
            local zoneInst = zoneInsts:GetZoneInstByIndex(i);
            local str, gaugeString = GET_CHANNEL_STRING(zoneInst);
            ui.AddDropListItem(str, gaugeString, zoneInst.channel);
        end
    end
end

function CHSURF_CHANGE_CHANNEL(nextChannel)
	local mapName = session.GetMapName()
	local mapCls = GetClass("Map", mapName);
	local zoneInsts = session.serverState.GetMap(mapCls.ClassID);
	local numberOfChannels = zoneInsts:GetZoneInstCount();
	local currentChannel = session.loginInfo.GetChannel();
	nextChannel = (1 + nextChannel + currentChannel) % numberOfChannels;
	if nextChannel == 0 then
		nextChannel = numberOfChannels;
	end
	SELECT_ZONE_MOVE_CHANNEL_HOOKED(0, nextChannel-1);
end
this is a channelsurfer lua.
i tried to look around to find ToS API but i couldn't find it
for example i want to change the command app.ChangeChannel(channelID); to ChangeMap - but i dont know what vaule it needs and etc etc...
or for example i want the code to use the /warp code of hook64 -> how the code line will look like?

Thanks.

Return to “General”

Who is online

Users browsing this forum: No registered users and 7 guests

Powered by phpBB® Forum Software © phpBB Limited
EULA & Privacy Policy
 

 

cron