SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 24/04/2012, 03:30 PM   #1
Elysian`
Banned
 
Join Date: Apr 2012
Location: Locating...
Posts: 460
Reputation: 35
Thumbs up Easy Class Selection.

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.

Code:
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 Code:
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 Code:
ForceClassSelection(playerid);

Hope this helps you.
(First tutorial, no hate?)

Last edited by Elysian`; 26/06/2012 at 08:00 PM.
Elysian` is offline   Reply With Quote
Old 24/04/2012, 03:48 PM   #2
Hoss
Huge Clucker
 
Join Date: Sep 2010
Posts: 201
Reputation: 85
Default Re: Easy Class Selection.

Hmm,I've got one question:
- What's point af adding team at Request Class? :\
Add team at player spawn
Hoss is offline   Reply With Quote
Old 24/04/2012, 03:49 PM   #3
Nєχυѕ
Big Clucker
 
Nєχυѕ's Avatar
 
Join Date: Apr 2012
Posts: 57
Reputation: 2
Default Re: Easy Class Selection.

How to get CameraPos? and CameraLookAt?
__________________
DM Servers - [A]ss[4]sin ,Racing servers - N3XUS ,Crazy Stunt servers - N3XUS , Psycho.
Nєχυѕ is offline   Reply With Quote
Old 24/04/2012, 03:52 PM   #4
Elysian`
Banned
 
Join Date: Apr 2012
Location: Locating...
Posts: 460
Reputation: 35
Default Re: Easy Class Selection.

Quote:
Originally Posted by Hoss View Post
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єχυѕ View Post
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?
Elysian` is offline   Reply With Quote
Old 24/04/2012, 04:53 PM   #5
Nєχυѕ
Big Clucker
 
Nєχυѕ's Avatar
 
Join Date: Apr 2012
Posts: 57
Reputation: 2
Default Re: Easy Class Selection.

Quote:
Originally Posted by Windows32 View Post
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.
__________________
DM Servers - [A]ss[4]sin ,Racing servers - N3XUS ,Crazy Stunt servers - N3XUS , Psycho.
Nєχυѕ is offline   Reply With Quote
Old 24/04/2012, 05:00 PM   #6
Elysian`
Banned
 
Join Date: Apr 2012
Location: Locating...
Posts: 460
Reputation: 35
Default Re: Easy Class Selection.

Yes I know that, it will tell the camera what coords to look at, hence CameraLookAt.
Elysian` is offline   Reply With Quote
Old 24/04/2012, 05:52 PM   #7
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,316
Reputation: 905
Default Re: Easy Class Selection.

http://forum.sa-mp.com/showthread.php?t=57018

See 'assumptions'.
__________________
>> Click here to see my releases.

Please do not PM me requesting help. Here you have a forum with 11,000+ active users - why are you limiting your help to one person?
MP2 is offline   Reply With Quote
Old 24/04/2012, 06:17 PM   #8
Elysian`
Banned
 
Join Date: Apr 2012
Location: Locating...
Posts: 460
Reputation: 35
Default Re: Easy Class Selection.

What's that about?
Elysian` is offline   Reply With Quote
Old 26/04/2012, 12:48 PM   #9
sanplayer
Banned
 
Join Date: Dec 2009
Location: UK, Wales
Posts: 325
Reputation: 20
Default Re: Easy Class Selection.

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 (c) 1997-2006, ITB CompuPhase


2 Errors.
sanplayer is offline   Reply With Quote
Old 26/04/2012, 05:00 PM   #10
Elysian`
Banned
 
Join Date: Apr 2012
Location: Locating...
Posts: 460
Reputation: 35
Default Re: Easy Class Selection.

Add "Team" in your enum.
Elysian` is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP] Class Selection - Showing the class name? CrucixTM Scripting Help 13 26/04/2012 06:38 PM
Help Setting A Player Class before class selection Madd Kat Scripting Help 5 09/02/2012 06:19 PM
Class selection help _Sprite_ Help Archive 5 06/12/2010 04:27 PM
help me with Class Selection Showing the class name The_Cobra Help Archive 2 05/02/2010 06:22 PM
Class selection Goobiiify Help Archive 4 18/08/2009 12:09 PM


All times are GMT. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.