SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 25/07/2016, 06:59 AM   #1
Ankon
Little Clucker
 
Join Date: May 2015
Posts: 37
Reputation: 0
Question Need help in a team selection system

Hey friends and I am here with a serious question..
I was trying to make the team selection system with defining gTeam....and all that..(sigh)
Basically at OnPlayerRequestClass I used cases to set the player's camera and the showing position but I wanted to spawn the player elsewhere(not where it was showed)
Also each team has three skins and three different spawn location and there are multiple teams(as usual)
All these factors confused me so much that I couldn't sleep that night..
Can anyone show me how to do it in an orderly manner yet fulfilling all the requirements mentioned below..

1.Each Team has 3 class(3 skins, 3 different spawn points and different show locations)
*By show locations I mean where they will be showed at OnPlayerRequestClass callback..and the show locations should be different from the spawn location.

2.There are multiple teams(as usual in every server)

3.Also, even though there are 3 spawn points all of that team should have same team color..

Would be helpful if you solved this problem...
Thanks in advance
__________________
Ankon is offline   Reply With Quote
Old 25/07/2016, 09:41 AM   #2
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,242
Reputation: 525
Default Re: Need help in a team selection system

You need to read more into the functions you have in the gamemode, and server.

Even though you are using PlayerClass functions, when they OnPlayerSpawn you can still set their spawn location by simply invoking SetPlayerPos.

Same with OnPlayerRequestClass. (Which is when they are switching classes, in the Class Selection window)

PHP Code:
OnPlayerConnect // First connection

OnPlayerRequestClass // First class selection/switching classes (Add SetPlayerPos, SetPlayerInterior, SetPlayerFacingAngle, SetPlayerCameraPos SetPlayerCameralLookAt in here for your spawn screen location.)
OnPlayerRequestSpawn // Selecting to spawn
OnPlayerSpawn // Upon spawning use SetPlayerPos, SetPlayerFacingAngle, SetPlayerInterior, and SetCameraBehindPlayer 
Read into the teams system. When you set the team via the native sa-mp server it also turns FriendlyFire off with no option to reenable it.

I noticed Gammix has an include called gTeams, which could help you out.
Sew_Sumi is offline   Reply With Quote
Old 25/07/2016, 10:06 AM   #3
Ankon
Little Clucker
 
Join Date: May 2015
Posts: 37
Reputation: 0
Default Re: Need help in a team selection system

Thanks for helping..
Well I got a way to make things working...
Could you verify that this way would work or not..
Firstly I made a gteam variable and put all the teams as for example arabia1, arabia2, arabia2 and so on...so now I can also set their spawn points manually on the onplayerspawn callback....
Now time to take the values of gTeam variable and to out them all in one....just like joining pieces of puzzle..
I will create a function when arabia1, arabia2, arabia3 would come into a single team...Arabia
And now I can use gteam2 to give the value Arabia in total....and whenever I use any team commands we can then use that gteam2 to check the player's team...
Yea...my idea....full fills all the things I mentioned but is a bit messy tho....still
Would it work?
__________________
Ankon is offline   Reply With Quote
Old 25/07/2016, 12:48 PM   #4
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,242
Reputation: 525
Default Re: Need help in a team selection system

It will.

A good idea is to separate the admins and the teams so any team member can be an admin,

I'm guessing that you've upgraded your IDE from pawno to notepad++ or another equivalent.
Sew_Sumi is offline   Reply With Quote
Old 26/07/2016, 04:17 AM   #5
Ankon
Little Clucker
 
Join Date: May 2015
Posts: 37
Reputation: 0
Default Re: Need help in a team selection system

Yes I did...who uses the year old pawno?
__________________
Ankon is offline   Reply With Quote
Old 26/07/2016, 05:01 AM   #6
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,242
Reputation: 525
Default Re: Need help in a team selection system

Oh you'd be surprised how many forgo the advantage of code folding and tab lines.
Sew_Sumi is offline   Reply With Quote
Old 26/07/2016, 10:00 PM   #7
Shinja
Gangsta
 
Shinja's Avatar
 
Join Date: Jan 2016
Posts: 972
Reputation: 107
Default Re: Need help in a team selection system

Code:
public OnGameModeInit()
{
	//team1
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	
	//team2
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    new team1skins[] = {0,1,2};
    new team2skins[] = {3,4,5};
	switch(classid)
	{
	    case 0..2:
	    {
	        SetPlayerSkin(playerid, team1skins[random(3)]);
	        SetPlayerTeam(playerid, 1);
		SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
		SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
		SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	     }
	     case 3..5:
	     {
	        SetPlayerSkin(playerid, team2skins[random(3)]);
	        SetPlayerTeam(playerid, 2);
		SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
		SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
		SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	     }
	}
	return 1;
}
I'm not sure if i got you, but i council you to use case x..y: //a.k.a classid => x && classid =< y
Shinja 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
Team Selection Problem NeamPojma Scripting Help 3 22/06/2015 12:03 PM
Help with team selection Nabster Scripting Help 4 07/03/2015 12:28 PM
Team selection with dialogs MSI Scripting Help 4 24/01/2012 02:57 PM
Need help with team selection.. Request Scripting Help 2 02/01/2012 06:26 PM


All times are GMT. The time now is 12:22 PM.


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