Problem with map changing system
#1

Hi,
There are two team attackers and defenders. attackers have to steal the vehicle from defenders. i have a problem: when attackers can't steal the vehicle and mission timer got over so attackers team get mission failed gametext and defending team get mission passed gametext but after 5-6 seconds again a Gametext appears for attackers and defenders in which attackers get mission passed and defenders get mission failed and the gamemode also don't change to get forward on next mission.

Codes:
Код:
forward NoExplode(playerid);
public NoExplode(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
    			PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
    			SetTimer("Finshed",6000,false);
        	    if(gTeam[i] == TEAM_ATTACKERS)
        	    {
        	        GameTextForPlayer(i, "~g~ ~n~Mission Passed", 6000, 4);
        	        PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
        	        GivePlayerMoney(i, 10000);
   	        	    SetPlayerScore(i,GetPlayerScore(i)+5);
   	        	    SendClientMessage(playerid,yellow,"{7C7C7C}» You've Recieved 5 Points and $10,000 for Completing the mission Objective.");
					SetPlayerCameraPos(i, 1930.1677,-571.0945,23.8120);
					SetPlayerCameraLookAt(i, 1911.5667,-563.5245,25.0610);
        	    }
        	    else if(gTeam[i] == TEAM_DEFENDERS)
        	    {
        	        GameTextForPlayer(i, "~r~ ~n~Mission Failed", 6000, 4);
        	        PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
        	        SendClientMessage(playerid,yellow,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
					SetPlayerCameraPos(i, 1930.1677,-571.0945,23.8120);
					GivePlayerMoney(i,-2000);
					SetPlayerCameraLookAt(i, 1911.5667,-563.5245,25.0610);
        	    }
    SetTimer("Finshed",2000,false);
}
}
	return 1;
}

forward NoExplode2(playerid);
public NoExplode2(playerid)
{
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
    PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
        	    if(gTeam[i] == TEAM_DEFENDERS)
        	    {
        	        GameTextForPlayer(i, "~g~ ~n~Mission Passed", 6000, 4);
        	        SendClientMessage(playerid,yellow,"{7C7C7C}» You've Recieved 5 Points and $10,000 for Completing the mission Objective.");
        	        GivePlayerMoney(i, 10000);
   	        	    SetPlayerScore(i,GetPlayerScore(i)+5);
       	    	    SetTimer("Finshed", 6000, 0);
   	    	        PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
        	    }
        	    else if(gTeam[i] == TEAM_ATTACKERS)
        	    {
        	        GameTextForPlayer(i, "~r~ ~n~Mission Failed", 6000, 4);
       	            SendClientMessage(playerid,yellow,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
	                PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					GivePlayerMoney(i, -2000);
	    			SetTimer("Finshed",6000,false);
        	    }
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    SendClientMessage(playerid,0xFF00FFFFF,"{55FF00}» Success : {FFFFFF}Your Stats have been Successfully Saved.");
    SetTimer("Finshed",2000,false);
    }
}
	return 1;
}

public Finshed(playerid)
{
   	SendRconCommand("changemode next-mission-name-here");
    return 1;
}

public Finshed2(playerid)
{
	for(new i = 0; playerid < MAX_PLAYERS; playerid++)
    {
        if(IsPlayerConnected(i))
        {
            if(gTeam[i] == TEAM_DEFENDERS)
            {
			GameTextForPlayer(i, "~r~ Mission Failed", 6000, 4);
			SendClientMessageToAll(COLOR_RED, "{E4E05D}» The Security Guards have Successfully defend the Helicopter from the Thieves.");
				SetTimer("Finshed", 2000, 0);
            }
            else if(gTeam[i] == TEAM_ATTACKERS)
            {
        	        GameTextForPlayer(i, "~g~ Mission Passed", 6000, 4);
        	        GivePlayerMoney(i, 10000);
        	        SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
            }
        }
    }
	SetTimer("Finshed", 2000, 0);
    return 1;
}

forward Load(playerid);
public Load(playerid)
{
	SetTimerEx("NoExplode2",290000,false,"i", playerid);
}
Reply
#2

I can help you with the gamemode changing but with others im not sure

SendRconCommand("changemode You must type here your next mission name ");
Reply
#3

" SendRconCommand("changemode You must type here your next mission name "); "
this is already in my gamemode. i didn't mentioned the next map name. see the codes carefully :c
Reply
#4

Why do you have two functions doing the same thing?

All you did was replace Mission Passed by Mission Failed or vice-versa for Attackers/Defenders in your public NoExplode2() function... Obviously, you'll get the opposite message repeated.

Just remove NoExplode2 and make a new team (for ex. fTeam) which checks for the failure and add it with else-if using the right conditions in NoExplode. Modify the GameText and SendClientMessage as per needs.
Reply
#5

Remember to make pairs in your else if conditions (You'll have 4 else if blocks)

Ex:
PHP код:
if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//print the win message for defenders and fail message for attackers.

EDIT: Sorry for the double post, can't see what I'm exactly doing on my Mobile.
Reply
#6

you mean i need to add
Код:
if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//print the win message for defenders and fail message for attackers.
}
instead of

