SA-MP Forums Archive
Set a players team from lcass - 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)
+--- Thread: Set a players team from lcass (/showthread.php?tid=344367)



Set a players team from class - BigGroter - 20.05.2012

I'm following this tutorial.
https://sampwiki.blast.hk/wiki/PAWN_tutorial_1
I'm near the bottom, and it says;

SetPlayerTeamFromClass(playerid, classid)
{
if (classid == 0)
{
gTeam[playerid] = TEAM_GROVE;
}
else
{
gTeam[playerid] = TEAM_BALLA;
}
}

Where do I add it? It says;

Place that code OUTSIDE a function in your code (as it is a new function) and put these lines as the first things after the open curly braces in your OnPlayerRequestClass callback (notice the way the variables are not global so we are having to pass them to out function too)

I can't get it to work though, help is appreciated.


Re: Set a players team from lcass - BigGroter - 20.05.2012

Anyone? This can't be too hard to solve.


Re: Set a players team from lcass - Pinguinn - 20.05.2012

It means that you have to add
pawn Код:
stock SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else
    {
        gTeam[playerid] = TEAM_BALLA;
    }
}
at the bottom of your script. So, under the latest public function

For the second thing, it means you have to do it like this
pawn Код:
public OnPlayerRequestClass(playerid, classid) {
    SetPlayerTeamFromClass(playerid, classid);
}



Re: Set a players team from lcass - BigGroter - 20.05.2012

What is that "stock" you added before SetPlayerTeamFromClass?


Re: Set a players team from lcass - Pinguinn - 20.05.2012

Quote:
Originally Posted by SA-MP Wiki
Stocks are a form of function. The only noticeable difference between a stock and a function is that when you don't use a stock, you don't get a warning. Stocks are powerful little tools that allow you to move large repeated bits of code away from the main block, making it easier to edit something that is used in multiple places.
source


Re: Set a players team from lcass - BigGroter - 20.05.2012

Ah, thank you!


Re: Set a players team from lcass - Pinguinn - 20.05.2012

No problem