How to create a simple faction?
#4

Step 1:
Define your teams and give them colours, like:
pawn Код:
#define RUSSIA          1
#define USA             2
.
.
.
so on
#define COLOR_RUSSIA        COLOR_BRIGHTRED
#define COLOR_USA           COLOR_LIGHTBLUE
.
.
.
so on
Step 2:
Add this :
pawn Код:
new gTeam[MAX_PLAYERS];
Step 3:
Add their skins under OnGameModeInit:
pawn Код:
AddPlayerClass(285,-334.5023,1535.5310,75.5625,181.2829,0,0,0,0,0,0); // Russian
    AddPlayerClass(287,213.3519,1867.2781,18.3741,359.5766,0,0,0,0,0,0); // United States
Step 4:
The under OnPlayerRequestClass do this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 268.4988,1884.0615,-30.0938);
    SetPlayerFacingAngle(playerid, 184.2539);
    SetPlayerCameraPos(playerid, 268.5090,1880.9513,-30.3906);
    SetPlayerCameraLookAt(playerid, 268.4988,1884.0615,-30.0938);
    SetPlayerTeamFromClass(playerid, classid);
    switch(classid)
    {
    case 0: GameTextForPlayer(playerid, "~r~RUSSIA", 5000, 3);
    case 1: GameTextForPlayer(playerid, "~b~USA", 5000, 3);
    }
    return 1;
}
This will show the name of the team when you are selecting skins.

Step 5:
The under OnPlayerRequestSpawn do this:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    {
         SetPlayerToTeamColor(playerid);
    }
    return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = RUSSIA;
        GameTextForPlayer(playerid,"~r~Russia",6,1);
    }
    if(classid == 1)
    {
        gTeam[playerid] = USA;
        GameTextForPlayer(playerid,"~b~United States",13,1);
    }
}

SetPlayerToTeamColor(playerid)
{
    if(gTeam[playerid] == RUSSIA)
    {
        SetPlayerColor(playerid,COLOR_RUSSIA);
    }
    if(gTeam[playerid] == USA)
    {
        SetPlayerColor(playerid,COLOR_USA);
    }
}
This will Set the players colour to the team.

Hope you understand this.
Reply


Messages In This Thread
How to create a simple faction? - by Sting. - 24.05.2012, 12:59
Re: How to create a simple faction? - by Sting. - 25.05.2012, 16:09
Re: How to create a simple faction? - by iFederal - 25.05.2012, 16:48
Re: How to create a simple faction? - by Faisal_khan - 25.05.2012, 17:03
Re: How to create a simple faction? - by Sting. - 27.05.2012, 03:02
Re: How to create a simple faction? - by ReneG - 27.05.2012, 03:06

Forum Jump:


Users browsing this thread: 1 Guest(s)