Setting player to team from skinid
#1

I'm kinda new to scripting and I have a problem with setting a player to a defined team by what skin they chose.
I did the setplayertoteamfromclass tutorial on the samp wiki to define my teams like:
"#define TEAM_COP 1
#define TEAM_BALLAS 2"
etc that worked fine but later on I did a stat saving system so I could save the player's skin so they spawned with it next time they logged in but I read somewhere here that you can't save the player's classid like that so my team's are useless once the player disconnects and connects again. So is there anyway of using the skinid to set the player to a team instead of by the classid?
I tried changing 'setplayertoteamfromclass' to 'setplayertoteamfromskin'
at the top of my script I wrote:
"forward SetPlayerTeamFromSkin(playerid, skinid);"
in the "onplayerspawn" I did "SetPlayerTeamFromSkin(playerid,skinid);"
then at the bottom on it's own I did:
"SetPlayerTeamFromSkin(playerid,skinid)
{
GetPlayerSkin(playerid);
if(skinid >= 280 && skinid <= 28
{
gTeam[playerid] = TEAM_COP;
}
else if(skinid >= 274 && skinid <= 276)
{
gTeam[playerid] = TEAM_ERS;
}
else if(skinid >= 102 && skinid <= 104)
{
gTeam[playerid] = TEAM_BALLAS;
}
else if(skinid >= 108 && skinid <= 110)
{
gTeam[playerid] = TEAM_NOR;
}
else if(skinid == 100 || skinid == 247 || skinid == 248 || skinid == 254)
{
gTeam[playerid] = TEAM_BIKER;
}
}
" But it says "error 017: undefined symbol "skinid"" when I try compiling it. The error is on my "SetPlayerTeamFromSkin(playerid,skinid);" line in the onplayerspawn callback.



Reply
#2

Put this with the other publics.

pawn Код:
forward SetPlayerTeamFromSkin(playerid);
public SetPlayerTeamFromSkin(playerid)
{
  new skinid = GetPlayerSkin(playerid);
  if(skinid >= 280 && skinid <= 288)
  {
    gTeam[playerid] = TEAM_COP;
  }
  else if(skinid >= 274 && skinid <= 276)
  {
    gTeam[playerid] = TEAM_ERS;
  }
  else if(skinid >= 102 && skinid <= 104)
  {
    gTeam[playerid] = TEAM_BALLAS;
  }
  else if(skinid >= 108 && skinid <= 110)
  {
    gTeam[playerid] = TEAM_NOR;
  }
  else if(skinid == 100 || skinid == 247 || skinid == 248 || skinid == 254)
  {
    gTeam[playerid] = TEAM_BIKER;
  }
  return 1;
}
And then OnPlayerSpawn put

pawn Код:
SetTimerEx("SetPlayerTeamFromSkin", 2000, 0, "i", playerid);
I did a timer so it allows enough time for a skin to be set.
Reply
#3

Ah, that worked, thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)