Help in basic spectating?
#1

Hi, Im trying to create a /spec command with the use of keyboard buttons to spectate the previous player with 'jump', next player with 'sprint' and get off of spec with 'crouch'. So far I did these things below but for the prev/next buttons, theyre not working.

The main idea is that there are 2 interiors, in one interior the 2 teams fight and when their players get killed, they spawn in another interior called the 'lounge'. the ones in the lounge can /spec players who are still in the first interior but NOT the ones in the lounge, including themselves. also if they reached id 0 and wants to spec the prev player, they will see the player with the highest player id if hes connected and the same when they spec the highest player id and wants to spec the next player, which would go to id 0 if hes connected.

this is what i got:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   if(gTeam[playerid][inspec] == 1) //if the one using /spec is in spec
   {
       if(PRESSED(KEY_JUMP)) //prev player
       {
           if(spectated == 0)
           {
               spectated = TEAMACOUNT+TEAMBCOUNT-1;
              PlayerSpectatePlayer(playerid, spectated);
         }
         else if(spectated != 0 || spectated == playerid)
         {
             PlayerSpectatePlayer(playerid, spectated-1);
         }

       if(PRESSED(KEY_SPRINT)) //next player                               
       {
           if(spectated == TEAMACOUNT+TEAMBCOUNT-1)
           {
               spectated = 0;
              PlayerSpectatePlayer(playerid, spectated);
         }
         else if(spectated != TEAMACOUNT+TEAMBCOUNT-1 || spectated == playerid)
         {
             PlayerSpectatePlayer(playerid, spectated+1);
         }

       if(PRESSED(KEY_CROUCH)) //out of spec - this part of crouch is correct, so no need to fix that
       {
           gTeam[playerid][inspec] = 0;
           TogglePlayerSpectating(playerid, 0);
          SetPlayerInterior(playerid, 12);         // this is the lounge
           SetPlayerPos(playerid, 2324.419921,-1145.568359,1050.710083);
           SetPlayerTeam(playerid, 4);
       }
   }
   return 1;
}
i cant seem to get the right math involved there, can anyone help? id appreciate it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)