GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 28 Nov 2013 11:38 AM |
This won't work for some reason, don't know why. No output and I don't see a syntactical error… This should work and do something like if an admin(me) chats: "team-PLAYERNAME-TEAMNAME" then that player's team color is changed to that team name's team color, but it doesn't. -_-
local gAdmin = { ["GGGGG14"] = true; --[[admin]] }
function findPlayer(name) for _, player in ipairs(game.Players:GetPlayers()) do if player.Name:lower() == name:lower() then return player end end end
function findTeam(name) for _, team in ipairs(game.Teams:GetChildren()) do if team.Name:lower() == name:lower() then return team end end end
function onChatted(msg, player)
if msg:sub(1,6) == "team--" and gAdmin[player.Name] then victim = findPlayer(msg:sub(6)) --[[subs victim name into admin cmd]] teamName = findTeam(msg:sub(7)) --[[subs teamname into admin cmd]] if victim and teamName then victim.TeamColor = teamName.TeamColor end end end
game.Players.PlayerAdded:connect(function(player) player.Chatted:connect(function(msg) onChatted(msg, player) end) end) |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 11:41 AM |
"victim = findPlayer(msg:sub(6))" : victim = findPlayer(msg:sub(7))
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
|
| 28 Nov 2013 11:42 AM |
tl;dr Just use string.find and string.sub together to find where the dashes are, check the team color (game.Teams.TeamName.TeamColor), and change the player's team color property. Hope this helped.
-IПƧΛПΣ- |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 28 Nov 2013 11:42 AM |
Why would it be 7?
TteamName would be subbed in as the seventh. |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
| |
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 11:44 AM |
Actually, my bad that's wrong. Try looking through the msg and adding the '-' in a table. findplayer(daslash[1]+1) team(daslash[2]+1)
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 28 Nov 2013 11:46 AM |
| bleh string manipulation and tables are annoying… especially with admin cmds |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
|
| 28 Nov 2013 11:48 AM |
| *sidenote: this is a shortened version of a 500 line admin script…, but this particular command won't work bleh. |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 11:48 AM |
Yeah, they are.
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 11:53 AM |
Try this: slash = nil for i =6,msg:len() do if string.sub(msg,i,i) == "-" then place = i break end end if place == nil then return end local player1 = findplayer(string.sub(msg,6,place - 1)) local team = team (string.sub(msg,place + 1))
end
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 11:56 AM |
slash = nil for i =6,msg:len() do if string.sub(msg,i,i) == "-" then slash = i break end end if slash == nil then return end local player1 = findplayer(string.sub(msg,6,slash - 1)) local team = team (string.sub(msg,slash + 1))
Don't know what I was thinking. x)
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
GGGGG14
|
  |
| Joined: 29 Jan 2012 |
| Total Posts: 25344 |
|
| |
|
|
| 28 Nov 2013 12:05 PM |
My admin works off of string manipulation. I even made a script that makes them easier to use using return....
-IПƧΛПΣ- |
|
|
| Report Abuse |
|
|
mic144
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 1598 |
|
|
| 28 Nov 2013 12:05 PM |
It should work but not sure havent tested it
-- $$ Get on my level, here use this ladder. Don't fall down on the way up! $$ -- |
|
|
| Report Abuse |
|
|
einsteinK
|
  |
| Joined: 22 May 2011 |
| Total Posts: 1015 |
|
|
| 28 Nov 2013 12:53 PM |
team-PLAYERNAME-TEAMNAME
-- This is onChatted(msg,player) local name,team = msg:match("team%-(%w+)%-(%w+)") -- Cuz string.match pwns if not name then return end -- Command not used right local p,t = findPlayer(name),findTeam(team) if not p or not t then return end -- No team/player p.TeamColor = t.TeamColor
-- This is onChatted(msg,player) local cmd,par = msg:match("(%w+)%-?(.*)") if not cmd then return end -- Player didn't say COMMAND-(optional text) local str = "'%s': '%s'" print(str:format(cmd,par)) -- "do-" --> 'do': '' -- "do-stuff" --> 'do': 'stuff' -- "do-a lot of-stuff" --> 'do': 'a lot of-stuff' |
|
|
| Report Abuse |
|
|
|
| 28 Nov 2013 01:00 PM |
| String manipulation takes a while to get correct in these scripts (I've had to restart my own script many times from scratch. This was the most painful part.), but they are well worth the time. |
|
|
| Report Abuse |
|
|