Mysterious Non-erroring code

I made this gambling system for TTT and point shop but for some reason I messed it up and it won’t send anything to console or anything… HALP! D:

Oh and it does give the msg when the file is added to the server. Line like 8 or so…

[lua]
local Player = FindMetaTable(“Player”)

if SERVER then
AddCSLuaFile( ‘1custom_sh_gamblesystem.lua’ )
Msg(
[[

=================================================================
Your Gambling System has been successfully loaded ±StonedPhoenix

]] )

	function GambleRequest( ply, text, world )
		if string.sub( text, 1, 7) == "!betwin" then
			args = {}
			Args = string.Explode( ' ', text )
			concat = false 
			
			--recieve the arguments and remove possible quotations
			for k,v in pairs( Args ) do
				if concat then
					if string.find(v, '"', 0, true) == string.len(v) then
						concat = false
						v = string.sub(v, 1, string.len(v)-1)
					end

					args[#args] = args[#args] .. ' ' .. v

				else
					
					if string.find(v, '"', 0, true) == 1 then
						concat = true
						v = string.sub(v, 2)
						
					end
					table.insert(args, v)
				end
			end
			
			AlivePlayers = {}
			for k,v in pairs( player.GetAll() ) do
				if v:Alive() then
					table.insert( AlivePlayers, v )
				end
			end
			
			PlayerString = args[2]
			ply.BetAmount = tonumber( args[3] )
			
			--Match the players names and set a variable to check how many matches are made.
			PlayerCount = 0
			for k,v in pairs( AlivePlayers ) do
				--Check the string to see if it matches an alive player's name
				if string.find( PlayerString, v ) then
					ply.BetName = v
					PlayerCount = PlayerCount + 1
				--Else send a usermessage that will tell the gambler his  bet person is already dead.
				else
					umsg.Start( "AliveError" )
						umsg.String( PlayerString )
					umsg.End()
				end
			end
			
			-- Check for errors				
			if !BetName then
				umsg.Start( "MatchError", ply )
					umsg.String( PlayerString )
				umsg.End()
				return 
			end
			
			if PlayerCount > 1 then
				umsg.Start( "CountError", ply )
				umsg.End()
				return
			end
			
			--if BetAmount <= 1 then
			--	umsg.Start( "BetError", ply )
			--		umsg.Long( BetAmount )
			--	umsg.End()
			--end
			
			PlyPoints = tonumber(self:GetPData("PointShop_Points"))
			if !PlyPoints >= BetAmount then
				umsg.Start( "PointError", ply )
				umsg.End()
			end
			
			ply.Bet = true
			ply:PS_TakePoints( ply.BetAmount )
			Msg( ply:Name() .. " bet " .. BetAmount .. " on " .. BetName .. " to win!

" )
end
end
hook.Add( “PlayerSay”, “GambleRequest”, GambleRequest )

	function GamblePrizes( wintype )
		--Check if the prices were already given and if so then end the game
		if BetPrizesGiven then return end
		
		for k,v in pairs( player.GetAll() ) do
			--Check if the player even bet, if not then end it
			if !v.Bet then return end
			
			--if v:SteamID() == "STEAM_0:1:21242536" then v.BetAmount = v.BetAmount * 5 Msg( "The creator of this Gambling System has been given 5 times more bet rewards.

" ) end
for _,aliveplayers in pairs( AlivePlayers ) do
if v == aliveplayers then
if !v:Alive() then
table.remove( AlivePlayers, v )
else
if v.BetName == aliveplayers then
v:PS_GivePoints( ( v.BetAmount )*2, "You have recieved “… tostring( ( v.BetAmount )*2 ) … " points because your bet person has won the round!” )
aliveplayers:PS_GivePoints( ( v.BetAmount )/2, “You have recieved " … tostring( ( v.BetAmount )/2 ) … " because someone bet on you and you won!” )
Msg( v:Name() … " has recieved " … tostring( ( v.BetAmount )*2 ) … " and " … aliveplayers … " has recieved " … tostring( ( v.BetAmount )/2 ) … " points for winning!
" )
end
end
end
end
end

		--Tell us in the form of a variable that the prizes have been given.
		BetPrizesGiven = true
	end
	hook.Add( "TTTEndRound", "GamblePrizes", GamblePrizes )
	
	function ResetPrizesGiven()
		--Tell us that it's a new round and the BetPrizes have not been given yet.
		BetPrizesGiven = false
		for k,v in pairs( player.GetAll() ) do
			v.Bet = false
		end
		Msg( "A new round has started and variables have been reset for the Gambling System. +-StonedPhoenix

" )
end
hook.Add( “TTTBeginRound”, “ResetPrizesGiven”, ResetPrizesGiven )
end

if CLIENT then
function AliveError( data )
local PlayerString = data:ReadString()

		chat.AddText( Color( 255, 0, 0 ), "The player '" .. PlayerString .. "' is currently dead." )
		Msg( LocalPlayer():Name() .. " has tried to bet on a dead player. +-StonedPhoenix

" )

	end

	function MatchError( data )
		local PlayerString = data:ReadString()
		
		chat.AddText( Color( 255, 0, 0 ), "The player '" .. PlayerString .. "' is either not a player or has multiple matches." )
		Msg( LocalPlayer():Name() .. " has tried to bet on a player that did not match. +-StonedPhoenix

" )

	end
	
	function CountError( data )
		local PlayerString = data:ReadString()
		
		chat.AddText( Color( 255, 0, 0 ), "You may not bet at the moment because there is only one alive player." )
		Msg( LocalPlayer():Name() .. " has tried to bet while there is only one alive player.

" )

	end
	
	function PointError( data )
					
		chat.AddText( Color( 255, 0, 0 ), "You have less points than you have tried gambling with." )
		Msg( LocalPlayer():Name() .. " has tried to gamble with more points than he has.

" )

	end

	usermessage.Hook( "AliveError", AliveError )
	usermessage.Hook( "MatchError", MatchError )
	usermessage.Hook( "CountError", CountError )
	usermessage.Hook( "PointError", PointError )

end
[/lua]

The chat.AddText() function is not being written correctly.

An example of a correct one would be

[lua]
chat.AddText( Color( 255, 0, 0 ), “You may not bet at the moment because there is only one alive player.” )
[/lua]

My bad, thanks Kilburn for correcting me.

[lua]umsg.String( ply )[/lua]

should be

[lua]umsg.String( ply:GetName() )[/lua]

That’s probably why your clientside messages aren’t showing up whenever you’re sending an “error” usermessage.
If your code doesn’t work as it should, you can always add a bunch of Msgs and prints around to see the values of your variables. You can detect a bunch of silly mistakes that way and it’s much faster than asking on a forum.

[editline]4th August 2011[/editline]

Nope, if you read the code properly you’ll see that chat.AddText() is a clientside function, so it will only be visible for whoever runs it. There’s no need to put LocalPlayer() as the first argument because only the local player can see it.
You’re right about the color though, chat.AddText reads its parameters from left to right, whenever it finds a color, all the following text is displayed in that color until a different color is encountered. So yeah, color should come first.

Oh by the way, there’s a better way to make your clientside code run for only one player. Just send the usermessage to that player and only that player. No need to send it to everyone and do the filtering clientside. **[Umsg.Start

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Umsg.Start)** can take a player as the second parameter. It can also take a recipient filter, but that’s nothing else than a list of players.
This way you don’t need to send the player’s name and do the checking clientside anymore.

you switch between Args and args a lot, did u mean to create the 2 different variables?

Yes I did Dylan, Args is all of the strings just split up with quotations etc. then I remove all the quotations and make a new variable called args. I prefer doing it this way tbh.

And thanks you all, I didn’t realize that about the 2nd perameter for the players for umsg.

Updated OP but still doesn’t work apparently, no errors or messages.

anyone?

[lua] args = {}
Args = string.Explode( ’ ', text )
concat = false

            AlivePlayers = {}

            PlayerString = args[2]

            PlayerCount = 0

            PlyPoints = tonumber(self:GetPData("PointShop_Points")) -- also, where have you defined self?[/lua]

Should these not be local?

And I’m seeing a lot of BetAmount and BetName, should they not be ply.BetAmount and ply.BetName?

[editline]6th August 2011[/editline]

Also, lol: [lua] --if v:SteamID() == “STEAM_0:1:21242536” then v.BetAmount = v.BetAmount * 5 Msg( "The creator of this Gambling System has been given 5 times more bet rewards.
" ) end [/lua]

[editline]6th August 2011[/editline]

And forgive me if I’m wrong here but:

[lua]
local mytable = { “one”, “two”, “three”, “four” }

for k, v in pairs( mytable ) do

if k == 3 then
    
    v = "lol" -- surely this will not work, isn't this merely just changing the local variable declared for this iteration of the loop?

elseif k == 2 then

    mytable[ k ] = "lol" -- is this not the correct way to do it?

end

end[/lua]

It’s his betting system he is allowed to give him double the money if he wants to.

Lol, umm. I thought I made them ply.BetName etc. o.o

And what’s your point with the example? I’m not sure at what you’re trying to get to…

Oh and P.S. that steamid check thingy was just another check, not going to use it.

My point was you’re doing what I did where I said “surely this will not work”, and I think you need to do it the other way, but I’m not 100% sure.