My script wont work after Garry's Updates.

Hey guys, I went away for a few days and when I came back, Garry had done some updates. I tested my Admin Mod and it wont work. I want to know what he has done and if you can help me change my script so it will work.

[lua]hook.Add(“PlayerSay”, “WAMGod”, function(plyObject, saidText, isPublic)
if plyObject:IsAdmin() then

local arguments = string.Explode(" ", saidText);



if (arguments[1] == "!god" and arguments[2] and arguments[2] != "") then

	local findName = string.lower( arguments[2] );
	local GodPlayers = {};
	

	for k, v in ipairs( player.GetAll() ) do

		if ( string.find(string.lower( v:Name() ), findName) ) then

			 	 v:GodEnable( )
		

			GodPlayers[#GodPlayers + 1] = v:Name();
		end
	end
	

	if (#GodPlayers > 0) then

		for k, v in ipairs( player.GetAll() ) do
			v:PrintMessage(3, "[WAM] "..plyObject:Name().." has godded "..table.concat(GodPlayers, ", and ")..".");
		end
	end
	
	return "";
end
end;

end);
[/lua]

The error would be nice…

They isn’t one.

Hm. What did garry update? Look for relative paths that could of messed something up.

Above v:GodEnable, do print(v). Tell me if it prints anything.

Nothing happens.

-snip-

Below if arguments == whatever, print(“IF STATEMENT IS CALLED”) or something. Really, just debug the function yourself. Figure out what level of the program is erroring.

Throw a hook into player damage, do a check, if the player is godded, then return false.

That’s incredibly unhelpful. You shouldn’t fix problems by hacky workarounds - there’s probably a good reason for why his code doesn’t work.

I added a print to the second line of my code and it didn’t print.

[editline]11:36PM[/editline]

It used to work, but after me being away it stopped working.

Currently wondering what’s going down with line 10.

Oh right. PlayerSay doesnt work any more. use **OnPlayerChat**instead.

Or rather it doesnt work for what your trying to do

I got it working by removing


arguments[1] == "!god" and

from line 10. What was that intended to do?

It was intended to god the target, so really I need that code.

[editline]11:27AM[/editline]

I did [lua]hook.Add(“OnPlayerChat” “WAMGod”, function( plyObject, saidText, isPublic, bPlayerIsDead )[/lua] and it still wont work.

PlayerSay is the serverside chat hook; OnPlayerChat is the clientside chat hook.

the line I mentioned doesn’t do that. it make sure arg 1 in the chat string isn’t “god”.

Removing that part made it possible to god any player while sv_cheats is on. I tested it.

But I want it to check that I say !god

Why would you remove that?

Ah, I see now. I fucked up.

The script worked for me without having to change anything.

On your server, you must have your username and steamid in ‘/garrysmod/garrysmod/settings/users.txt’

the code should run server-side obviously and sv_cheats must be on. That’s it.