How to set a team limit on my faction -
ruckfules99 - 17.02.2010
How can i set a team limit for my army team? I know this has been asked many times, but this has never been explained properly and most of the topics that it's been asked in have no replies.
So can someone give me a fully explained answer, I know more then 5 people asking the same questions
Heres my "Onplayerrequestspawn" If it helps
Код:
if(gTeam[playerid] == TEAM_ARMY && CanUseArmy[playerid] == 0) {
GameTextForPlayer(playerid,"~w~You cannot use this class/skill~n~You do not have the required permissions to play as~n~~b~SA army",5000,3);
return 0;
}
This only tells if you have army rights or not, I don't know if this would be useful or not, but i put it out there anyway
Re: How to set a team limit on my faction -
ruckfules99 - 17.02.2010
anyone?
Re: How to set a team limit on my faction -
ruckfules99 - 17.02.2010
I know someone knows, Please help.
Re: How to set a team limit on my faction -
woot - 17.02.2010
Very basic .. Heres an example, make sure you take away 1 etc when disconnecting or whenever the player changes his team.
pawn Код:
new TeamCount[ 10 ]; // Edit the size depending on how much teams you have
public OnPlayerSpawn(playerid)
{
TeamCount[ gTeam[ playerid ] ]++;
}
Re: How to set a team limit on my faction -
ruckfules99 - 17.02.2010
Quote:
|
Originally Posted by //exora
Very basic .. Heres an example, make sure you take away 1 etc when disconnecting or whenever the player changes his team.
pawn Код:
new TeamCount[ 10 ]; // Edit the size depending on how much teams you have
public OnPlayerSpawn(playerid) { TeamCount[ gTeam[ playerid ] ]++; }
|
i did not understand when you said "make sure you take away 1 etc when disconnecting or whenever the player changes his team."
I've never seen how to do this before nor do i no how lol, Can you explain a bit more
Re: How to set a team limit on my faction -
woot - 17.02.2010
k the newb way ..
Let's say, you have TEAM_ARMY
Then you create a new global variable, outside of all functions.
Now, when a players team is changed to "TEAM_ARMY", then you add +1 to TEAM_ARMY_COUNT
++ is the same as PLUS ONE, so you add ONE to the variable TEAM_ARMY_COUNT
pawn Код:
if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT++;
Lets say you add this ^ to OnPlayerSpawn, then you could check like ..
pawn Код:
if(TEAM_ARMY_COUNT >= 5) return SendClientMessage(playerid, COLOR_RED, "The army team is full! (5 Players)");
This ^ is how to prevent the player from chosing it.
When a player disconnects and his team is TEAM_ARMY, then remove it from his variable. Examply; OnPlayerDisconnect
pawn Код:
if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT--;
Re: How to set a team limit on my faction -
ruckfules99 - 17.02.2010
Ok, I tryed doing what you've told me, and this is how i did it. i am a nooby scripter, so I'm not exactly sure how to do it....
Код:
new TEAM_ARMY_COUNT;
(obviously easily added)
Then under "Onplayerspawn" I put
Код:
}else if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT++; {
if(TEAM_ARMY_COUNT >= 5) return SendClientMessage(playerid, COLOR_RED, "The army team is full! (5 Players)");
{
SendClientMessage(playerid,0x1E90FFAA, "Type /commands for your commands");
SendClientMessage(playerid,0x1E90FFAA, "SA ARMY: Your objective is to take out MOST WANTED (Level 10 +) suspects only");
SendClientMessage(playerid,0x1E90FFAA, "If you dont need to kill the suspect, then don't. Use /ar to arrest instead");
SendClientMessage(playerid,0x1E90FFAA, "Remember: This is not a deathmatch server. Please abide by the /rules and enjoy");
hastazer[playerid] =1;
HasLawEnforcementRadio[playerid] =1;
LawEnforcementRadio[playerid] =1;
Then under "OnplayerDisconnect"
I put
Код:
public OnPlayerDisconnect(playerid, reason)
{
if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT--;
{
//the rest of my stuff
}
return 1;
}
i get these errors after i do all that:
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found "if"
All on line "2776"
Heres line 2776:
Код:
}else if(gTeam[playerid] == TEAM_MEDIC) {
Re: How to set a team limit on my faction -
WSD - 17.02.2010
nice ive been looking for a script to do this for my server!!!!
ty exora
Re: How to set a team limit on my faction -
ruckfules99 - 17.02.2010
Quote:
|
Originally Posted by WSD
nice ive been looking for a script to do this for my server!!!!
ty exora 
|
WSD can you tell me how you did it? Im having so much trouble with thisl.....
Re: How to set a team limit on my faction -
WSD - 18.02.2010
sure but it might still be a bit complicated:
add this to the top of your script below the #includes:
new TEAM_ARMY_COUNT;
add this under OnPlayerSpawn:
if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT++;
now add this to OnPlayerRequestClass:
if(TEAM_ARMY_COUNT >= 5) return SendClientMessage(playerid, COLOR_RED, "The army team is full! (5 Players)");
this could be the complicated part,
if you have OnPlayerDisconnect in your gamemode script, add this:
if(gTeam[playerid] == TEAM_ARMY) TEAM_ARMY_COUNT--;
if not add this under a callback in the script:
public OnPlayerDisconnect();
{
then add the line above