First off, yes Acecool did help me with this. He basically wrote it for me but he explained everything and what not too.
I don't want credit for it I just want it working.
So I have a PointShop Taunt system but I can't get it to work. (I included it in sv_init.lua too)
sh_taunt_system.lua
[code]
//
// Taunt System - Josh 'Acecool' Moser
// addons/acecool/lua/autorun/sh_taunt_system.lua
//
//
// Init
//
TAUNTS = TAUNTS || { };
//
// Taunt Declarations...
//
TAUNT_OH_NO = 0;
TAUNTS[ TAUNT_OH_NO ] = { wav = "vo/npc/male01/ohno.wav", name = "Oh No!" };
[/code]
sv_taunt_system.lua
[code]
//
// Taunt System - Josh 'Acecool' Moser
// addons/acecool/lua/autorun/server/sv_taunt_system.lua
//
// How frequenty the user can taunt...
local TAUNT_SYSTEM_FREQUENCY = 3;
//
// Server Hooks for F1-F4 keys...
//
-- GM:ShowHelp --F1
-- GM:ShowTeam --F2
-- GM:ShowSpare1 --F3
-- GM:ShowSpare2 --F4
//
// ShowTeam is for F2 - Taunt Bind
//
hook.Add( "ShowTeam", "ShowHelp:Taunt", function( _p )
// Player not valid? Unlikely but still a good check
if ( !IsValid( _p ) ) then return; end
// Init Last Played
if ( !_p.__EquippedTauntLastPlayed ) then _p.__EquippedTauntLastPlayed = 0; end
// Check timing, this works well if equipped or not so message doesn't spam...
if ( CurTime( ) - _p.__EquippedTauntLastPlayed > TAUNT_SYSTEM_FREQUENCY ) then
// Update timer...
_p.__EquippedTauntLastPlayed = CurTime( );
// Does the player have a taunt equipped?
local _data = _p.__EquippedTaunt;
if ( _data ) then
// Play it...
_p:EmitSound( _data.wav );
else
// If not, you can notify the player, or not...
_p:PrintMessage( HUD_PRINTTALK, "You do not have any taunts equipped. Buy one from the point-shop or equip it.." );
end
end
end );
[/code]
itemforthepointshop.lua
[code]
//
// - Josh 'Acecool' Moser
//
// Because all files will be the same except for the "name" and taunt. use this.
// Homework; convert this constant repeated code into taunt-system to make taunt definitions easier.
local _taunt = TAUNT_OH_NO;
// Taunt name, cost...
ITEM.Name = 'Oh No!' -- Can be simplified into ITEM.Name = "Taunt: " .. TAUNTS[ _taunt ].name;
ITEM.Price = 5000
ITEM.Material = 'vo/npc/male01/ohno.wav'
//
// What happens when user equips taunt...
//
function ITEM:OnEquip( _p, modifications )
local _data = TAUNTS[ _taunt ];
_p.__EquippedTaunt = _taunt;
_p:PrintMessage( HUD_PRINTTALK, "You just equipped the " .. ( _data.name || "Undefined!" ) .. " taunt!" );
end
//
// Reset to allow different taunt to be equipped
//
function ITEM:OnHolster( ply )
local _data = TAUNTS[ _taunt ];
_p.__EquippedTaunt = nil;
_p:PrintMessage( HUD_PRINTTALK, "You just holstered the " .. ( _data.name || "Undefined!" ) .. " taunt!" );
end
//
// Make sure the user can equip a taunt...
//
function ITEM:CanEquip( _p )
local _equipped = _p.__EquippedTaunt;
local _bIsEquipped = _equipped && _equipped >= 0;
// If user has something already equipped, they can't equip until they un-equip
if ( _bIsEquipped ) then
local _data = TAUNTS[ _taunt ];
_p:PrintMessage( HUD_PRINTTALK, "You already have a taunt equipped, the " .. ( _data.name || "Undefined!" ) .. " taunt!" );
end
// Since we used inverse logic, we need to return the inverse...
// Basically, we CAN EQUIP only if we are not equipped. If we are not equipped ( var is false ) but
// we need it to return true; hence the !...
return !_bIsEquipped;
end
[/code]
Does anyone know why it's broken? ><
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_pointshop_taunt_system/item_taunt_oh_no.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_pointshop_taunt_system/sh_taunt_system.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_pointshop_taunt_system/sv_taunt_system.lua.html[/url]
And "solution" to make it shorter:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_pointshop_taunt_system/sv_taunt_system_simlification_solution.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_pointshop_taunt_system/item_taunt_oh_no_simplification_solution.lua.html[/url]
One of the "errors" the op told me about is that the pointshop is reporting a missing model, meaning ITEM.Model must be set in the item. Pick some model that "taunts" will show up as in the buy-menu.
The second error was the pointshop was loading before the "taunt system", therefore the ids are nil; I told the op to include them before the pointshop ( inside the pointshop addon folder if necessary and set to load first )
The "taunt system" bits need to load before the pointshop otherwise the enum-taunt-ids won't be set in time for the pointshop to know what it means. Also, it hasn't been tested.
Sorry, you need to Log In to post a reply to this thread.