• Print

Author Topic: message to player who called function  (Read 5721 times)

0 Members and 1 Guest are viewing this topic.

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
message to player who called function
« on: April 02, 2015, 03:29:21 am »
Hello guys,I want to add delay for taunt menu opening.
Problem: player who opened menu = nil
cl_taunts.lua
Code: Lua
  1. local function openTauntMenu(ply)
  2.         if IsValid(menu) then
  3.                 fillCats(menu.CatList, menu.TauntList)
  4.                 fillList(menu.TauntList, menu.CurrentTaunts, menu.CurrentTauntCat)
  5.                 if CurTime() >= cooldown then
  6.                 menu:SetVisible(!menu:IsVisible())
  7.                 cooldown = CurTime() + taunts_cooldown
  8.                 return
  9.                 else
  10.                 ply:PrintMessage(HUD_PRINTTALK, "Stop spam taunts!!! Wait "..math.floor(cooldown-CurTime()).." seconds.")
  11.                 return
  12.                 end
  13.         end
What I need to add in sv_taunts.lua or in shared file to get player, who try to open menu
Code from files https://github.com/mechanicalmind/prophunters/tree/master/gamemode

Offline Livaco

  • Full Member
  • ***
  • Posts: 133
  • Karma: -37
    • Livaco
Re: message to player who called function
« Reply #1 on: April 02, 2015, 04:18:01 am »
Is There Anay Errors In The Consle When You Run It?
Here To Help And Be Happy And Help :)

My Website
My Addons
PermaBanV1.0

Quote from:  Livaco on April 12 at 9:10:20 PM
I May Be Dum But Am Still Better Then The Rest

Livaco Products©

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: message to player who called function
« Reply #2 on: April 02, 2015, 05:31:30 am »
Problem: player who opened menu = nil

Im not sure if this is correct but i don't think you can call ply in cl_ files... you have to define it!

local ply = LocalPlayer()

Try this and ya post the error

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: message to player who called function
« Reply #3 on: April 02, 2015, 07:49:58 am »
Im not sure if this is correct but i don't think you can call ply in cl_ files... you have to define it!

local ply = LocalPlayer()

Try this and ya post the error

good job! thank you!
carma +
one more question: what the best way to play sound at the end of round to All players?Not only in Vector(0,0,0) for example.

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: message to player who called function
« Reply #4 on: April 02, 2015, 08:09:11 am »
This would probably get you the best sound, but it is clientside only.
http://wiki.garrysmod.com/page/surface/PlaySound

Otherwise I would recommend this run on every single player...
http://wiki.garrysmod.com/page/Entity/EmitSound

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: message to player who called function
« Reply #5 on: April 02, 2015, 08:53:57 am »
This would probably get you the best sound, but it is clientside only.
http://wiki.garrysmod.com/page/surface/PlaySound

Otherwise I would recommend this run on every single player...
http://wiki.garrysmod.com/page/Entity/EmitSound
thank you, I am using sv_downloadurl , file with music do not want to dowload from my host repository, what i nedd to do additionally?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: message to player who called function
« Reply #6 on: April 02, 2015, 09:17:50 am »
You would have to run this on the server to force the client to download it.
http://wiki.garrysmod.com/page/resource/AddFile

Offline ZeD

  • Newbie
  • *
  • Posts: 20
  • Karma: 0
Re: message to player who called function
« Reply #7 on: April 02, 2015, 09:47:03 am »
so I need to add new lua script
file_load/lua/autorun/sv_files.lua
and add line resource.AddFile( string path ) in it?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: message to player who called function
« Reply #8 on: April 02, 2015, 10:19:57 am »
It should, yes.

  • Print