Problem with jump
#1

Hey there.

This is the part of the gamemode which makes the player able to jump twice as high and gets his health back after he falls.
Works great for player ID0 but it kills all other players on the server. The version of the server is 3.0z and the gamemode has been recompiled and all of the plugins are updated.

Thanks for any help.
rep ++

This is my code:
PHP код:
new Float:SaveHealth[MAX_PLAYERS];
new 
MordidaT[MAX_PLAYERS] = 0;
new 
Morda;
forward TimmerMordidas();
forward healtx();
///////////////////////////////////////////////////////
Morda SetTimer("TimmerMordidas"30001);
///////////////////////////////////////////////////////
public TimmerMordidas()
{
    for(new 
playerid 0playerid MAX_PLAYERSplayerid++)
       {
        if(
IsPlayerConnected(playerid))
           {
            
MordidaT[playerid] = 0;
        }
       }
}
///////////////////////////////////////////////////////
public healtx() 
{
    for(new 
playerid 0playerid MAX_PLAYERSplayerid++)
    {
            if(
IsPlayerConnected(playerid))
        {
            
SetPlayerHealth(playeridSaveHealth[playerid]); 
        }
    }
}
///////////////////////////////////////////////////////
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_JUMP)
    if(
PlayerInfo[playerid][pJeZombi] == 1)
    { 
        if(
PlayerInfo[playerid][pZombiSkill] == || PlayerInfo[playerid][pZombiSkill] >= 7)
        {
            if(
MordidaT[playerid] == 0)
                {
                
MordidaT[playerid] = 1;
                        
GetPlayerHealth(playeridSaveHealth[playerid]); 
                    new 
Float:xFloat:yFloat:z;
                      
SetTimer("healtx",2000,0);
                        
GetPlayerVelocity(playeridxyz);
                        
SetPlayerVelocity(playerid,,z+0.5);
                }
          }
        else
        {
                
ClearAnimations(playerid);
        }
    }
}
///////////////////////////////////////////////////////        
public OnGameModeExit()
{
    foreach(
Playeri)
    {
          
KillTimer(Morda);
      }
}
/////////////////////////////////////////////////////// 
Reply
#2

Код:
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
            if(IsPlayerConnected(playerid))
        {
            SetPlayerHealth(playerid, SaveHealth[playerid]); 
        }
    }
You're using a loop to check thru all players and set all of their healths to whatever it was saved. Since it is only saved for the player that jamp and got the variable setted, everyone gets their health set to the default of the variable, which is 0 unless you've changed it.

You can fix that by using SetTimerEx to add a player parameter ( and even a health parameter) instead of using a global timer.
Reply
#3

Thank you for your response

[I]PlayerInfo[pREPPoints]++;

I was changed:
Quote:

Morda = SetTimer("TimmerMordidas", 3000, 1);
To:
Morda = SetTimerEx("TimmerMordidas",3000,1,"i",playerid);



SetTimerEx("healtx",2000,0);
To:
SetTimerEx("healtx",2000,0,"i",playerid);

But the problem still exists. What am I doing wrong?
Reply
#4

Change the whole function itself

Add a player parameter, and just set the variable of that player.

Код:
forward healtx(playerid);
public healtx(playerid) 
{ 
       SetPlayerHealth(playerid, SaveHealth[playerid]);  
}
Reply
#5

Thank you for your time. Now it's ok.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)