OnPlayerRequestSpawn
#1

how to make OnPlayerRequestSpawn system ?
example:
if someone chooses SWAT skin and press on spawn, it will tell him that this skin require bla bla bla, you cannot spawn a swat skin
Reply
#2

A good example is below, comes from my own TDM GM (https://sampforum.blast.hk/showthread.php?tid=464879).

pawn Код:
public OnGameModeInit();
{
    AddPlayerClass(105,-1952.4731,144.6503,26.2813,129.6875,0,0,0,0,0,0); // GROUP 1 SPAWN 1
    AddPlayerClass(106,-1977.5947,159.9818,27.6940,270.7932,0,0,0,0,0,0); // GROUP 1 SPAWN 2
    AddPlayerClass(271,-1968.5822,111.3440,27.6875,345.8059,0,0,0,0,0,0); // GROUP 1 SPAWN 3
    AddPlayerClass(270,-1978.4353,106.6088,27.6875,128.3738,0,0,0,0,0,0); // GROUP 1 SPAWN 4
    AddPlayerClass(111,-2467.9446,140.3007,35.1719,275.0369,0,0,0,0,0,0); // GROUP 2 SPAWN 1
    AddPlayerClass(112,-2473.5613,167.8929,35.1276,324.0218,0,0,0,0,0,0); // GROUP 2 SPAWN 2
    AddPlayerClass(113,-2447.1460,127.3225,35.1719,348.0073,0,0,0,0,0,0); // GROUP 2 SPAWN 3
    AddPlayerClass(126,-2435.6851,196.5303,35.1471,191.3992,0,0,0,0,0,0); // GROUP 2 SPAWN 4
    AddPlayerClass(173,-2747.0498,-298.4399,7.0283,124.6302,0,0,0,0,0,0); // GROUP 3 SPAWN 1
    AddPlayerClass(174,-2749.0925,-347.0935,7.1690,331.2417,0,0,0,0,0,0); // GROUP 3 SPAWN 2
    AddPlayerClass(175,-2719.9109,-318.3430,7.8438,73.8906,0,0,0,0,0,0); // GROUP 3 SPAWN 3
    AddPlayerClass(177,-2767.9602,-262.6047,7.1875,225.8169,0,0,0,0,0,0); // GROUP 3 SPAWN 4
    AddPlayerClass(221,-1681.8612,1350.0090,9.8047,43.3542,0,0,0,0,0,0); // GROUP 4 SPAWN 1
    AddPlayerClass(222,-1674.7875,1355.2260,7.1797,223.7917,0,0,0,0,0,0); // GROUP 4 SPAWN 2
    AddPlayerClass(223,-1629.9725,1418.9817,7.1875,211.2164,0,0,0,0,0,0); // GROUP 4 SPAWN 3
    AddPlayerClass(297,-1701.2769,1390.2626,7.1787,99.9379,0,0,0,0,0,0); // GROUP 4 SPAWN 4
    AddPlayerClass(280,-1616.0018,687.5595,7.1875,181.4945,0,0,0,0,0,0); // GROUP COP SPAWN 1
    AddPlayerClass(282,-1638.6371,698.7301,6.0176,227.1163,0,0,0,0,0,0); // GROUP COP SPAWN 2
    AddPlayerClass(283,-1625.9618,659.6985,7.1875,49.1646,0,0,0,0,0,0); // GROUP COP SPAWN 3
    AddPlayerClass(284,-1622.3274,659.9947,-5.2422,105.8276,0,0,0,0,0,0); // GROUP COP SPAWN 4
    AddPlayerClass(217,-2598.6526,2363.2122,9.8830,78.4680,0,0,0,0,0,0); // GROUP ADMIN SPAWN 1
    AddPlayerClass(3,-2395.0745,2219.4312,4.9844,110.7829,0,0,0,0,0,0); // GROUP ADMIN SPAWN 2
    AddPlayerClass(211,-2470.2908,2483.0083,17.5026,228.4926,0,0,0,0,0,0); // GROUP ADMIN SPAWN 3
    return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid); // declare this upon when the player is going to choose a class
    return 1;
}
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    switch(classid)
    {
        case 0: // case of classid of 0
        {
            gTeam[playerid] = TEAM_ITALIAN; // set the team (you will not have this variable most likely)
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6); // game text
            SetPlayerInterior(playerid, 0); // interior
            SetPlayerPos(playerid, -1952.4731, 144.6503, 26.2813); // position
            SetPlayerFacingAngle(playerid, 129.6875); // facing angle
            SetPlayerCameraPos(playerid, -1954.7084, 142.5232, 27.0294); // set the camera position
            SetPlayerCameraLookAt(playerid, -1952.4731, 144.6503, 26.2813); // set the camera facing position
            SetPlayerColor(playerid, TEAM_COLOR_GREEN); // set the team color
            return 1; // return true
        }
        case 1:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1977.5947, 159.9818, 27.6940);
            SetPlayerFacingAngle(playerid, 270.7932);
            SetPlayerCameraPos(playerid, -1975.1216, 160.1899, 27.6940);
            SetPlayerCameraLookAt(playerid, -1977.5947, 159.9818, 27.6940);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 2:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1968.5822,111.3440,27.6875);
            SetPlayerFacingAngle(playerid, 345.8059);
            SetPlayerCameraPos(playerid, -1968.0773,114.1654,27.6875);
            SetPlayerCameraLookAt(playerid, -1968.5822,111.3440,27.6875);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 3:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1978.4353,106.6088,27.6875);
            SetPlayerFacingAngle(playerid, 128.3738);
            SetPlayerCameraPos(playerid, -1980.3306,104.9670,27.6799);
            SetPlayerCameraLookAt(playerid, -1978.4353,106.6088,27.6875);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 4:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2467.9446,140.3007,35.1719);
            SetPlayerFacingAngle(playerid, 275.0369);
            SetPlayerCameraPos(playerid, -2465.6357,140.5779,35.1719);
            SetPlayerCameraLookAt(playerid, -2467.9446,140.3007,35.1719);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 5:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2473.5613,167.8929,35.1276);
            SetPlayerFacingAngle(playerid, 324.0218);
            SetPlayerCameraPos(playerid, -2472.0981,170.0587,35.1071);
            SetPlayerCameraLookAt(playerid, -2473.5613,167.8929,35.1276);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 6:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2447.1460,127.3225,35.1719);
            SetPlayerFacingAngle(playerid, 348.0073);
            SetPlayerCameraPos(playerid, -2446.8123,129.8497,35.1719);
            SetPlayerCameraLookAt(playerid, -2447.1460,127.3225,35.1719);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 7:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2435.6851,196.5303,35.1471);
            SetPlayerFacingAngle(playerid, 191.3992);
            SetPlayerCameraPos(playerid, -2434.5874,192.5599,35.1231);
            SetPlayerCameraLookAt(playerid, -2435.6851,196.5303,35.1471);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 8:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2747.0498,-298.4399,7.0283);
            SetPlayerFacingAngle(playerid, 124.6302);
            SetPlayerCameraPos(playerid, -2749.9463,-300.2413,7.0391);
            SetPlayerCameraLookAt(playerid, -2747.0498,-298.4399,7.0283);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 9:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2749.0925,-347.0935,7.1690);
            SetPlayerFacingAngle(playerid, 331.2417);
            SetPlayerCameraPos(playerid, -2747.6929,-344.0244,7.1797);
            SetPlayerCameraLookAt(playerid, -2749.0925,-347.0935,7.1690);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 10:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2719.9109,-318.3430,7.8438);
            SetPlayerFacingAngle(playerid, 73.8906);
            SetPlayerCameraPos(playerid, -2722.8000,-317.6968,7.7716);
            SetPlayerCameraLookAt(playerid, -2719.9109,-318.3430,7.8438);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 11:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2767.9602,-262.6047,7.1875);
            SetPlayerFacingAngle(playerid, 225.8169);
            SetPlayerCameraPos(playerid, -2765.6487,-264.9485,7.1875);
            SetPlayerCameraLookAt(playerid, -2767.9602,-262.6047,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 12:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1681.8612,1350.0090,9.8047);
            SetPlayerFacingAngle(playerid, 43.3542);
            SetPlayerCameraPos(playerid, -1684.0620,1352.3635,9.8047);
            SetPlayerCameraLookAt(playerid, -1681.8612,1350.0090,9.8047);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 13:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1674.7875,1355.2260,7.1797);
            SetPlayerFacingAngle(playerid, 223.7917);
            SetPlayerCameraPos(playerid, -1672.4031,1352.7843,7.1797);
            SetPlayerCameraLookAt(playerid, -1674.7875,1355.2260,7.1797);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 14:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1629.9725,1418.9817,7.1875);
            SetPlayerFacingAngle(playerid, 211.2164);
            SetPlayerCameraPos(playerid, -1628.1548,1415.6901,7.1875);
            SetPlayerCameraLookAt(playerid, -1629.9725,1418.9817,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 15:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1701.2769,1390.2626,7.1787);
            SetPlayerFacingAngle(playerid, 99.9379);
            SetPlayerCameraPos(playerid, -1704.3599,1389.5792,7.1826);
            SetPlayerCameraLookAt(playerid, -1701.2769,1390.2626,7.1787);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 16:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1616.0018,687.5595,7.1875);
            SetPlayerFacingAngle(playerid, 181.4945);
            SetPlayerCameraPos(playerid, -1616.1003,683.4143,7.1875);
            SetPlayerCameraLookAt(playerid, -1616.0018,687.5595,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 17:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1638.6371,698.7301,6.0176);
            SetPlayerFacingAngle(playerid, 227.1163);
            SetPlayerCameraPos(playerid, -1635.2449,695.5535,6.8040);
            SetPlayerCameraLookAt(playerid, -1638.6371,698.7301,6.0176);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 18:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1625.9618,659.6985,7.1875);
            SetPlayerFacingAngle(playerid, 49.1646);
            SetPlayerCameraPos(playerid, -1629.2073,662.3978,7.1875);
            SetPlayerCameraLookAt(playerid, -1625.9618,659.6985,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 19:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1622.3274,659.9947,-5.2422);
            SetPlayerFacingAngle(playerid, 105.8276);
            SetPlayerCameraPos(playerid, -1626.4871,659.0468,-5.2422);
            SetPlayerCameraLookAt(playerid, -1622.3274,659.9947,-5.2422);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 20:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2598.6526,2363.2122,9.8830);
            SetPlayerFacingAngle(playerid, 78.4680);
            SetPlayerCameraPos(playerid, -2601.5554,2362.9507,8.9658);
            SetPlayerCameraLookAt(playerid, -2598.6526,2363.2122,9.8830);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
        case 21:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2395.0745,2219.4312,4.9844);
            SetPlayerFacingAngle(playerid, 110.7829);
            SetPlayerCameraPos(playerid, -2398.7595,2217.8083,4.9844);
            SetPlayerCameraLookAt(playerid, -2395.0745,2219.4312,4.9844);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
        case 22:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2470.2908,2483.0083,17.5026);
            SetPlayerFacingAngle(playerid, 228.4926);
            SetPlayerCameraPos(playerid, -2467.8032,2481.0713,17.2140);
            SetPlayerCameraLookAt(playerid, -2470.2908,2483.0083,17.5026);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
    }
    return 1;
}
I'm sure you'd be able to see how it works, first you add the class with the skin, coordinates and weapon data, then you add that code underneath the OnPlayerRequestClass, then underneath that you add the code for the SetPlayerTeamFromClass (that doesn't need to be a function, just type it like that).
Reply
#3

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
A good example is below, comes from my own TDM GM (https://sampforum.blast.hk/showthread.php?tid=464879).

pawn Код:
public OnGameModeInit();
{
    AddPlayerClass(105,-1952.4731,144.6503,26.2813,129.6875,0,0,0,0,0,0); // GROUP 1 SPAWN 1
    AddPlayerClass(106,-1977.5947,159.9818,27.6940,270.7932,0,0,0,0,0,0); // GROUP 1 SPAWN 2
    AddPlayerClass(271,-1968.5822,111.3440,27.6875,345.8059,0,0,0,0,0,0); // GROUP 1 SPAWN 3
    AddPlayerClass(270,-1978.4353,106.6088,27.6875,128.3738,0,0,0,0,0,0); // GROUP 1 SPAWN 4
    AddPlayerClass(111,-2467.9446,140.3007,35.1719,275.0369,0,0,0,0,0,0); // GROUP 2 SPAWN 1
    AddPlayerClass(112,-2473.5613,167.8929,35.1276,324.0218,0,0,0,0,0,0); // GROUP 2 SPAWN 2
    AddPlayerClass(113,-2447.1460,127.3225,35.1719,348.0073,0,0,0,0,0,0); // GROUP 2 SPAWN 3
    AddPlayerClass(126,-2435.6851,196.5303,35.1471,191.3992,0,0,0,0,0,0); // GROUP 2 SPAWN 4
    AddPlayerClass(173,-2747.0498,-298.4399,7.0283,124.6302,0,0,0,0,0,0); // GROUP 3 SPAWN 1
    AddPlayerClass(174,-2749.0925,-347.0935,7.1690,331.2417,0,0,0,0,0,0); // GROUP 3 SPAWN 2
    AddPlayerClass(175,-2719.9109,-318.3430,7.8438,73.8906,0,0,0,0,0,0); // GROUP 3 SPAWN 3
    AddPlayerClass(177,-2767.9602,-262.6047,7.1875,225.8169,0,0,0,0,0,0); // GROUP 3 SPAWN 4
    AddPlayerClass(221,-1681.8612,1350.0090,9.8047,43.3542,0,0,0,0,0,0); // GROUP 4 SPAWN 1
    AddPlayerClass(222,-1674.7875,1355.2260,7.1797,223.7917,0,0,0,0,0,0); // GROUP 4 SPAWN 2
    AddPlayerClass(223,-1629.9725,1418.9817,7.1875,211.2164,0,0,0,0,0,0); // GROUP 4 SPAWN 3
    AddPlayerClass(297,-1701.2769,1390.2626,7.1787,99.9379,0,0,0,0,0,0); // GROUP 4 SPAWN 4
    AddPlayerClass(280,-1616.0018,687.5595,7.1875,181.4945,0,0,0,0,0,0); // GROUP COP SPAWN 1
    AddPlayerClass(282,-1638.6371,698.7301,6.0176,227.1163,0,0,0,0,0,0); // GROUP COP SPAWN 2
    AddPlayerClass(283,-1625.9618,659.6985,7.1875,49.1646,0,0,0,0,0,0); // GROUP COP SPAWN 3
    AddPlayerClass(284,-1622.3274,659.9947,-5.2422,105.8276,0,0,0,0,0,0); // GROUP COP SPAWN 4
    AddPlayerClass(217,-2598.6526,2363.2122,9.8830,78.4680,0,0,0,0,0,0); // GROUP ADMIN SPAWN 1
    AddPlayerClass(3,-2395.0745,2219.4312,4.9844,110.7829,0,0,0,0,0,0); // GROUP ADMIN SPAWN 2
    AddPlayerClass(211,-2470.2908,2483.0083,17.5026,228.4926,0,0,0,0,0,0); // GROUP ADMIN SPAWN 3
    return 1;
}
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid); // declare this upon when the player is going to choose a class
    return 1;
}
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    switch(classid)
    {
        case 0: // case of classid of 0
        {
            gTeam[playerid] = TEAM_ITALIAN; // set the team (you will not have this variable most likely)
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6); // game text
            SetPlayerInterior(playerid, 0); // interior
            SetPlayerPos(playerid, -1952.4731, 144.6503, 26.2813); // position
            SetPlayerFacingAngle(playerid, 129.6875); // facing angle
            SetPlayerCameraPos(playerid, -1954.7084, 142.5232, 27.0294); // set the camera position
            SetPlayerCameraLookAt(playerid, -1952.4731, 144.6503, 26.2813); // set the camera facing position
            SetPlayerColor(playerid, TEAM_COLOR_GREEN); // set the team color
            return 1; // return true
        }
        case 1:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1977.5947, 159.9818, 27.6940);
            SetPlayerFacingAngle(playerid, 270.7932);
            SetPlayerCameraPos(playerid, -1975.1216, 160.1899, 27.6940);
            SetPlayerCameraLookAt(playerid, -1977.5947, 159.9818, 27.6940);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 2:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1968.5822,111.3440,27.6875);
            SetPlayerFacingAngle(playerid, 345.8059);
            SetPlayerCameraPos(playerid, -1968.0773,114.1654,27.6875);
            SetPlayerCameraLookAt(playerid, -1968.5822,111.3440,27.6875);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 3:
        {
            gTeam[playerid] = TEAM_ITALIAN;
            GameTextForPlayer(playerid, "~g~The Italian Mafia", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1978.4353,106.6088,27.6875);
            SetPlayerFacingAngle(playerid, 128.3738);
            SetPlayerCameraPos(playerid, -1980.3306,104.9670,27.6799);
            SetPlayerCameraLookAt(playerid, -1978.4353,106.6088,27.6875);
            SetPlayerColor(playerid, TEAM_COLOR_GREEN);
            return 1;
        }
        case 4:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2467.9446,140.3007,35.1719);
            SetPlayerFacingAngle(playerid, 275.0369);
            SetPlayerCameraPos(playerid, -2465.6357,140.5779,35.1719);
            SetPlayerCameraLookAt(playerid, -2467.9446,140.3007,35.1719);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 5:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2473.5613,167.8929,35.1276);
            SetPlayerFacingAngle(playerid, 324.0218);
            SetPlayerCameraPos(playerid, -2472.0981,170.0587,35.1071);
            SetPlayerCameraLookAt(playerid, -2473.5613,167.8929,35.1276);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 6:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2447.1460,127.3225,35.1719);
            SetPlayerFacingAngle(playerid, 348.0073);
            SetPlayerCameraPos(playerid, -2446.8123,129.8497,35.1719);
            SetPlayerCameraLookAt(playerid, -2447.1460,127.3225,35.1719);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 7:
        {
            gTeam[playerid] = TEAM_VAGOS;
            GameTextForPlayer(playerid, "~y~San Fierro Vagos", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2435.6851,196.5303,35.1471);
            SetPlayerFacingAngle(playerid, 191.3992);
            SetPlayerCameraPos(playerid, -2434.5874,192.5599,35.1231);
            SetPlayerCameraLookAt(playerid, -2435.6851,196.5303,35.1471);
            SetPlayerColor(playerid, TEAM_COLOR_YELLOW);
            return 1;
        }
        case 8:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2747.0498,-298.4399,7.0283);
            SetPlayerFacingAngle(playerid, 124.6302);
            SetPlayerCameraPos(playerid, -2749.9463,-300.2413,7.0391);
            SetPlayerCameraLookAt(playerid, -2747.0498,-298.4399,7.0283);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 9:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2749.0925,-347.0935,7.1690);
            SetPlayerFacingAngle(playerid, 331.2417);
            SetPlayerCameraPos(playerid, -2747.6929,-344.0244,7.1797);
            SetPlayerCameraLookAt(playerid, -2749.0925,-347.0935,7.1690);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 10:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2719.9109,-318.3430,7.8438);
            SetPlayerFacingAngle(playerid, 73.8906);
            SetPlayerCameraPos(playerid, -2722.8000,-317.6968,7.7716);
            SetPlayerCameraLookAt(playerid, -2719.9109,-318.3430,7.8438);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 11:
        {
            gTeam[playerid] = TEAM_RIFA;
            GameTextForPlayer(playerid, "~r~Avispa Rifa", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2767.9602,-262.6047,7.1875);
            SetPlayerFacingAngle(playerid, 225.8169);
            SetPlayerCameraPos(playerid, -2765.6487,-264.9485,7.1875);
            SetPlayerCameraLookAt(playerid, -2767.9602,-262.6047,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_RED);
            return 1;
        }
        case 12:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1681.8612,1350.0090,9.8047);
            SetPlayerFacingAngle(playerid, 43.3542);
            SetPlayerCameraPos(playerid, -1684.0620,1352.3635,9.8047);
            SetPlayerCameraLookAt(playerid, -1681.8612,1350.0090,9.8047);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 13:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1674.7875,1355.2260,7.1797);
            SetPlayerFacingAngle(playerid, 223.7917);
            SetPlayerCameraPos(playerid, -1672.4031,1352.7843,7.1797);
            SetPlayerCameraLookAt(playerid, -1674.7875,1355.2260,7.1797);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 14:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1629.9725,1418.9817,7.1875);
            SetPlayerFacingAngle(playerid, 211.2164);
            SetPlayerCameraPos(playerid, -1628.1548,1415.6901,7.1875);
            SetPlayerCameraLookAt(playerid, -1629.9725,1418.9817,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 15:
        {
            gTeam[playerid] = TEAM_RUSSIAN;
            GameTextForPlayer(playerid, "~w~Russian Mobs", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1701.2769,1390.2626,7.1787);
            SetPlayerFacingAngle(playerid, 99.9379);
            SetPlayerCameraPos(playerid, -1704.3599,1389.5792,7.1826);
            SetPlayerCameraLookAt(playerid, -1701.2769,1390.2626,7.1787);
            SetPlayerColor(playerid, TEAM_COLOR_WHITE);
            return 1;
        }
        case 16:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1616.0018,687.5595,7.1875);
            SetPlayerFacingAngle(playerid, 181.4945);
            SetPlayerCameraPos(playerid, -1616.1003,683.4143,7.1875);
            SetPlayerCameraLookAt(playerid, -1616.0018,687.5595,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 17:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1638.6371,698.7301,6.0176);
            SetPlayerFacingAngle(playerid, 227.1163);
            SetPlayerCameraPos(playerid, -1635.2449,695.5535,6.8040);
            SetPlayerCameraLookAt(playerid, -1638.6371,698.7301,6.0176);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 18:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1625.9618,659.6985,7.1875);
            SetPlayerFacingAngle(playerid, 49.1646);
            SetPlayerCameraPos(playerid, -1629.2073,662.3978,7.1875);
            SetPlayerCameraLookAt(playerid, -1625.9618,659.6985,7.1875);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 19:
        {
            gTeam[playerid] = TEAM_POLICE;
            GameTextForPlayer(playerid, "~b~Police Officer", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -1622.3274,659.9947,-5.2422);
            SetPlayerFacingAngle(playerid, 105.8276);
            SetPlayerCameraPos(playerid, -1626.4871,659.0468,-5.2422);
            SetPlayerCameraLookAt(playerid, -1622.3274,659.9947,-5.2422);
            SetPlayerColor(playerid, TEAM_COLOR_BLUE);
            return 1;
        }
        case 20:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2598.6526,2363.2122,9.8830);
            SetPlayerFacingAngle(playerid, 78.4680);
            SetPlayerCameraPos(playerid, -2601.5554,2362.9507,8.9658);
            SetPlayerCameraLookAt(playerid, -2598.6526,2363.2122,9.8830);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
        case 21:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2395.0745,2219.4312,4.9844);
            SetPlayerFacingAngle(playerid, 110.7829);
            SetPlayerCameraPos(playerid, -2398.7595,2217.8083,4.9844);
            SetPlayerCameraLookAt(playerid, -2395.0745,2219.4312,4.9844);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
        case 22:
        {
            gTeam[playerid] = TEAM_ADMINS;
            GameTextForPlayer(playerid, "~p~Administration", 5000, 6);
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, -2470.2908,2483.0083,17.5026);
            SetPlayerFacingAngle(playerid, 228.4926);
            SetPlayerCameraPos(playerid, -2467.8032,2481.0713,17.2140);
            SetPlayerCameraLookAt(playerid, -2470.2908,2483.0083,17.5026);
            SetPlayerColor(playerid, TEAM_COLOR_PURPLE);
            return 1;
        }
    }
    return 1;
}
I'm sure you'd be able to see how it works, first you add the class with the skin, coordinates and weapon data, then you add that code underneath the OnPlayerRequestClass, then underneath that you add the code for the SetPlayerTeamFromClass (that doesn't need to be a function, just type it like that).
thanks for replying but this is not what i want, i know how to do what you say using OnPlayerSpawn callback.
what i want is to make some skins is unspawn able and requires cop rank x or reaching score 5000 bla bla
Reply
#4

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
thanks for replying but this is not what i want, i know how to do what you say using OnPlayerSpawn callback.
what i want is to make some skins is unspawn able and requires cop rank x or reaching score 5000 bla bla
Just a tip, you could simply use AddPlayerClassEx
pawn Код:
AddPlayerClassEx(teamid, skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo)


Quick Example
pawn Код:
new
    PlayerTeam[ MAX_PLAYERS ]
;

#define \
    TeamOne 0

public OnGameModeInit()
{
    AddPlayerClassEx(TeamOne, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);//Skin ID 3
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    if(GetPlayerScore(playerid) < 100 && PlayerTeam[playerid] == TeamOne)
        return SendClientMessage( playerid, -1, "[ERROR] - You need 100 score to spawn on this team." );
    return 1;
}
Reply
#5

Yea, I forgot to add something else, this is how I did under OnPlayerRequestSpawn to prevent someone from spawning i.e. with an admin skin whilst they're not an admin:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_ADMINS && PlayerData[playerid][pAdmin] <= 0)
    {
        new string[200];
        format(string, sizeof(string), "Only administrators of the server can use this skin.");
        SendClientMessage(playerid, COLOR_RED, string);
        return 0;
    }
    if(gPlayerRegistered[playerid] == 1 && gPlayerLogged[playerid] == 0)
    {
        new string[200];
        format(string, sizeof(string), "This account is registered, you must login before proceeding with a spawn.");
        SendClientMessage(playerid, COLOR_RED, string);
        return 0;
    }
    else if(gPlayerRegistered[playerid] == 1 && gPlayerLogged[playerid] == 1)
    {
        return 1;
    }
    else if(gPlayerRegistered[playerid] == 0 && gPlayerLogged[playerid] == 0)
    {
        return 1;
    }
    return 1;
}
I'm setting the teams at OnPlayerRequestClass, and then upon OnPlayerRequestSpawn, if that team is X and the player is not Y, then it will return 0 to stop the player from spawning. You could do this with global variables too instead of setting the teams straight away.
Reply
#6

do i have to forward the OnPlayerRequestSpawn callback ?
or it's defined by samp ?
Reply
#7

No, It's a default callback from #include "a_samp.inc"
Reply
#8

thanks i found it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)