SendCustomGameEventToServer Problems

I'm trying to have make a button that returns the ID of the player that presses it and one number, but so far all my attempts resulted in returning either nil or empty tables.

the mode_vote.js file

"use strict";

(function () {

})();


function OnVoteRound() 
{
    var iPlayerID = Players.GetLocalPlayer();

   GameEvents.SendCustomGameEventToServer( "vote_gamemode", { pID: iPlayerID, mode:0 })
}

and in the addon_game_mode.lua

function CAddonTemplateGameMode:InitGameMode()

    CustomGameEventManager:RegisterListener( "vote_gamemode", Dynamic_Wrap(CAddonTemplateGameMode, "RoundVote"))

end


function CAddonTemplateGameMode:RoundVote(eventSourceIndex, data )
    print(eventSourceIndex.pID)
    print(eventSourceIndex.mode)
print(data)
end

And the only result is nil. Please help.

Comments

  • edited April 2016 Posts: 1,670

    Events to server already have the player ID passed through .PlayerID, do a DeepPrintTable of the stuff you are getting

    function CAddonTemplateGameMode:RoundVote(event)
        DeepPrintTable(event)
        print(event.PlayerID)
    end
    

    The concept of Modding Community doesn't go well together with Competitive Business
    My Project Page || My GitHub Profile ||

  • Posts: 29

    Events to server already have the player ID passed through .PlayerID, do a DeepPrintTable of the stuff you are getting

    fantastic,thank you once again