Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local options =
- {
- -- print to console
- console = true,
- -- say in party chat
- partychat = true,
- -- print only votes in your team
- onlymyteam = true,
- };
- local function Log( text )
- if( options.console ) then
- print( "[lbox] " .. text );
- end
- if( options.partychat ) then
- client.Command( "say_party \"" .. text .. "\"", true );
- end
- end
- local function FireGameEvent( event )
- if( event:GetName( ) ~= "vote_cast" ) then return end;
- -- https://wiki.alliedmods.net/Tf2_voting#vote_cast
- local player = entities.GetByIndex( event:GetInt( "entityid" ) );
- if( player == nil ) then return end;
- local me = entities.GetLocalPlayer( );
- if( me == nil or me == player ) then return end;
- if( options.onlymyteam ) then
- if( me:GetTeamNumber( ) ~= player:GetTeamNumber( ) ) then
- return;
- end
- end
- -- 0 = F1, 1 = F2
- local option = event:GetInt( "vote_option" );
- if( option == 0 ) then
- option = "F1";
- else
- option = "F2";
- end
- local playerinfo = client.GetPlayerInfo( player:GetIndex( ) );
- if( playerinfo == nil ) then return end;
- local playername = playerinfo.Name;
- local steamid = playerinfo.SteamID;
- Log( playername .. " " .. steamid .. " pressed " .. option );
- end
- client.AllowListener( "vote_cast" );
- callbacks.Unregister( "FireGameEvent", "votelogger_FireGameEvent" );
- callbacks.Register( "FireGameEvent", "votelogger_FireGameEvent", FireGameEvent );
Add Comment
Please, Sign In to add comment