Classs selection for new players
#1

Hello friends i want to ask you how to make class selection.I made registration but now i need code to paste it in
Код:
public OnPlayerRequestClass(playerid, classid)
.I want to make that player can choose any skin.
Reply
#2

First define your teams:
pawn Код:
#define RUSSIA          1
#define USA             2
#define AFGHANISTAN     3
#define GERMANY         4
#define JAPAN           5
#define COLOR_RUSSIA        COLOR_BRIGHTRED
#define COLOR_USA           COLOR_LIGHTBLUE
#define COLOR_AFGHANISTAN   COLOR_TAN
#define COLOR_GERMANY       COLOR_GREEN
#define COLOR_JAPAN         COLOR_WHITE
new gTeam[MAX_PLAYERS];
Then add your skin 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
    AddPlayerClass(73,-1327.0896,2544.6479,86.4345,269.1425,0,0,0,0,0,0); //Afghanistan
    AddPlayerClass(165,-220.9162,2619.3599,62.7527,186.1895,0,0,0,0,0,0); // Germany
    AddPlayerClass(123,435.6286,2541.2283,19.2019,178.5884,0,0,0,0,0,0); // Japan
Then under OnPlayerRequestClass:
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);
    return 1;
}
Then under OnPlayerRequestSpawn:
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    {
        ShowPlayerDialog(playerid, 500, DIALOG_STYLE_LIST, "Classes", "Assault\nSniper\nPilot\nEngineer\nFlameThrower\nDemolition", "Select", "Cancel");
        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);
    }
    if(classid == 2)
    {
        gTeam[playerid] = AFGHANISTAN;
        GameTextForPlayer(playerid,"COLOR_TAN Afghanistan",11,1);
    }
    if(classid == 3)
    {
        gTeam[playerid] = GERMANY;
        GameTextForPlayer(playerid,"~g~Germany",7,1);
    }
    if(classid == 4)
    {
        gTeam[playerid] = JAPAN;
        GameTextForPlayer(playerid,"~w~Japan",7,1);
    }
}

SetPlayerToTeamColor(playerid)
{
    if(gTeam[playerid] == RUSSIA)
    {
        SetPlayerColor(playerid,COLOR_RUSSIA);
    }
    if(gTeam[playerid] == USA)
    {
        SetPlayerColor(playerid,COLOR_USA);
    }
    if(gTeam[playerid] == AFGHANISTAN)
    {
        SetPlayerColor(playerid,COLOR_AFGHANISTAN);
    }
    if(gTeam[playerid] == GERMANY)
    {
        SetPlayerColor(playerid,COLOR_GERMANY);
    }
    if(gTeam[playerid] == JAPAN)
    {
        SetPlayerColor(playerid,COLOR_JAPAN);
    }
}
Hope you got it.
Reply
#3

Under GameModeInit put this, replace x, y, z and angle with your own coords.
pawn Код:
for(new cx=0; cx<300; cx++) //Makes a loop from 0 to 299 (all skins)
{
    AddPlayerClass(cx, x, y, z, angle, 0, 0, 0, 0, 0, 0);
}
For class selection, replace x, y, z with the coords where the player should be, angle wich way he should be facing, and replace Cx, Cy and Cz with the coords of the camera.
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, x, y, z);
    SetPlayerFacingAngle(playerid, angle);
    SetPlayerCameraPos(playerid, Cx, Cy, Cz);
    SetPlayerCameraLookAt(playerid, x, y, z);
    return 1;
}
EDIT: How did you have time to write all that in so short time O_o
Reply
#4

Quote:
Originally Posted by [NWA]Hannes
Посмотреть сообщение
EDIT: How did you have time to write all that in so short time O_o
I think he copied it from his own gamemode.
Reply
#5

Quote:
Originally Posted by Unfriendly
Посмотреть сообщение
I think he copied it from his own gamemode.
Absolutely right. It was my first GM when I was a newbie.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)