[Tutorial] Easy Class Selection.
#1

Easy Class Selection!
Hello,
Today I will teach you how to make easy class selections in a few steps!


Let's get started:
First of all,
You want to use the AddPlayerClass function.

Код:
AddPlayerClass(288,2296.5662,2451.6270,10.8203,87.8270,0,0,0,0,0,0);
(This will spawn a Police officer on those coords with no weapons. You may use my one if you wish.)


After adding your classes you move on to OnPlayerRequestClass. We will be using (switch).
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    switch(classid) // switch between the classid's displayed in OnGameModeInit.
    {
        case 0, 1: // The number of classes that use this function.
        {
            //Police Spawn
            SetPlayerPos(playerid, 2296.5662,2451.6270, 10.8203); //this is the players position
            SetPlayerFacingAngle(playerid, 87.8270); //their facing angle
           
            //Camera Position Police
            SetPlayerCameraPos(playerid, 2293.3640,2451.7341,12.8203); //this is the cameras position FACING your skin.
           
            //Police Spawn
            SetPlayerCameraLookAt(playerid, 2296.5662,2451.6270, 10.8203); //this is what the camera will look at
           
            PlayerInfo[playerid][Team] = Cops; // if you use a team, This will set them to Team "cops"
        }
        case 2, 3:
        {
            SetPlayerPos(playerid, 2516.9578,2447.6992,11.0313); //this is the players position
            SetPlayerFacingAngle(playerid, 269.7719); //their facing angle
            SetPlayerCameraPos(playerid, 2521.2405,2447.5195,12.0313); //this is the cameras position

            SetPlayerCameraLookAt(playerid, 2516.9578,2447.6992,11.0313); //this is what the camera will look at
            PlayerInfo[playerid][Team] = Civilian;
        }
    }
    return 1;
}
Last but not least, to force a player class selection after connecting, add this under OnPlayerConnect:
pawn Код:
ForceClassSelection(playerid);
Hope this helps you.
(First tutorial, no hate?)
Reply
#2

Hmm,I've got one question:
- What's point af adding team at Request Class? :\
Add team at player spawn
Reply
#3

How to get CameraPos? and CameraLookAt?
Reply
#4

Quote:
Originally Posted by Hoss
Посмотреть сообщение
Hmm,I've got one question:
- What's point af adding team at Request Class? :\
Add team at player spawn
What do you mean? You do not have to use teams if you do not wish too..

Quote:
Originally Posted by Nєχυѕ
Посмотреть сообщение
How to get CameraPos? and CameraLookAt?
Say if you took the coords standing infront of the Los Santos police station..
You use /save again infront of the player facing the Police Station. If you know what I mean?
Reply
#5

Quote:
Originally Posted by Windows32
Посмотреть сообщение
What do you mean? You do not have to use teams if you do not wish too..



Say if you took the coords standing infront of the Los Santos police station..
You use /save again infront of the player facing the Police Station. If you know what I mean?
You kidding me? Man , that gives the x,y,z coords.
Reply
#6

Yes I know that, it will tell the camera what coords to look at, hence CameraLookAt.
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=57018

See 'assumptions'.
Reply
#8

What's that about?
Reply
#9

C:\Users\Ghost\Desktop\Unique Freeroam\gamemodes\freeroam.pwn(144) : error 033: array must be indexed (variable "Team")
C:\Users\Ghost\Desktop\Unique Freeroam\gamemodes\freeroam.pwn(153) : error 033: array must be indexed (variable "Team")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#10

Add "Team" in your enum.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)