Sparrow Posted February 7, 2012 Posted February 7, 2012 why when I do this: local getTeam = getTeamName (source) it comes error: Bad 'team' pointer @ 'getTeamName'
Kenix Posted February 7, 2012 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.
sckatchof Posted February 7, 2012 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
Sparrow Posted February 7, 2012 Author 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)
Kenix Posted February 7, 2012 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 )
Sparrow Posted February 7, 2012 Author 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.
Kenix Posted February 7, 2012 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 )
Sparrow Posted February 7, 2012 Author 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.
GanJaRuleZ Posted February 7, 2012 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
Kenix Posted February 7, 2012 Posted February 7, 2012 Show full code. And try rename this cmd to set_team
Sparrow Posted February 7, 2012 Author 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 )
Castillo Posted February 7, 2012 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".
Sparrow Posted February 7, 2012 Author 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.
Castillo Posted February 7, 2012 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 )
Sparrow Posted February 7, 2012 Author 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
Castillo Posted February 7, 2012 Posted February 7, 2012 That make's no sense, "team" is a team-element, not a skin model.
Sparrow Posted February 7, 2012 Author 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 )
Castillo Posted February 7, 2012 Posted February 7, 2012 What part don't you get? "team" is not a SKIN MODEL.
Sparrow Posted February 7, 2012 Author 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)
Castillo Posted February 7, 2012 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 )
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