SA-MP Forums Archive
How would i do this? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How would i do this? (/showthread.php?tid=122329)



How would i do this? - JoeDaDude - 21.01.2010

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0)
    {
        gTeam[playerid] = TEAM_POLICESF;
    }
    else
    {
        gTeam[playerid] = TEAM_CROOKSF;
    }
    else
    {
        gTeam[playerid] = TEAM_MEDICSF;
    }
}
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(305) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
I know else is used as a last resort or w/e, but how would i do this?


Re: How would i do this? - Correlli - 21.01.2010

pawn Код:
if(classid == 0) gTeam[playerid] = TEAM_POLICESF;
else if(classid == OTHER_CLASS_ID) gTeam[playerid] = TEAM_CROOKSF;
else gTeam[playerid] = TEAM_MEDICSF;
or even better:
pawn Код:
switch(classid)
{
  case 0: gTeam[playerid] = TEAM_POLICESF;
  case OTHER_CLASS_ID: gTeam[playerid] = TEAM_CROOKSF;
  default: gTeam[playerid] = TEAM_MEDICSF;
}



Re: How would i do this? - JoeDaDude - 21.01.2010

Would that work properly?
Because before TEAM_CROOKSF
Didnt have, if(classid == w/e)


Re: How would i do this? - Correlli - 21.01.2010

OTHER_CLASS_ID was just an example, put your own class-ID.


Re: How would i do this? - JoeDaDude - 21.01.2010

pawn Код:
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(305) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(313) : error 017: undefined symbol "classid"
C:\Program Files\Rockstar Games\GTA San Andreas\sa-mp\gamemodes\gamemode.pwn(317) : error 017: undefined symbol "classid"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
Wouldnt like this work because its only to set the players color

pawn Код:
if(GetPlayerTeam(playerid) == 1) SetPlayerColor(playerid, TEAM_POLICESF_COLOR);
else if(GetPlayerTeam(playerid) == 2) SetPlayerColor(playerid, TEAM_CROOKSF_COLOR);
else if(GetPlayerTeam(playerid) == 3) SetPlayerColor(playerid, TEAM_MEDICSF_COLOR);
Or

pawn Код:
if(GetPlayerTeam(playerid) == TEAM_POLICESF) SetPlayerColor(playerid, TEAM_POLICESF_COLOR);
else if(GetPlayerTeam(playerid) == TEAM_CROOKSF) SetPlayerColor(playerid, TEAM_CROOKSF_COLOR);
else if(GetPlayerTeam(playerid) == TEAM_MEDICSF) SetPlayerColor(playerid, TEAM_MEDICSF_COLOR);
Or something like that

EDIT: Wait ive been putting them in completly the wrong place, Hold on