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`
Huge Clucker
 
Elysian`'s Avatar
 
Join Date: Apr 2012
Location: Locating...
Posts: 438
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
Big Clucker
 
Join Date: Sep 2010
Posts: 199
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єχυѕ
Banned
 
Join Date: Apr 2012
Posts: 57
Reputation: 2
Default Re: Easy Class Selection.

How to get CameraPos? and CameraLookAt?
Nєχυѕ is offline   Reply With Quote
Old 24/04/2012, 03:52 PM   #4
Elysian`
Huge Clucker
 
Elysian`'s Avatar
 
Join Date: Apr 2012
Location: Locating...
Posts: 438
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єχυѕ
Banned
 
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.
Nєχυѕ is offline   Reply With Quote
Old 24/04/2012, 05:00 PM   #6
Elysian`
Huge Clucker
 
Elysian`'s Avatar
 
Join Date: Apr 2012
Location: Locating...
Posts: 438
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: 5,264
Reputation: 748
Default Re: Easy Class Selection.

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

See 'assumptions'.
__________________
>> Click here for ALL of my releases
mGates - Create AUTOMATIC gates with ONE FUNCTION (+ restrictions i.e. team members only)
IEE (Interior Enter/Exits) - Create enex markers with one function
Cuffs - Cuff offsets for ALL SKINS!
vfunc - Vehicle functions. GetVehicleColor and synced random colors.
gBug - Prevent the 'G' bug (players being able to enter moving vehicles by pressing G then running after them).
MP2 is offline   Reply With Quote
Old 24/04/2012, 06:17 PM   #8
Elysian`
Huge Clucker
 
Elysian`'s Avatar
 
Join Date: Apr 2012
Location: Locating...
Posts: 438
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
Huge Clucker
 
Join Date: Dec 2009
Location: UK, Wales
Posts: 301
Reputation: 18
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`
Huge Clucker
 
Elysian`'s Avatar
 
Join Date: Apr 2012
Location: Locating...
Posts: 438
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 05:19 PM
Class selection help _Sprite_ Help Archive 5 06/12/2010 03:27 PM
help me with Class Selection Showing the class name The_Cobra Help Archive 2 05/02/2010 05:22 PM
Class selection Goobiiify Help Archive 4 18/08/2009 12:09 PM


All times are GMT. The time now is 04:23 PM.


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