Safe place Help!
#1

Hi Guys,

I made a Safe Mode place,

So i wan't to avoid the fights etc..

So i did this code :

PHP код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(
IsSafe[playerid] == 1) {
     
ApplyAnimation(playerid"DANCING""bd_clap"4.1111111);
     
SendClientMessage(playerid,COLOR_LIGHTBLUE"Vous ne pouvez blesser quelqu'un en Safe Mode");
     }
  } 
Under OnPlayerTakeDamage

But i didn't work, the players can shot they others.. :S

Help?
Reply
#2

It wouldn't work because OnPlayerTakeDamage is called after the damage is done, not before that. I may think of a more efficient way of doing this by using OnPlayerWeaponShot...

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    switch(hittype)
    {
        case BULLET_HIT_TYPE_PLAYER: // If what was hit by playerid is a PLAYER
        {
            if(gTeam[hitid] == TEAM_SURVIVANT && gTeam[playerid] == TEAM_SURVIVANT)
            {
                if(IsSafe[hitid] == 1)
                {
                    ApplyAnimation(hitid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
                    SendClientMessage(hitid, COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
                    // Here's the trick:
                    // we're going to return 0 if playerid is in Safe Mode
                    // which prevents the bullet and its damage
                    // like nothing happened in the first place
                    return 0; // prevent bullet and its damage
                }
            }
        }
    }
    return 1; // None of our checks were broken, so we should allow this bullet
}
Reply
#3

It works, but i shows me that when i'm getting betten up.. xD
Reply
#4

I don't understand?
Reply
#5

pawn Код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(IsSafe[playerid] == 1) {
     ApplyAnimation(playerid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
     TogglePlayerControllableEx(playerid, 0);
     SendClientMessage(playerid,COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
     }
}

That should fix your issue..
That will stop people taking DMG, But also it will stop them from moving.

Код:
#define FLOAT_INFINITY (Float:0x7F800000)
pawn Код:
if(gTeam[playerid] == TEAM_SURVIVANT && gTeam[issuerid] == TEAM_SURVIVANT) {
    if(IsSafe[playerid] == 1) {
     
     SetPlayerHealth(playerid, FLOAT_INFINITY);
     ApplyAnimation(playerid, "DANCING", "bd_clap", 4.1, 1, 1, 1, 1, 1, 1);
     SendClientMessage(playerid,COLOR_LIGHTBLUE, "Vous ne pouvez blesser quelqu'un en Safe Mode");
     } else {
         ClearAnimation(playerid);
         SetPlayerHealth(playerid, 100);
     }
}

That will stop them being damaged
Reply
#6

Doesn't work..

Help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)