Sparrow Posted February 7, 2012 Share Posted February 7, 2012 why when I do this: local getTeam = getTeamName (source) it comes error: Bad 'team' pointer @ 'getTeamName' Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 You should use source in event https://wiki.multitheftauto.com/wiki/Pre ... ables_list Show full code.We don't know maybe your source player in event or team. Link to comment
sckatchof Posted February 7, 2012 Share Posted February 7, 2012 why when I do this: local getTeam = getTeamName (source) it comes error: Bad 'team' pointer @ 'getTeamName' Try this : local team = getTeamFromName(teamname) if team and getPlayerTeam(player) == team then Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 my code: function setMyTeam(source) local getTeam = getTeamName (source) if (getTeam) then outputChatBox("Your team now is "..getTeamName..".", source, 0, 255, 0) else outputChatBox("Bara nayek.", source, 255, 0, 0) end end addCommandHandler ("setteam", setMyTeam) Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 function setMyTeam( player ) local team = getPlayerTeam( player ) if team then outputChatBox( "Your team now is "..getTeamName( team )..".", player, 0, 255, 0 ) else outputChatBox( "Bara nayek.", player, 255, 0, 0 ) end end addCommandHandler ( "setteam", setMyTeam ) Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 hm, I want it to set the player in team after he type /setteam function setMyTeam( player ) local team = getPlayerTeam( player ) if team then setPlayerTeam (player, team) outputChatBox( "Your team now is "..getTeamName( team )..".", player, 0, 255, 0 ) else outputChatBox( "Bara nayek.", player, 255, 0, 0 ) end end addCommandHandler ( "setteam", setMyTeam ) it didn't set me in team. Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 function setMyTeam( player,_,name ) if name then local team = getPlayerTeam( player ) if not team then if setPlayerTeam ( player, getTeamFromName( name ) ) then outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Can't set to team.", player, 255, 0, 0 ) end else outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /setteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "setteam", setMyTeam ) Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 this didn't work, no errors but in chatbox: Error: 'Test' matches no players.Alreadly in team. Test is the team. Link to comment
GanJaRuleZ Posted February 7, 2012 Share Posted February 7, 2012 well , as far i know /setteam is an command , on freeroam servers... So there are 2 scripts : The command : Error:'Test' matches no players. You're script : Aleardy in a team Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 Show full code. And try rename this cmd to set_team Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 this didn't work, I changed the command, but it says that I'm Alreadly in team function setMyTeam( player,_,name ) if name then local team = getPlayerTeam( player ) if not team then if setPlayerTeam ( player, getTeamFromName( name ) ) then outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Can't set to team.", player, 255, 0, 0 ) end else outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "newteam", setMyTeam ) Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 function setMyTeam( player, cmd, ... ) local name = table.concat({...}, " ") if (name and name ~= "") then local team = getPlayerTeam( player ) if (not team) then if setPlayerTeam ( player, getTeamFromName( name ) ) then outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Can't set to team.", player, 255, 0, 0 ) end else outputChatBox( "Alreadly in team.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "changeteam", setMyTeam ) I think the command "/newteam" is part of the Admin panel, that's why I renamed it to "/changeteam". Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 didn't work it still says that I'm Alreadly in team, and it didn't set my team to the new one. Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 That's because you added to check for team.. function setMyTeam( player, cmd, ... ) local name = table.concat({...}, " ") if (name and name ~= "") then local team = getPlayerTeam( player ) if setPlayerTeam ( player, getTeamFromName( name ) ) then outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Can't set to team.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /newteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "changeteam", setMyTeam ) Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 it's working now, thanks Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 another question please, when I use /changeteam command, I get another team and I didn't get his skin, so I must add setElementModel (player, team) after if setPlayerTeam ( player, getTeamFromName( name ) ) then Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 That make's no sense, "team" is a team-element, not a skin model. Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 I mean: function setMyTeam( player, cmd, ... ) local name = table.concat({...}, " ") if (name and name ~= "") then local team = getPlayerTeam( player ) if setPlayerTeam ( player, getTeamFromName( name ) ) then setElementModel (player, team) outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Access Denied.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /changeteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "changeteam", setMyTeam ) Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 What part don't you get? "team" is not a SKIN MODEL. Link to comment
Sparrow Posted February 7, 2012 Author Share Posted February 7, 2012 I mean when player do /changeteam he get the skin of that team... E.g: /changeteam Army, he get the army skin (ID: 287) Link to comment
Castillo Posted February 7, 2012 Share Posted February 7, 2012 So, I guess you mean a table with team names and skins? Like this: local skins = { ["Team 1"] = 299, ["Team 2"] = 288, } function setMyTeam( player, cmd, ... ) local name = table.concat({...}, " ") if (name and name ~= "") then local team = getPlayerTeam( player ) if setPlayerTeam ( player, getTeamFromName( name ) ) then setElementModel (player, tonumber(skins[getTeamName(getPlayerTeam(player))]) or 0) outputChatBox( "Your team now is "..getTeamName( getPlayerTeam( player ) )..".", player, 0, 255, 0 ) else outputChatBox( "Access Denied.", player, 255, 0, 0 ) end else outputChatBox( "SYNTAX: /changeteam [team name].", player, 255, 0, 0 ) end end addCommandHandler ( "changeteam", setMyTeam ) Link to comment
Sparrow Posted February 8, 2012 Author Share Posted February 8, 2012 thanks for this help... Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now