• Some problems with a gamemode
    10 replies, posted
Hello, I'm creating a gamemode (Oh and I'm deriving sandbox) for a friend and I've encountered two errors which I don't understand: 1.[FIXED] When muting a player (preventing them from typing) it stops me spawning npcs with the following error, even if I un-mute them: [gamemodes\sandbox\gamemode\commands.lua:281] attempt to call field 'Get' (a nil value) The code that I used to mute a player is as thus: (PlayerExist just verifies if they are on the server, which works fine) --- The command--- [lua]function mute (ply, command, args) if (ply:IsAdmin() or ply:IsSuperAdmin()) then playerExist(ply, args[1]) if (found[1] ==1) then ply.muted = found[2] list = player.GetAll() for k, v in pairs (list) do v:PrintMessage ( HUD_PRINTTALK, found[2]:Nick() .. " has been muted") end else ply:PrintMessage( HUD_PRINTTALK, "Player Not found") end end end concommand.Add("mute",mute)[/lua] --- the hook -- [lua] function muted (ply, text, team) --PROBLEM if (ply.muted == ply) then print ("MUTED") if SERVER then return false end end end hook.Add("PlayerSay", "muted", muted) [/lua] According to the wiki and other gamemodes this should work, but I must be missing something. 2. I'm trying to implement a script to slow down the player if they sprint too long (stamina bar) and no matter how I try to code it their speed never decreases: --- cl.init--- [lua] if (StaminaVal <0.1) then RunConsoleCommand ("awbdh5w4wt5gsrteyqqw3464756w43ege5y453256",1) elseif (StaminaVal > 0.2 ) then RunConsoleCommand ("awbdh5w4wt5gsrteyqqw3464756w43ege5y453256",0) end [/lua] ---init.lua--- [lua] function slooooow (ply) print (player.slow) if (player.slow == 1.00) then ply:SetRunSpeed(200) end if (player.slow == 0.00) then ply:SetRunSpeed(400) end end hook.Add("PlayerFootstep", "slow", slooooow) function initSlow (ply, command, args) player.slow = args[1] end concommand.Add("awbdh5w4wt5gsrteyqqw3464756w43ege5y453256",initSlow) [/lua] Additionally I've tried setting up a shared file that is included by both cl.init and init so that I can share a variable between them but to no success, if there is a easy way to share variables securely without having to rely on concommand it'd be appreciated. 3. I have also got an issue with animations, is there a quick fix for player models as from what I'm told NPC animations simply T pose when put onto players, yet I see servers get away with this without the individual models being re-rigged? 4.[FIXED] (Sorry for the recent edits keep thinking of ideas I needed to fix since the FP email verification system was borked) I also can't recall where to find a fix so that while in noclip you can't be shot or harmed in any way, ideally I don't want to use a temporary god mode as they will still stop bullets or so forth, currently for noclip I have: (the model is just an invisible player model) [lua] function Nonoclip (ply) if (ply:IsAdmin() or ply:IsSuperAdmin()) then if (ply:GetMoveType() == MOVETYPE_WALK) then ply.HoldModel = ply:GetModel() ply:SetModel("models/player/invisible.mdl") -- also need to make viewing titles invisible as well later end if (ply:GetMoveType() == MOVETYPE_NOCLIP) then ply:SetModel(ply.HoldModel) -- vice versa to above commnemt end return true else return false end end hook.Add("PlayerNoClip","Nonoclip",Nonoclip) [/lua] 5. If I want to create my own scoreboard, is it derma related and what hooks will I need to use to overwrite the standard one (or do I block the standard one and just somehow bind the standard key to this)?
For your first question, on line 6 of the code snippet you posted you are overriding the list library, this is causing other scripts that use the list library to break.
Ah, thanks I'll edit that and try it out later. Also a friend suggested a fix for the noclip: [lua] function Nonoclip (ply) if (ply:IsAdmin() or ply:IsSuperAdmin()) then if (ply:GetMoveType() == MOVETYPE_WALK) then ply.HoldModel = ply:GetModel() ply:SetModel("models/player/invisible.mdl") ply:SetNotSolid(true) ply:GodEnable() -- also need to make viewing titles invisible as well later end if (ply:GetMoveType() == MOVETYPE_NOCLIP) then ply:SetModel(ply.HoldModel) ply:SetNotSolid(false) ply:GodDisable() -- vice versa to above commnemt end return true else return false end end hook.Add("PlayerNoClip","Nonoclip",Nonoclip) [/lua] I haven't tested it as of yet.
Make the list variable local.
I decided to use a different name just encase I accidently remove local or so forth (I also made it local as well)
Sorry to bump, but some issues are still present and if you use gmatch does it just use regular expression?
[QUOTE=Melonstrike;27497266]Sorry to bump, but some issues are still present and if you use gmatch does it just use regular expression?[/QUOTE] Yes it does. Well, it uses pattern matching quite similar to regular expression.
Thanks, guess learning regular expressions won't be wasted after all :)
Any idea on how to create the icons in the QMenu for entities (entity/entity)? (Also, still need help with problems 2,3 and 5 in the OP)
^ = SpawnIcon Also, clients can see what console commands you run on them. [b][url=http://wiki.garrysmod.com/?title=Usermessage.Hook]Usermessage.Hook [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
SpawnIcons are not what I'm looking for that's for derma and I need it for the standard gmod Q menu entity section.
Sorry, you need to Log In to post a reply to this thread.