ULX

Author Topic: Getting the current map and current player count isn't working  (Read 1379 times)

0 Members and 1 Guest are viewing this topic.

Offline Rex744

  • Newbie
  • *
  • Posts: 8
  • Karma: 0
Hello, I was expecting my code to use the ulx csaycolor command from the ulx custom commands, and I wanted my script to check if the map is pb_z_high_school_g then if there are a certain amount of players to display a specific ulx csay message which veries depending on how many people are on. This is not the case, when I run this file, the only thing showing up is the first EASY message, I've messed around with my alt accounts in-game and by using bots in-game, there is no change. After running the file, it never updates text again, so if I add a bot no other message appears, it is only when I run the file.

Can anyone help me?

Code: [Select]
function AutoDifficultyPatch(ply)
for k,v in pairs (player.GetAll()) do
if game.GetMap() == "pb_z_high_school_g" then do
if v:GetCount(1) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to EASY. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(2) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to EASY. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(3) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to MEDIUM. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(4) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to HARD. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(5) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to HARD. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(6) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to HARD. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(7) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to INSANE. Do !difficulty to vote change to a different one.", "red")
elseif v:GetCount(8) then
RunConsoleCommand("ulx", "csaycolor", "[Someone joined/left] Difficulty automatically changed to INSANE. Do !difficulty to vote change to a different one.", "red")
end
end
end
end
end
hook.Add( PlayerInitialSpawn, "AutoDifficultyPatch()", AutoDifficultyPatch() )

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given