Help: Change Team at Die
#1

Hello guys, I'm trying to make a function in OnPlayerDeath that when you die "Respawn" in the Team that you chose with /class, the problem is that it appears randomly in any Team ... Someone can help me ??

PHP код:
new 21;
new 
2;
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
A)
    {
        
SetTimerEx("Team1"3300false"i"playerid);
    }
     else if(
B)
    {
          
SetTimerEx("Team2"3300false"i"playerid);
    } 
Reply
#2

Show your timers.
And you might want to assign the variable A and B with [MAX_PLAYERS];.
if(A[playerid]).
Reply
#3

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Show your timers.
And you might want to assign the variable A and B with [MAX_PLAYERS];.
if(A[playerid]).
In what way can I put the code to work??

PHP код:
public Team1(playerid)
{
  switch(
random(6)) // Negros
  
{
        case 
0:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
          switch(
random(8))
         {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
4: {SetPlayerSkin(playerid28);
                 
SetSpawnInfo(playerid,0,28,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2636.9077,260.5389,4.3281,75.9486,30,150,25,50,29,150);}
         }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
        case 
1:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
        switch(
random(8))
         {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
4: {SetPlayerSkin(playerid28);
                 
SetSpawnInfo(playerid,0,28,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2659.7424,260.6835,4.6328,20.2774,30,150,25,50,29,150);}
         }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
        case 
2:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         switch(
random(8))
         {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
4: {SetPlayerSkin(playerid28);
                 
SetSpawnInfo(playerid,0,28,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2695.9822,262.4749,4.6328,258.9438,30,150,25,50,29,150);}
         }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
        case 
3:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         switch(
random(8))
         {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
4: {SetPlayerSkin(playerid28);
                 
SetSpawnInfo(playerid,0,28,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2694.5286,276.3913,4.3359,230.1168,30,150,25,50,29,150);}
         }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
        case 
4:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         switch(
random(8))
         {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2659.1301,275.6968,4.3359,79.7154,30,150,25,50,29,150);}
         }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
        case 
5:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         switch(
random(8))
          {
                 case 
0: {SetPlayerSkin(playerid21);
                 
SetSpawnInfo(playerid,0,21,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
1: {SetPlayerSkin(playerid19);
                 
SetSpawnInfo(playerid,0,19,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
2: {SetPlayerSkin(playerid183);
                 
SetSpawnInfo(playerid,0,183,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
3: {SetPlayerSkin(playerid104);
                 
SetSpawnInfo(playerid,0,104,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
4: {SetPlayerSkin(playerid28);
                 
SetSpawnInfo(playerid,0,28,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
5: {SetPlayerSkin(playerid22);
                 
SetSpawnInfo(playerid,0,22,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
6: {SetPlayerSkin(playerid190);
                 
SetSpawnInfo(playerid,0,190,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
                 case 
7: {SetPlayerSkin(playerid195);
                 
SetSpawnInfo(playerid,0,195,-2665.8315,237.6608,4.3359,96.0087,30,150,25,50,29,150);}
          }
         
SetPlayerColor(playeridcolor_NEGROS);
        }
  }
}
public 
Team2(playerid)
{
  switch(
random(6)) //Civiles
  
{
        case 
0:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1762.0461,960.5403,24.8828,171.4048,26,100,29,150,24,20);
         
SetPlayerColor(playeridcolor_CIVILES);
        }
        case 
1:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1771.2639,961.1591,24.8828,167.9581,26,100,29,150,24,20);
         
SetPlayerColor(playeridcolor_CIVILES);
        }
        case 
2:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1751.0995,961.6115,24.8828,176.7314,26,100,29,150,24,20);
         
SetPlayerColor(playeridcolor_CIVILES);
        }
        case 
3:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1739.0233,961.1733,24.8828,171.0913,26,100,29,150,24,20);
             
SetPlayerColor(playeridcolor_CIVILES);
        }
        case 
4:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1743.8237,946.1083,24.8828,15.3633,26,100,29,150,24,20);
             
SetPlayerColor(playeridcolor_CIVILES);
        }
        case 
5:
        {
         
GameTextForPlayer(playerid"~g~Skin Changed!"30003);
         
SetPlayerSkin(playerid2);
         
SetSpawnInfo(playerid,1,2,-1764.9819,945.7482,24.8828,31.9701,26,100,29,150,24,20);
             
SetPlayerColor(playeridcolor_CIVILES);
        }
}

Reply
#4

Where do you assign the A and B variables to the player?
Reply
#5

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Where do you assign the A and B variables to the player?
here:

PHP код:

new SKIN_MODELS[] = {
    
21,
    
2,
    
124,
    
122,
    
285,
    
108,
    
248,
    
295,
    
159,
    
50,
    
296,
    
287
};
new 
SKIN_NAMES[][] = {
    
"__Negros",
    
"_Civiles",
    
"___Mafia",
    
"____Nang",
    
"____Swat",
    
"___Maras",
    
"___Biker",
    
"____Rich",
    
"_Farmers",
    
"Mechanic",
    
"____Pimp",
    
"Soldados"
};
new 
21;
new 
2;
new 
124;
new 
122;
new 
285;
new 
108;
public 
OnPlayerRequestClass(playeridclassid)
{
    
PlayAudioStreamForPlayer(playerid"https://open.spotify.com/track/677emOQgVxZAMZcLFEAr1z?si=sBh9rxFWSXGAU4UzWPaxCQ");
    
SetSpawnInfo(playerid000030000000);
    
TogglePlayerSpectating(playeridtrue);
    
SetTimerEx("login_dialog"00"i"playerid);
const 
MAX_SKINS 312;
    static 
string[MAX_SKINS 16];
    if (
string[0] == EOS) {
        for (new 
iMAX_SKINSi++) {
            
format(stringsizeof string"%s%i\tID: %i\n"stringii);
        }
    }
    
    
    return 
ShowPreviewModelDialog(playerid0"Selecciуn de Equipo"SKIN_MODELS,SKIN_NAMES "Select""Cancel");
}
CMD:class(playerid,params[])
{
    
GetPlayerHealth(playeridhealth);
    
ShowPlayerDialog(playerid1DIALOG_STYLE_LIST"Equipos","\nNegros\nCiviles\nMafia\nNang\nSwat\nMaras\nBiker\nRich\nFarmers\nMechanic\nPimp\nSoldados" "Select""");
     
SendClientMessage(playerid, -1"Your class will be changed in 10 seconds.");
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
if(
dialogid == 1)
{
switch(
listitem)
{
    case 
0:{if(A)
    {
    
SetTimerEx("ClassSelection1"10000false"i"playerid);
    }}
    case 
1:{if(B)
    {
    
SetTimerEx("ClassSelection2"10000false"i"playerid);
    }}
    case 
2:{if(C)
    {
    
SetTimerEx("ClassSelection3"10000false"i"playerid);
    }}
    case 
3:{if(D)
    {
    
SetTimerEx("ClassSelection4"10000false"i"playerid);
    }}
    case 
4:{if(E)
    {
    
SetTimerEx("ClassSelection5"10000false"i"playerid);
    }}
    case 
5:{if(F)
    {
    
SetTimerEx("ClassSelection6"10000false"i"playerid);
    }}
}

Reply
#6

But you never assign any variable to a player, so how do you expect the script to put a player in the same team he used to be?
From my point of view that entire script should be rewritten.
Reply
#7

Quote:
Originally Posted by saffierr
Посмотреть сообщение
But you never assign any variable to a player, so how do you expect the script to put a player in the same team he used to be?
From my point of view that entire script should be rewritten.
can you give an example of the variable you're talking about?
Reply
#8

For example, assign variable A to a player.
new A[MAX_PLAYERS];
A[playerid] = bla bla;
then under OnPlayerDeath
if(A[playerid] == blabla) // code
Reply
#9

Quote:
Originally Posted by bookknp
Посмотреть сообщение
hmmm
dont work

PHP код:
new gTeam[MAX_PLAYERS];
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
gTeam[playerid] == A)) //<----- (19916)
    
{
        
SetTimerEx("Team1"3300false"i"playerid);  
    }
    else if(
gTeam[playerid] == B))
    {
          
SetTimerEx("Team2"3300false"i"playerid);
    } 
Reply
#10

As I said your code needs to be rewritten.
And I just gave you a slight example, not expecting it to work, just to give you an idea.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)