Hello my fellow g-tards out there...
I am working on a gameMODe called "AIDS-Mod". [I know this is a serious treat to many, begging you pardon, it is NOT meant to offend anyone!!]
I wanted to derive it from Fretta, but the VoteForChange menu wont show up. (f1/f2/f3/f4 wont do anything)
I tried starting via Fretta as overwrite, or directly; Deriving from Fretta or base; and I got two results when pressing F1:
- LUA error: [XXXX.lua]: attempt to call global 'ShowHelp' (a nil value) <-- Some like duh'
- Original GMOD Help (that flash-video-tutorial thingi)
When I derive from sandbox, neither 'C' nor 'Q' will bring up any menus, from which I conclude Deriving fails.
In both cases the console reads
[CODE]registering gamemode fretta/sandbox derived from base
registering gamemode aidsmod derived from fretta/sandbox
CONSOLE SOMEWHAT IS DISABLED
registering gamemode aidsmod derived from base[/CODE]
after a "gamemode_reload".
I even commented out all my custom code, same result.
My Files:
gamemodes/aidsmod/gamemode/init.lua
[CODE]--SERVERSIDE--
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_hud.lua" )
include( "shared.lua" )
function CheckRoundEnd()
if ( !GAMEMODE:InRound() ) then return end
for k,v in pairs( team.GetPlayers( TEAM_HUMAN ) ) do
if v:Frags() >= 10 then
GM.RoundEndWithResult(ply, ply:GetName() .. " wins!")
end
end
end
function EntityTakeDamage( ent, inflictor, attacker, amount )
if ent:GetClass() == "entity_aids" and inflictor:GetClass() == "weapon_aidsbar" then
if attacker:GetNWBool( "HasAids" ) then
attacker:PrintMessage( HUD_PRINTCENTER, "You gave your aids to " .. ent:GetOwner():GetName() )
ent:GetOwner():PrintMessage( HUD_PRINTCENTER, "You were infected by " .. attacker:GetName() )
UnInfect( attacker )
Infect( ent:GetOwner() )
end
end
end
function OnRoundStart()
for k,v in pairs( player.GetAll() ) do
self:UnInfect( ply )
end
NewAids()
end
function GM:PlayerDeath( ply, inflictor, attacker )
if ply:GetNWBool( "HasAids" ) then
attacker:AddFrags(2)
NewAids()
end
end
function PlayerDisconnected( ply )
if ply:GetNWBool( "HasAids" ) then
NewAids()
end
end
function PlayerInitialSpawn( ply )
ply:SetNWInt( "AidsTime", 20 )
local ent=ents.Create( "entity_aids" )
Msg( "SPAWN ENTITY" )
ent:SetPos( ply:GetPos() + Vector( 0,0,132 ) )
ent:SetOwner( ply )
ent:SetParent( ply )
ent:Spawn()
return true
end
function PlayerShouldTakeDamage( victim, ply )
if ply:IsPlayer() then
if victim:GetNWInt( "AidsTime" ) != 0 then
return false
end
end
return true
end
local secondtick = 0
function Think()
if ( CurTime() >= secondtick ) then
for k,v in pairs( player.GetAll() ) do
if v:GetNWBool( "HasAids" ) then
if v:GetNWInt( "AidsTime" ) == 1 then
v:PrintMessage( HUD_PRINTCENTER, "You can now be hurt!" )
v.Trail = util.SpriteTrail(v, 0, Color(255,0,0), false, 15, 1, 3, 1/(15+1)*0.5, "trails/plasma.vmt")
end
if v:GetNWInt( "AidsTime" ) != 0 then
v:SetNWInt( "AidsTime", v:GetNWBool( "AidsTime" ) - 1 )
end
end
end
secondtick = CurTime() + 1
end
end
hook.Add( "CheckRoundEnd", "ACheckRoundEnd", CheckRoundEnd )
hook.Add( "EntityTakeDamage", "AEntityTakeDamage", EntityTakeDamage )
hook.Add( "OnRoundStart", "AOnRoundStart", OnRoundStart )
hook.Add( "PlayerDeath", "APlayerDeath", PlayerDeath )
hook.Add( "PlayerDisconnected", "APlayerDisconnected", PlayerDisconnected )
hook.Add( "PlayerInitialSpawn", "APlayerInitialSpawn", PlayerInitialSpawn )
hook.Add( "PlayerShouldTakeDamage", "APlayerShouldTakeDamage", PlayerShouldTakeDamage )
hook.Add( "Think", "AThink", Think )
---------
function NewAids()
players = player.GetAll()
aidzor = players[ math.random( #players ) ]
aidzor:PrintMessage( HUD_PRINTCENTER, "You were infected with aids!" )
Infect( aidzor )
end
function Infect( ply )
ply:SetNWBool( "HasAids", true )
end
function UnInfect( ply )
SafeRemoveEntity( ply.Trail )
ply:SetNWBool( "HasAids", false )
ply:SetNWInt( "AidsTime", 20 )
end[/CODE]
gamemodes/aidsmod/gamemode/shared.lua
[CODE]GM.Name = "AIDS-Gamemode"
GM.Author = "[W33D|] S0lll0s"
GM.Email = "SMOArena@gmx.de"
GM.Website = "w33d-clan.cwsurf.de"
GM.Help = "People with aids try to infect others,\n and get miraculosely healed when they transfer the Virus.\n Dafuq?"
DeriveGamemode( "fretta" )
IncludePlayerClasses()
GM.Data = {}
function GM:Initialize()
self.BaseClass.Initialize( self )
end
GM.TeamBased = false
GM.AllowAutoTeam = true
GM.AllowSpectating = true
GM.SecondsBetweenTeamSwitches = 10
GM.GameLength = 15
GM.RoundLimit = 10
GM.VotingDelay = 10
GM.NoPlayerSuicide = false
GM.NoPlayerDamage = false
GM.NoPlayerSelfDamage = false
GM.NoPlayerTeamDamage = false
GM.NoPlayerPlayerDamage = false
GM.NoNonPlayerPlayerDamage = false
GM.NoPlayerFootsteps = false
GM.PlayerCanNoClip = false
GM.TakeFragOnSuicide = true[/CODE]
gamemodes/aidsmod/gamemode/cl_init.lua
[CODE]--CLIENTSIDE--
include( "cl_hud.lua" )[/CODE]
gamemodes/aidsmod/gamemode/cl_hud.lua
[CODE]--CLIENT HUD EXTENSION--
client = client or LocalPlayer()
local function HUDPaint()
draw.SimpleText( "3.2.1 TESTING" , "ScoreboardText", 100, 60, Color( 86, 104, 86, 255 ), 0, 0 )
draw.SimpleText( client:GetNWInt( "AidsTime" ) , "ScoreboardText", 100, 50, Color( 86, 104, 86, 255 ), 0, 0 )
end
hook.Add( "HUDPaint", "PaintOurHud", HUDPaint )[/CODE]
also the entities "entity_aids" (infact a red bathtub for testing) and the "weapon_aidsbar" (modified standard crowbar SWEP).
gamemodes/aidsmod/entities/entities/entity_aids/init.lua
[CODE]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:Initialize()
self.Entity:SetModel( "models/props_interiors/BathTub01a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_FLY )
self.Entity:SetSolid( SOLID_VPHYSICS )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
end
end
function ENT:Use( activator, caller )
activator:ChatPrint( "AIDS'D" )
end
function ENT:Think()
self.R = self.R or 0; -- if R is nil, make it 0
if( self.R >= 255 ) then
self.R = 0; -- reset R if it's over 255
end
self:SetColor( self.R, 0, 0, 255 ); -- actually set the color
self.R = self.R + 1; -- increment R
end[/CODE]
gamemodes/aidsmod/entities/entities/entity_aids/shared.lua
[CODE]ENT.Type = "anim"
ENT.Base = "base_entity"
ENT.PrintName = "Lua Test"
ENT.Author = "Ich"
ENT.Contact = "Ne."
ENT.Category = "Lua Beispiele"
ENT.Purpose = "Beispiel SEnt"
ENT.Instructions = "Benutzen auf eigene Gefahr, nicht während Wintersaison benutzen, nicht in kleinen Räumen verwenden."
ENT.Spawnable = true
ENT.AdminSpawnable = true[/CODE]
gamemodes/aidsmod/entities/entities/entity_aids/cl_init.lua
[CODE]include('shared.lua')
function ENT:Draw()
self.Entity:DrawModel()
end[/CODE]
I hope you can help me!
Try moving the DeriveGamemode line to the top of shared.lua.
By the way, if you're making a gamemode, don't use hook.Add().
You should only use it when coding addons that need to override the gamemode.
Use the GM functions instead.
[lua]
hook.Add("HUDPaint", "myHUD", paintFunction);
-- Should be:
function GM:HUDPaint()
-- Your stuff here.
end;
[/lua]
I am stupid. I had it with all the GM:'s and removed them.
/note to self: Make Backups!!
well got them in again.
Also The code above is not quit true in case of the entity_aids:Think() hook, I changed it back again, for it doesnt work like it should (with the code up there).
I'll tell you my experiences with DeriveGamemode() on top of shared.lua in like 5 minutes!
EDIT: Bathub is gone for no reason. Gotta check this out...
WAAAAIT: just found this in my console:
[CODE]Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: aidsmod/gamemode/cl_init.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: aidsmod/gamemode/shared.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: aidsmod/gamemode/cl_hud.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_init.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/shared.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/skin.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/player_class.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/class_default.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_splashscreen.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_selectscreen.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_gmchanger.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_help.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/player_extension.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_hudlayout.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_hudelement.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_hudbase.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_hudcommon.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_gamenotice.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_scoreboard.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_scoreboard_team.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_scoreboard_small.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/vgui/vgui_vote.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_hud.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_deathnotice.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_scores.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/cl_notify.lua
Warning: Calling AddCSLuaFile too late, this file will not be sent to clients: fretta/gamemode/player_colours.lua[/CODE]
Why is it late? It should be called right at the start...
EDIT: Got my bathtub fixed. F1 still gets the error above.
[editline]12th March 2012[/editline]
Could someone please just test how far it works for him?
[url]http://www.mediafire.com/?v02yl9hf0t2fbv6[/url]
To get yoursef aids type "lua_run NewAids()" into the console.
Thank you!
It's being sent too late because you're defining variables before sending the Lua files.
I think it was just due to "gamemode_reload" andnot doing gamemode_reload_cl... lemme test it.
Have you tried my files yourself?
If you did a gamemode_reload that would be why.
Yes I did. Same situation still. Can't find any errors though.
Sorry, you need to Log In to post a reply to this thread.