Problem with SetPlayerTeamFromClass
#1

Hello everyone, I got the next problem:

I`m trying to make a Team Deathmatch gamemode, I defined Teams but when it comes to SetPlayetTeamFromClass, something goes wrong, I`ll explain:

I use this:

First, defining the teams:

pawn Код:
new gTeam[MAX_PLAYERS];
after that, at the bottom of the script, I inserted:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    switch(classid)
    {
    case 71, 265, 266, 267, 280, 281, 285:gTeam[playerid] = TEAM_POLICE;
    case 163, 164, 165, 166, 233, 286, 287, 295:gTeam[playerid] = TEAM_BUREAU;
    case 274, 275, 276, 277, 278, 279:gTeam[playerid] = TEAM_MEDICS;
    case 147, 150, 141, 153, 156, 187, 188:gTeam[playerid] = TEAM_LICENSE;
    case 61, 142, 169, 170, 211, 253, 255:gTeam[playerid] = TEAM_TAXI;
    case 111, 112, 113, 290, 236, 206, 186:gTeam[playerid] = TEAM_BRATVA;
    case 124, 125, 126, 217, 258, 259:gTeam[playerid] = TEAM_NUCCI;
    case 47, 48, 108, 109, 110, 292:gTeam[playerid] = TEAM_SANGRE;
    case 46, 114, 115, 116, 173, 174, 175:gTeam[playerid] = TEAM_VARIOS;
    case 66, 67, 72, 133, 179, 181, 192, 191, 190, 201, 202, 247, 248, 254:gTeam[playerid] = TEAM_BIKERS;
    case 127, 193, 272, 294:gTeam[playerid] = TEAM_HITMAN;
    case 12, 105, 106, 107, 195, 269, 270, 271, 293:gTeam[playerid] = TEAM_GROVE;
    case 13, 21, 22, 102, 103, 104, 296, 297, 298:gTeam[playerid] = TEAM_BALLAS;
    case 93, 282, 283, 284, 288:gTeam[playerid] = TEAM_SHERIFF;
    }
}
and put SetPlayerTeamFromClass(playerid, classid); at

pawn Код:
public OnPlayerRequestClass(playerid, classid)
          {
          SetPlayerTeamFromClass(playerid, classid);
          return 1;
          }
But, the server recognizes only TEAM_POLICE, the first one.

I get no errors / warnings when I compile it but I tried to make a command only for another gTeam (for example TEAM_HITMAN) and the command wouldn`t work ... The server would not recognize the other teams, beside gTeam[playerid] == TEAM_POLICE ...

Anyone has any solution ? Thank you in advance.
Reply
#2

Class ID != skin ID.
https://sampwiki.blast.hk/wiki/OnPlayerRequestClass
Quote:
Originally Posted by SA:MP Wiki
Note: Class IDs are assigned when AddPlayerClass is used.
So the first AddPlayerClass is class ID 0 and the second one is class ID 1, etc.
Reply
#3

Quote:
Originally Posted by [03]Garsino
Посмотреть сообщение
Class ID != skin ID.
https://sampwiki.blast.hk/wiki/OnPlayerRequestClass


So the first AddPlayerClass is class ID 0 and the second one is class ID 1, etc.
Hm, I think I know what you mean ... but isn`t there a way to 'shorten' it?

If I`m not wrong, you're trying to say next:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    switch(classid)
    {
    case 0:gTeam[playerid] = TEAM_POLICE; // First AddPlayerClass in GameModeInit
    case 1:gTeam[playerid] = TEAM_POLICE;// Second AddPlayerClass in GameModeInit
    }
}
And if I`m right and that`s what you're trying to tell me, I have another question:

Let`s say I have 100 AddPlayerClass ... or how about if I have more than 1 skin per team? Can`t I somehow group them all together?

What I mean is next: Instead of "case 0: bla bla" to use "case 71,123,200, etc: bla bla" - 71,123,200, etc = Skins ID which I used.

Is there anyway of using Skins ID instead of Class ID? Or is it better, easier to use class ID ? If yes, how can I set it up using class ID ?


Later Edit: Okay, so I`ve played around my script, taking note of what you said and I think I somehow fixed the problem. Instead of using:
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
I used
pawn Код:
SetPlayerTeamFromClass(playerid, skinid)
and of course:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
        new skinid = GetPlayerSkin(playerid);
I`ll give it few tests before I can surely tell you if it works or not ... I`ll come back with another later edit to tell you if it works.

Thank you for your help.

Later later edit:

Yes, I finally fixed it.

Thanks [03]Garsino for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)