Код:
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
    PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
        	    if(gTeam[i] == TEAM_DEFENDERS)
        	    {
        	        GameTextForPlayer(i, "~g~ ~n~Mission Passed", 6000, 4);
        	        SendClientMessage(playerid,yellow,"{7C7C7C}» You've Recieved 5 Points and $10,000 for Completing the mission Objective.");
        	        GivePlayerMoney(i, 10000);
   	        	    SetPlayerScore(i,GetPlayerScore(i)+5);
       	    	    SetTimer("Finshed", 6000, 0);
   	    	        PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
        	    }
        	    else if(gTeam[i] == TEAM_ATTACKERS)
        	    {
        	        GameTextForPlayer(i, "~r~ ~n~Mission Failed", 6000, 4);
       	            SendClientMessage(playerid,yellow,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
	                PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					GivePlayerMoney(i, -2000);
	    			SetTimer("Finshed",6000,false);
        	    }
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    SendClientMessage(playerid,0xFF00FFFFF,"{55FF00}» Success : {FFFFFF}Your Stats have been Successfully Saved.");
    SetTimer("Finshed",2000,false);
Under
Код:
forward NoExplode2(playerid);
public NoExplode2(playerid)
{
Reply
#7

Quote:
Originally Posted by NGEN123
Посмотреть сообщение
you mean i need to add
Код:
if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//print the win message for defenders and fail message for attackers.
}
instead of

Код:
	for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
    PlayerPlaySound(playerid, 1185, 0.0, 0.0, 0.0);
        	    if(gTeam[i] == TEAM_DEFENDERS)
        	    {
        	        GameTextForPlayer(i, "~g~ ~n~Mission Passed", 6000, 4);
        	        SendClientMessage(playerid,yellow,"{7C7C7C}» You've Recieved 5 Points and $10,000 for Completing the mission Objective.");
        	        GivePlayerMoney(i, 10000);
   	        	    SetPlayerScore(i,GetPlayerScore(i)+5);
       	    	    SetTimer("Finshed", 6000, 0);
   	    	        PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
        	    }
        	    else if(gTeam[i] == TEAM_ATTACKERS)
        	    {
        	        GameTextForPlayer(i, "~r~ ~n~Mission Failed", 6000, 4);
       	            SendClientMessage(playerid,yellow,"{FF0000}» You've Lost -$2000 Money for Not completing the Mission Objective.");
					SetPlayerCameraPos(i, 1276.0552,-788.1879,96.9662);
					SetPlayerCameraLookAt(i, 1288.8605,-788.3223,96.4609);
	                PlayerPlaySound(i, 1185, 0.0, 0.0, 0.0);
					GivePlayerMoney(i, -2000);
	    			SetTimer("Finshed",6000,false);
        	    }
    PlayerPlaySound(playerid, 1085, 0.0, 0.0, 0.0);
    SendClientMessage(playerid,0xFF00FFFFF,"{55FF00}» Success : {FFFFFF}Your Stats have been Successfully Saved.");
    SetTimer("Finshed",2000,false);
Under
Код:
forward NoExplode2(playerid);
public NoExplode2(playerid)
{
You do not remove the whole thing.
Only replace your if-elses with mine and keep the for loops and other callbacks like SendClientMessage, SetTimer.etc.
(change the messages for each case since it would be different.)

What I have done is basically like switch-case.

You'll have a total of 3 if else statements:
PHP код:
1. if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//body
}
2. else if(gTeam[i] == TEAM_ATTACKERS && fTeam[i] == TEAM_DEFENDERS)
{
//body
}
3. else
{
//body when no one wins (timer runs out)

I'm pretty sure including this in NoExplode should fix one of your problems you mentioned. (remember to make NoExplode2 as a comment and test out what I have provided once to make sure everything is running alright.)

Points to remember:
1. You have to make a new team like gTeam called fTeam.
2. gTeam is the team which wins and fTeam is the team which loses.
3. Keep the for loops and if-else body but change the if statements with mine.
4. Change the messages for each if else body since the outcome is different.
5. Include everything within for loop and if(IsPlayerConnnected(i))

I hope you're understanding what I'm saying.

Regards,
SpaceX.
Reply
#8

Код:
1. if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//body
}
2. else if(gTeam[i] == TEAM_ATTACKERS && fTeam[i] == TEAM_DEFENDERS)
{
//body
}
3. else
{
//body when no one wins (timer runs out)
}
1. If Team attackers successfully steal the vehicle and deliever it so they win ok.
2. If team attackers got unsuccessfull so the team defenders will win.

The point 2 is same as point 3. that you have mentioned the your codes.





Sorry for the bump. :c
Reply
#9

So here i have replace gTeam = Defender TO fTeam = Defender in my whole script

is it correct?
Reply
#10

You have not read my post correctly.

PHP код:
1. if(gTeam[i] == TEAM_DEFENDERS && fTeam[i] == TEAM_ATTACKERS)
{
//body
}
2. else if(gTeam[i] == TEAM_ATTACKERS && fTeam[i] == TEAM_DEFENDERS)
{
//body
}
3. else
{
//body when no one wins (timer runs out)

1. Defenders win and attackers lose.
2. Attackers win and defenders lose.
3. Timer runs out -> no-one wins or loses. (it's a tie)

Like you've made gTeam in your main post for winners, make an fTeam or any other variable for losers and use the if-else commands above.
Leave the body the same as it is.

Leave the other body part the same but modify as per needs. (the modify part is the messages I'm talking about.)

I've summarized it all in my post above, please go through it again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)