I searched in the wiki of gmod but I didn't find anything about IsChat or something like that.
The only one thing I found it's OnplayerChat for hook but nothing by player.
Any one have an idea ?
Thanks
[QUOTE=lotus006;29895258]I searched in the wiki of gmod but I didn't find anything about IsChat or something like that.
The only one thing I found it's OnplayerChat for hook but nothing by player.
Any one have an idea ?
Thanks[/QUOTE]
GM:OnPlayerChat( Player player, String text, Boolean TeamChat, Boolean PlayerIsDead )
The Player argument will return the player who sent the message, such as (for example):
function GM:OnPlayerChat( Player, text, IsTeam, IsDead )
print("Message By: "..Player:Nick().."\n")
chat.AddText(Player, Color( 255, 255, 255 ), ": ", text) --Add Chat - didnt bother making one for team arg
return true
end
If you get stuck finding functions this is a great website
[url]http://luasearch.overvprojects.nl/[/url]
Its much better to search for functions then using the wiki search
yeah thanks to both, i just not have time yet to try it but for lua search I know already it's very usefull :)
about GM:OnPlayerChat() what ever it say alway GM: something a nil value, I tested with hook but i'm alway confused about this.
You really should be using:
[lua]
hook.Add("OnPlayerChat"," ", function(ply, text, team, dead)
--Stuff Goes Here
end)
[/lua]
As you should not be overriding functions like this unless its a gamemode.
[QUOTE=lotus006;29951417]yeah thanks to both, i just not have time yet to try it but for lua search I know already it's very usefull :)
about GM:OnPlayerChat() what ever it say alway GM: something a nil value, I tested with hook but i'm alway confused about this.[/QUOTE]
Where and How are you calling it?
Are you calling it inside a function, because for one it is a hook and will call itself and for two GM has to be called as GAMEMODE inside a function, or self inside a function that is already GM, such as:
[lua]
--if making a GAMEMODE then
function GM:SomethingInAMeta( Player )
print(Player:Name().." likes making Gamemodes.".."\n")
end
function GM:PlayerSpawn( Player )
self:SomethingInAMeta( Player ) --When calling a method from inside an object that is the same as the object you are calling the method for, you must use self and not its global / local
--name (in this case GAMEMODE).
--Failing to do the above will result in an "Attempt to index global "VAR", a nil value" Error.
end
--if you were to call GM inside of a normal function, it would have to look like this:
--In a Gamemode file:
function GM:DoMath(int, float)
return math.Round(int) * float
end
--In your Addon / Sample file: (How to call the above function)
function ThePlayerSpawned( Player )
local var = GAMEMODE:DoMath(5.6, 7) --Called as GAMEMODE, not GM
print("The number is: "..tostring(var).."\n")
end
hook.Add("PlayerSpawn", "ThePlayerSpawned", ThePlayerSpawned)
--if you did the above, it would work. However, if you did this;
--In a Gamemode file:
function GM:DoMath(int, float)
return math.Round(int) * float
end
--In your Addon / Sample file:
function ThePlayerSpawned( Player )
local var = GM:DoMath(5.6, 7)
--Doing the above will result in an "Attempt to index global "VAR", a nil value" Error.
print("The number is: "..tostring(var).."\n")
end
hook.Add("PlayerSpawn", "ThePlayerSpawned", ThePlayerSpawned)
--it would not.
[/lua]
Post where the file with the code is located (addons / lua / autorun or gamemode), and be sure to post all of your code involving this with it, or else we can not help you.
[QUOTE=Albert;29954576]
.[/QUOTE]
I had to rate you Lua-King, but unfortunately I could only rate you Lua helper..
Sorry, you need to Log In to post a reply to this thread.