[QUOTE=lawlavex;36994833]Here's the full code
[CODE]hook.Add("Think", "spacebar", jump)
if LocalPlayer():KeyDown(IN_JUMP) then
LocalPlayer():PrintMessage(HUD_PRINTCENTER, 'You Jumped')
end
end[/CODE][/QUOTE]
[CODE]
local function SayYouJumped( ply, key )
if key == IN_JUMP then
ply:PrintMessage( HUD_PRINTCENTER, "You jumped!" )
end
end
hook.Add( "KeyPress", "SayYouJumped", SayYouJumped )
[/CODE]
[QUOTE=randomscript;36994998][CODE]
local function SayYouJumped( ply, key )
if key == IN_JUMP then
ply:PrintMessage( HUD_PRINTCENTER, "You jumped!" )
end
end
hook.Add( "KeyPress", "SayYouJumped", SayYouJumped )
[/CODE][/QUOTE]
That got rid of the errors, but nothing happened again.
[QUOTE=brandonj4;36994479]You could message them with LocalPlayer():ChatPrint('You jumped!').
Add a Think hook aswell or a timer.
Think:
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2902.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2902.html[/URL]
Timer.Create:
[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9643.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index9643.html[/URL]
Actually it's:
LocalPlayer():PrintMessage(HUD_PRINTCENTER, 'You jumped!')[/QUOTE]
Or...
GM:KeyPress( Player player, (IN_KEYS) key )
[editline]29th July 2012[/editline]
Ninja'd.
[editline]29th July 2012[/editline]
Damn, no wonder. The rest of the page didn't load.
I've been trying to edit the TTT scoreboard to make my name change colors. I don't know what's wrong. Here's the sb_row.lua code:
[lua]local flashingTable = {};
hook.Add("Tick", "ChangingColor", function()
local glow = math.abs(math.sin(CurTime() * 2) * 255);
flashingTable[1] = Color(glow, 0, 0, 255);
flashingTable[2] = Color(0, glow, 0, 255);
flashingTable[3] = Color(0, 0, glow, 255);
hook.Call("TTTScoreboardColorForPlayer", GAMEMODE, ply)
/*local flashingRed = Color(glow, 0, 0, 255);
local flashingGreen = Color(0, glow, 0);
local flashingBlue = Color(0, 0, glow);*/
end)
local namecolor = {
default = COLOR_WHITE,
admin = Color(220, 180, 0, 255),
dev = flashingTable[math.random(3)];
};
function GM:TTTScoreboardColorForPlayer(ply)
if not IsValid(ply) then return namecolor.default end
if ply:SteamID() == "STEAM_0:0:27335599" then
return namecolor.dev
elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.admin
else
return namecolor.default
end
end[/lua]
It give me the error: TTTScoreboardColorForPlayer hook returned something that isn't a color!
Here's the code that has to do with that error:
[lua]local function ColorForPlayer(ply)
if IsValid(ply) then
local c = hook.Call("TTTScoreboardColorForPlayer", GAMEMODE, ply)
-- verify that we got a proper color
if c and type(c) == "table" and c.r and c.b and c.g and c.a then
return c
else
ErrorNoHalt("TTTScoreboardColorForPlayer hook returned something that isn't a color!\n")
end
end
return namecolor.default
end[/lua]
I know nothing about Lua, so if anyone could help with this, I'm out of ideas. I've pretty much been getting help from a friend with this, and I don't think he really wants to help anymore. Any help you can give is greatly appreciated. Thanks.
Oh yeah, and all credit goes to Mr. Cee and InfernalCookie for the code.
I remember writing that flashing color snippet.
Anyways, where is COLOR_WHITE defined?
[editline]29th July 2012[/editline]
Now that I think of it, it might be because the indexes for flashingTable until a player actually joins. That means you're storing nil for the dev color.
[QUOTE=Chessnut;36996596]I remember writing that flashing color snippet.
Anyways, where is COLOR_WHITE defined?[/QUOTE]
Ah, I thought InfernalCookie did. My bad. I'll try to find where COLOR_WHITE is. But uhh... did you ever figure out how to make it work?
Just replace COLOR_WHITE with Color(255, 255, 255, 255). No big deal. If it's complaining it isn't getting a color then I'd pin it on either COLOR_WHITE being undefined or TTTScoreboardColorForPlayer calling namecolor.dev (flashingTable[1, 2, or 3]) before Tick runs so flashingTable[1, 2, and 3] are all undefined.
Anyone know a quicker way to reload a GWEN skins .png than restarting the entire game?
[QUOTE=Drakehawke;36997267]Anyone know a quicker way to reload a GWEN skins .png than restarting the entire game?[/QUOTE]
You could try:
[lua]
include "skins/default.lua"
[/lua]
This has most likely been posted/answered before, but can anyone spare a script to re-create all the removed fonts in GM13? I've heard before the font files are still there, but they're no longer being created. Not sure of the actual file names or the proper sizes.
IF YOUR GETTING AN ERROR IN YOUR FILE SYSTEM, MAKE NOTE IF IT IS GMOD13 DO TO DIRECTORY REFERENCE
"string expected, got no value" ~ fixed example
[CODE]
local Money_StartAmount = 1
function GM:PlayerInitialSpawn( ply )
ply:SetModel("models/heroes/vengeful/vengeful.mdl")
ply:ConCommand("BeginSounds")
if file.Exists( "owl_" .. ply:UniqueID() .. ".txt", "DATA" ) then
ply:ChatPrint("Welcome Back! Your Owls Have Been Loaded; Keep Them Safe!")
local money = file.Read( "owl_" .. ply:UniqueID() .. ".txt", "DATA" )
ply:ChatPrint("You Have A Balance Of " .. money .. " Owls")
else
ply:ChatPrint("Welcome New Player! Here's An Owl!")
for _, people in pairs(player.GetAll()) do
if people != ply then
people:ChatPrint( ply:Nick() .. " Got His First Owl! . . . that poor thing!")
end
end
end
[/CODE]
[QUOTE=Watercycle;37006204][CODE]Money_StartAmount = 50
-snip-
[/QUOTE]
Are you using gmod13? because the file. library changed.
[QUOTE=Stillnex;37006793]Are you using gmod13? because the file. library changed.[/QUOTE]
i am, oh dear how do i work with the new then?
... scratch that found it [URL]https://docs.google.com/document/d/1khSuIYrAMkqXu7wlH5YRJNwz6hOH6Xqi5lqBhE3x6gA/edit[/URL]
thank you =)
In theory, assuming I don't need to exchange variables between files, if I were to do this:
[CODE]local newg = getfenv(0)
setfenv(1, newg)[/CODE]
Would it eliminate the need for typing 'local' before all of my variables to keep them localized inside a file, and if not, how would I do this?
fixed, snipped
How would I go about setting the size of some spawn icons in a menu?
I've tried looking at other scripts that use SetIconSize, But I get the error:
[lua]attempt to call method 'SetIconSize' (a nil value)[/lua]
[QUOTE=Coffeee;37009914]How would I go about setting the size of some spawn icons in a menu?
I've tried looking at other scripts that use SetIconSize, But I get the error:
[lua]attempt to call method 'SetIconSize' (a nil value)[/lua][/QUOTE]
spawnIcon:SetSize(32, 32);
Is there a way to get the output of a concommand? Everything seems to return nil.
[QUOTE=Agent766;37013627]Is there a way to get the output of a concommand? Everything seems to return nil.[/QUOTE]
Isn't the output of the concommand what you define it to do in your script?
If you mean the output of source commands then I don't think it's possible.
If I had 4 items and each had a percent chance of getting picked. e.g. 40%, 30%, 10%, 20% - What is the math to get the winner?
Something like this.
[lua]
function pickWeightedRandom(entries)
local total = 0
for k,v in pairs(entries) do
total = total+v.chance
end
local threshold = math.random(total)
while true do
local entry = table.remove(entries,math.random(#entries))
threshold = threshold-entry.chance
if (threshold <= 0) then
return entry.value
end
end
end
[/lua]
So, I've got a few DCollapsiveCategories, but I only want 1 expanded each time, tho I can't seem to figure it out. Any clue?
[QUOTE=Persious;37035103]So, I've got a few DCollapsiveCategories, but I only want 1 expanded each time, tho I can't seem to figure it out. Any clue?[/QUOTE]
Put them into a table named Collaps, then have this code run after they are made.
[lua]
for k,v in pairs(Collaps) do
v.Header.OnMousePressed = function(mcode)
for c,d in pairs (self.Collaps) do
if d:GetExpanded() == true then d:Toggle() end
end
self:Toggle()
end
end
[/lua]
Aha, thank you!
[editline]1st August 2012[/editline]
[gamemodes\messingaround\gamemode\base\client\main_menu.lua:61] attempt to index global 'self' (a nil value)
[QUOTE=Persious;37035203]Aha, thank you!
[editline]1st August 2012[/editline]
[gamemodes\messingaround\gamemode\base\client\main_menu.lua:61] attempt to index global 'self' (a nil value)[/QUOTE]
Replace self with v, sorry.
Oh yeah, exactly. Thank you ;)
[lua]
[skyrp\gamemode\shared.lua:17] attempt to call method 'GetUserGroup' (a nil value)(Hook: PlayerNoClip)
[/lua]
Here is the code:
[lua]
function GM:PlayerNoClip( ply )
if ply:GetUserGroup() == "owner" or ply:GetUserGroup() == "superadmin" then
return true
else
return false
end
end
[/lua]
I don't see what i'm doing wrong, there are no errors in console when i start the server. And it worked perfectly before new update.
Sorry, you need to Log In to post a reply to this thread.